本文整理汇总了C++中xmpp_disconnect函数的典型用法代码示例。如果您正苦于以下问题:C++ xmpp_disconnect函数的具体用法?C++ xmpp_disconnect怎么用?C++ xmpp_disconnect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmpp_disconnect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handle_legacy
static int _handle_legacy(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *type, *name;
/* delete missing handler */
xmpp_timed_handler_delete(conn, _handle_missing_legacy);
/* server responded to legacy auth request */
type = xmpp_stanza_get_type(stanza);
name = xmpp_stanza_get_name(stanza);
if (!type || strcmp(name, "iq") != 0) {
xmpp_error(conn->ctx, "xmpp", "Server sent us an unexpected response "\
"to legacy authentication request.");
xmpp_disconnect(conn);
} else if (strcmp(type, "error") == 0) {
/* legacy client auth failed, no more fallbacks */
xmpp_error(conn->ctx, "xmpp", "Legacy client authentication failed.");
xmpp_disconnect(conn);
} else if (strcmp(type, "result") == 0) {
/* auth succeeded */
xmpp_debug(conn->ctx, "xmpp", "Legacy auth succeeded.");
conn->authenticated = 1;
conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata);
} else {
xmpp_error(conn->ctx, "xmpp", "Server sent us a legacy authentication "\
"response with a bad type.");
xmpp_disconnect(conn);
}
return 0;
}
示例2: _handle_session
static int _handle_session(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *type;
/* delete missing session handler */
xmpp_timed_handler_delete(conn, _handle_missing_session);
/* server has replied to the session request */
type = xmpp_stanza_get_type(stanza);
if (type && strcmp(type, "error") == 0) {
xmpp_error(conn->ctx, "xmpp", "Session establishment failed.");
xmpp_disconnect(conn);
} else if (type && strcmp(type, "result") == 0) {
xmpp_debug(conn->ctx, "xmpp", "Session establishment successful.");
conn->authenticated = 1;
/* call connection handler */
conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata);
} else {
xmpp_error(conn->ctx, "xmpp", "Server sent malformed session reply.");
xmpp_disconnect(conn);
}
return 0;
}
示例3: _handle_register
static int _handle_register(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *type;
/* delete missing handler */
xmpp_timed_handler_delete(conn, _handle_missing_register);
/* server responded to legacy auth request */
type = xmpp_stanza_get_type(stanza);
if (!type) {
xmpp_error(conn->ctx, "xmpp", "Server sent us an unexpected response "\
"to register request.");
xmpp_disconnect(conn);
} else if (strcmp(type, "error") == 0) {
/* legacy client auth failed, no more fallbacks */
xmpp_error(conn->ctx, "xmpp", "Register clientfailed.");
xmpp_disconnect(conn);
} else if (strcmp(type, "result") == 0) {
/* auth succeeded */
xmpp_debug(conn->ctx, "xmpp", "Register succeeded.");
_auth(conn);
} else {
xmpp_error(conn->ctx, "xmpp", "Server sent us a register" \
"response with a bad type.");
xmpp_disconnect(conn);
}
return 0;
}
示例4: _jabber_disconnect
static void
_jabber_disconnect(void)
{
// if connected, send end stream and wait for response
if (jabber_conn.conn_status == JABBER_CONNECTED) {
log_info("Closing connection");
jabber_conn.conn_status = JABBER_DISCONNECTING;
xmpp_disconnect(jabber_conn.conn);
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
jabber_process_events();
}
_connection_free_saved_account();
_connection_free_saved_details();
_connection_free_session_data();
if (jabber_conn.conn != NULL) {
xmpp_conn_release(jabber_conn.conn);
jabber_conn.conn = NULL;
}
if (jabber_conn.ctx != NULL) {
xmpp_ctx_free(jabber_conn.ctx);
jabber_conn.ctx = NULL;
}
}
jabber_conn.conn_status = JABBER_STARTED;
FREE_SET_NULL(jabber_conn.presence_message);
FREE_SET_NULL(jabber_conn.domain);
}
示例5: _handle_proceedtls_default
static int _handle_proceedtls_default(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *name;
name = xmpp_stanza_get_name(stanza);
xmpp_debug(conn->ctx, "xmpp",
"handle proceedtls called for %s", name);
if (strcmp(name, "proceed") == 0) {
xmpp_debug(conn->ctx, "xmpp", "proceeding with TLS");
conn->tls = tls_new(conn->ctx, conn->sock);
if (!tls_start(conn->tls))
{
xmpp_debug(conn->ctx, "xmpp", "Couldn't start TLS! error %d", tls_error(conn->tls));
tls_free(conn->tls);
conn->tls = NULL;
conn->tls_failed = 1;
/* failed tls spoils the connection, so disconnect */
xmpp_disconnect(conn);
}
else
{
conn->secured = 1;
conn_prepare_reset(conn, auth_handle_open);
conn_open_stream(conn);
}
}
return 0;
}
示例6: _handle_missing_session
static int _handle_missing_session(xmpp_conn_t * const conn,
void * const userdata)
{
xmpp_error(conn->ctx, "xmpp", "Server did not reply to session request.");
xmpp_disconnect(conn);
return 0;
}
示例7: _handle_sasl_result
static int _handle_sasl_result(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *name;
name = xmpp_stanza_get_name(stanza);
/* the server should send a <success> or <failure> stanza */
if (strcmp(name, "failure") == 0) {
xmpp_debug(conn->ctx, "xmpp", "SASL %s auth failed",
(char *)userdata);
/* fall back to next auth method */
_auth(conn);
} else if (strcmp(name, "success") == 0) {
/* SASL PLAIN auth successful, we need to restart the stream */
xmpp_debug(conn->ctx, "xmpp", "SASL %s auth successful",
(char *)userdata);
/* reset parser */
conn_prepare_reset(conn, _handle_open_sasl);
/* send stream tag */
conn_open_stream(conn);
} else {
/* got unexpected reply */
xmpp_error(conn->ctx, "xmpp", "Got unexpected reply to SASL %s"\
"authentication.", (char *)userdata);
xmpp_disconnect(conn);
}
return 0;
}
示例8: jabber_disconnect
void
jabber_disconnect(void)
{
// if connected, send end stream and wait for response
if (jabber_conn.conn_status == JABBER_CONNECTED) {
char *account_name = jabber_get_account_name();
const char *fulljid = jabber_get_fulljid();
plugins_on_disconnect(account_name, fulljid);
log_info("Closing connection");
accounts_set_last_activity(jabber_get_account_name());
jabber_conn.conn_status = JABBER_DISCONNECTING;
xmpp_disconnect(jabber_conn.conn);
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
jabber_process_events(10);
}
_connection_free_saved_account();
_connection_free_saved_details();
_connection_free_session_data();
if (jabber_conn.conn) {
xmpp_conn_release(jabber_conn.conn);
jabber_conn.conn = NULL;
}
if (jabber_conn.ctx) {
xmpp_ctx_free(jabber_conn.ctx);
jabber_conn.ctx = NULL;
}
}
jabber_conn.conn_status = JABBER_STARTED;
FREE_SET_NULL(jabber_conn.presence_message);
FREE_SET_NULL(jabber_conn.domain);
}
示例9: jabber_autoping_fail
void
jabber_autoping_fail(void)
{
if (jabber_conn.conn_status == JABBER_CONNECTED) {
log_info("Closing connection");
char *account_name = jabber_get_account_name();
const char *fulljid = jabber_get_fulljid();
plugins_on_disconnect(account_name, fulljid);
accounts_set_last_activity(jabber_get_account_name());
jabber_conn.conn_status = JABBER_DISCONNECTING;
xmpp_disconnect(jabber_conn.conn);
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
jabber_process_events(10);
}
if (jabber_conn.conn) {
xmpp_conn_release(jabber_conn.conn);
jabber_conn.conn = NULL;
}
if (jabber_conn.ctx) {
xmpp_ctx_free(jabber_conn.ctx);
jabber_conn.ctx = NULL;
}
}
FREE_SET_NULL(jabber_conn.presence_message);
FREE_SET_NULL(jabber_conn.domain);
jabber_conn.conn_status = JABBER_DISCONNECTED;
_jabber_lost_connection();
}
示例10: xmpp_cleanup
void
xmpp_cleanup() {
xmpp_disconnect();
if (connection) lm_connection_unref(connection);
xmpp_roster_cleanup();
config_cleanup();
} /* xmpp_cleanup */
示例11: handle_reply
int handle_reply(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
xmpp_stanza_t *query, *item;
char *type, *name;
type = xmpp_stanza_get_type(stanza);
if (strcmp(type, "error") == 0)
fprintf(stderr, "ERROR: query failed\n");
else {
query = xmpp_stanza_get_child_by_name(stanza, "query");
printf("Roster:\n");
for (item = xmpp_stanza_get_children(query); item;
item = xmpp_stanza_get_next(item))
if ((name = xmpp_stanza_get_attribute(item, "name")))
printf("\t %s (%s) sub=%s\n",
name,
xmpp_stanza_get_attribute(item, "jid"),
xmpp_stanza_get_attribute(item, "subscription"));
else
printf("\t %s sub=%s\n",
xmpp_stanza_get_attribute(item, "jid"),
xmpp_stanza_get_attribute(item, "subscription"));
printf("END OF LIST\n");
}
/* disconnect */
xmpp_disconnect(conn);
return 0;
}
示例12: _handle_component_hs_response
/* Check if the received stanza is <handshake/> and set auth to true
* and fire connection handler.
*/
int _handle_component_hs_response(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza,
void * const userdata)
{
char *name;
xmpp_timed_handler_delete(conn, _handle_missing_handshake);
name = xmpp_stanza_get_name(stanza);
if (strcmp(name, "handshake") != 0) {
char *msg;
size_t msg_size;
xmpp_stanza_to_text(stanza, &msg, &msg_size);
if (msg) {
xmpp_debug(conn->ctx, "auth", "Handshake failed: %s", msg);
xmpp_free(conn->ctx, msg);
}
xmpp_disconnect(conn);
return XMPP_EINT;
} else {
conn->authenticated = 1;
conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata);
}
/* We don't need this handler anymore, return 0 so it can be deleted
* from the list of handlers.
*/
return 0;
}
示例13: process_input
void *console_routine(void *arg)
{
xmpp_conn_t *conn = (xmpp_conn_t*)arg;
process_input(conn);
xmpp_disconnect(conn);
return NULL;
}
示例14: _handle_missing_features_sasl
static int _handle_missing_features_sasl(xmpp_conn_t * const conn,
void * const userdata)
{
xmpp_error(conn->ctx, "xmpp", "Did not receive stream features "\
"after SASL authentication.");
xmpp_disconnect(conn);
return 0;
}
示例15: conn_handler
/* define a handler for connection events */
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
const int error, xmpp_stream_error_t * const stream_error,
void * const userdata)
{
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
if (status == XMPP_CONN_CONNECT) {
fprintf(stderr, "DEBUG: connected\n");
xmpp_disconnect(conn);
}
else {
fprintf(stderr, "DEBUG: disconnected\n");
xmpp_stop(ctx);
}
}