mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 22:26:21 +00:00
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
This commit is contained in:
@@ -342,7 +342,7 @@ connection_connect_raw(const char* const altdomain, int port,
|
||||
#endif
|
||||
|
||||
if (connect_status == 0) {
|
||||
conn.conn_status = JABBER_CONNECTING;
|
||||
conn.conn_status = JABBER_RAW_CONNECTING;
|
||||
} else {
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
}
|
||||
@@ -686,6 +686,21 @@ _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));
|
||||
|
||||
break;
|
||||
|
||||
// disconnected
|
||||
case XMPP_CONN_DISCONNECT:
|
||||
log_debug("Connection handler: XMPP_CONN_DISCONNECT");
|
||||
|
||||
@@ -2658,14 +2658,15 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
void
|
||||
iq_register_new_account(const char* const user, const char* const password)
|
||||
{
|
||||
//char* id = connection_create_stanza_id();
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t* iq = stanza_register_new_account(ctx, user, password);
|
||||
|
||||
const char* id = xmpp_stanza_get_id(iq);
|
||||
iq_id_handler_add(id, _register_new_account_result_id_handler, NULL, NULL);
|
||||
iq_id_handler_add(id, _register_new_account_result_id_handler, NULL, NULL); // FIXME: function doesn't seem to ever run?
|
||||
|
||||
log_debug("HI hi sending registration stanza");
|
||||
iq_send_stanza(iq);
|
||||
log_debug("registration stanza has been sent");
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,43 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
|
||||
saved_details.auth_policy);
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
session_connect_raw(const char* const altdomain, const int port, const char* const tls_policy,
|
||||
const char* const auth_policy)
|
||||
{
|
||||
assert(altdomain != NULL);
|
||||
|
||||
_session_free_saved_account();
|
||||
_session_free_saved_details();
|
||||
|
||||
// save details for reconnect
|
||||
saved_details.altdomain = strdup(altdomain);
|
||||
if (port != 0) {
|
||||
saved_details.port = port;
|
||||
} else {
|
||||
saved_details.port = 0;
|
||||
}
|
||||
if (tls_policy) {
|
||||
saved_details.tls_policy = strdup(tls_policy);
|
||||
} else {
|
||||
saved_details.tls_policy = NULL;
|
||||
}
|
||||
if (auth_policy) {
|
||||
saved_details.auth_policy = strdup(auth_policy);
|
||||
} else {
|
||||
saved_details.auth_policy = NULL;
|
||||
}
|
||||
|
||||
// raw connect
|
||||
log_info("Raw connecting to server: %s", altdomain);
|
||||
|
||||
return connection_connect_raw(
|
||||
saved_details.altdomain,
|
||||
saved_details.port,
|
||||
saved_details.tls_policy,
|
||||
saved_details.auth_policy);
|
||||
}
|
||||
|
||||
void
|
||||
session_autoping_fail(void)
|
||||
{
|
||||
@@ -261,6 +298,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 +582,4 @@ _session_free_saved_details(void)
|
||||
FREE_SET_NULL(saved_details.tls_policy);
|
||||
FREE_SET_NULL(saved_details.auth_policy);
|
||||
}
|
||||
|
||||
|
||||
@@ -2782,6 +2782,9 @@ stanza_register_new_account(xmpp_ctx_t* ctx, const char* const user, const char*
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,8 @@ 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);
|
||||
|
||||
jabber_conn_status_t session_connect_raw(const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
|
||||
void session_disconnect(void);
|
||||
void session_shutdown(void);
|
||||
void session_process_events(void);
|
||||
|
||||
Reference in New Issue
Block a user