diff --git a/ChangeLog b/ChangeLog index 07630a0..20275ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ - LibreSSL support - New API: - xmpp_stanza_get_child_by_name_and_ns() + - xmpp_conn_is_connecting() + - xmpp_conn_is_connected() + - xmpp_conn_is_disconnected() 0.9.3 - PLAIN mechanism is used only when no other mechanisms are supported diff --git a/src/conn.c b/src/conn.c index 91413d5..9b78cc9 100644 --- a/src/conn.c +++ b/src/conn.c @@ -1002,6 +1002,37 @@ int xmpp_conn_is_secured(xmpp_conn_t * const conn) return conn->secured && !conn->tls_failed && conn->tls != NULL ? 1 : 0; } +/** + * @return TRUE if connection is in connecting state and FALSE otherwise + * + * @ingroup Connections + */ +int xmpp_conn_is_connecting(xmpp_conn_t * const conn) +{ + return conn->state == XMPP_STATE_CONNECTING ? 1 : 0; +} + +/** + * @return TRUE if connection is in connected state and FALSE otherwise + * + * @ingroup Connections + */ +int xmpp_conn_is_connected(xmpp_conn_t * const conn) +{ + return conn->state == XMPP_STATE_CONNECTED ? 1 : 0; +} + +/** + * @return TRUE if connection is in disconnected state and FALSE otherwise + * + * @ingroup Connections + */ +int xmpp_conn_is_disconnected(xmpp_conn_t * const conn) +{ + return conn->state == XMPP_STATE_DISCONNECTED ? 1 : 0; +} + + /* timed handler for cleanup if normal disconnect procedure takes too long */ static int _disconnect_cleanup(xmpp_conn_t * const conn, void * const userdata) diff --git a/strophe.h b/strophe.h index 036797b..17b8dd5 100644 --- a/strophe.h +++ b/strophe.h @@ -237,6 +237,9 @@ xmpp_ctx_t *xmpp_conn_get_context(xmpp_conn_t * const conn); void xmpp_conn_disable_tls(xmpp_conn_t * const conn); int xmpp_conn_is_secured(xmpp_conn_t * const conn); void xmpp_conn_set_keepalive(xmpp_conn_t * const conn, int timeout, int interval); +int xmpp_conn_is_connecting(xmpp_conn_t * const conn); +int xmpp_conn_is_connected(xmpp_conn_t * const conn); +int xmpp_conn_is_disconnected(xmpp_conn_t * const conn); int xmpp_connect_client(xmpp_conn_t * const conn, const char * const altdomain,