From 757d5bad7448368f8a2607b5e091d98dd4190dd5 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 18 Sep 2008 03:56:08 +0000 Subject: [PATCH] + Add xmpp_conn_get_context() to get the ctx a connection belongs to. Fixes #10 * Properly use altdomain when no SRV record. Fixes #2 - Remove unused function declarations from strophe.h. Fixes #1 --- src/conn.c | 17 ++++++++++++++++- strophe.h | 3 +-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/conn.c b/src/conn.c index 9763483..96fe693 100644 --- a/src/conn.c +++ b/src/conn.c @@ -320,6 +320,18 @@ void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass) conn->pass = xmpp_strdup(conn->ctx, pass); } +/** Get the strophe context that the connection is associated with. +* @param conn a Strophe connection object +* +* @return a Strophe context +* +* @ingroup Connections +*/ +xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn) +{ + return conn->ctx; +} + /** Initiate a connection to the XMPP server. * This function returns immediately after starting the connection * process to the XMPP server, and notifiations of connection state changes @@ -359,7 +371,10 @@ int xmpp_connect_client(xmpp_conn_t * const conn, if (!sock_srv_lookup("xmpp-client", "tcp", conn->domain, connectdomain, 2048, &connectport)) { xmpp_debug(conn->ctx, "xmpp", "SRV lookup failed."); - if (!altdomain) domain = conn->domain; + if (!altdomain) + domain = conn->domain; + else + domain = altdomain; xmpp_debug(conn->ctx, "xmpp", "Using alternate domain %s, port %d", altdomain, altport); strcpy(connectdomain, domain); connectport = altport ? altport : 5222; diff --git a/strophe.h b/strophe.h index cc210c1..8e2b474 100644 --- a/strophe.h +++ b/strophe.h @@ -215,6 +215,7 @@ const char *xmpp_conn_get_jid(const xmpp_conn_t * const conn); void xmpp_conn_set_jid(xmpp_conn_t * const conn, const char * const jid); const char *xmpp_conn_get_pass(const xmpp_conn_t * const conn); void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass); +xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn); int xmpp_connect_client(xmpp_conn_t * const conn, const char * const altdomain, @@ -325,8 +326,6 @@ int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza, /* common stanza helpers */ char *xmpp_stanza_get_type(xmpp_stanza_t * const stanza); char *xmpp_stanza_get_id(xmpp_stanza_t * const stanza); -int xmpp_stanza_get_to(); -int xmpp_stanza_get_from(); int xmpp_stanza_set_id(xmpp_stanza_t * const stanza, const char * const id); int xmpp_stanza_set_type(xmpp_stanza_t * const stanza,