conn: implemented xmpp_connect_raw()
This function is similar to xmpp_connect_client(), but doesn't perform authentication. Instead, it calls user's connection handler immediately after establishing the connection. Hence, user can implement own authendication or registration procedures. Such a "raw" connection can be useful when user interaction is required (e.g. Data Forms in XEP-0077, OAuth2).
This commit is contained in:
14
src/auth.c
14
src/auth.c
@@ -288,6 +288,7 @@ static int _handle_proceedtls_default(xmpp_conn_t * const conn,
|
||||
xmpp_debug(conn->ctx, "xmpp", "proceeding with TLS");
|
||||
|
||||
if (conn_tls_start(conn) == 0) {
|
||||
conn_prepare_reset(conn, auth_handle_open);
|
||||
conn_open_stream(conn);
|
||||
} else {
|
||||
/* failed tls spoils the connection, so disconnect */
|
||||
@@ -1235,3 +1236,16 @@ int _handle_missing_handshake(xmpp_conn_t * const conn, void * const userdata)
|
||||
xmpp_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void auth_handle_open_raw(xmpp_conn_t * const conn)
|
||||
{
|
||||
handler_reset_timed(conn, 0);
|
||||
/* user handlers are not called before authentication is completed. */
|
||||
conn->authenticated = 1;
|
||||
conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata);
|
||||
}
|
||||
|
||||
void auth_handle_open_stub(xmpp_conn_t * const conn)
|
||||
{
|
||||
xmpp_warn(conn->ctx, "auth", "Stub callback is called.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user