conn: fixed indentations
This commit is contained in:
371
src/conn.c
371
src/conn.c
@@ -48,7 +48,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int _disconnect_cleanup(xmpp_conn_t * const conn,
|
static int _disconnect_cleanup(xmpp_conn_t * const conn,
|
||||||
void * const userdata);
|
void * const userdata);
|
||||||
|
|
||||||
static void _handle_stream_start(char *name, char **attrs,
|
static void _handle_stream_start(char *name, char **attrs,
|
||||||
void * const userdata);
|
void * const userdata);
|
||||||
@@ -72,52 +72,52 @@ xmpp_conn_t *xmpp_conn_new(xmpp_ctx_t * const ctx)
|
|||||||
xmpp_connlist_t *tail, *item;
|
xmpp_connlist_t *tail, *item;
|
||||||
|
|
||||||
if (ctx == NULL) return NULL;
|
if (ctx == NULL) return NULL;
|
||||||
conn = xmpp_alloc(ctx, sizeof(xmpp_conn_t));
|
|
||||||
|
|
||||||
|
conn = xmpp_alloc(ctx, sizeof(xmpp_conn_t));
|
||||||
if (conn != NULL) {
|
if (conn != NULL) {
|
||||||
conn->ctx = ctx;
|
conn->ctx = ctx;
|
||||||
|
|
||||||
conn->type = XMPP_UNKNOWN;
|
conn->type = XMPP_UNKNOWN;
|
||||||
conn->state = XMPP_STATE_DISCONNECTED;
|
conn->state = XMPP_STATE_DISCONNECTED;
|
||||||
conn->sock = -1;
|
conn->sock = -1;
|
||||||
conn->tls = NULL;
|
conn->tls = NULL;
|
||||||
conn->timeout_stamp = 0;
|
conn->timeout_stamp = 0;
|
||||||
conn->error = 0;
|
conn->error = 0;
|
||||||
conn->stream_error = NULL;
|
conn->stream_error = NULL;
|
||||||
|
|
||||||
/* default send parameters */
|
/* default send parameters */
|
||||||
conn->blocking_send = 0;
|
conn->blocking_send = 0;
|
||||||
conn->send_queue_max = DEFAULT_SEND_QUEUE_MAX;
|
conn->send_queue_max = DEFAULT_SEND_QUEUE_MAX;
|
||||||
conn->send_queue_len = 0;
|
conn->send_queue_len = 0;
|
||||||
conn->send_queue_head = NULL;
|
conn->send_queue_head = NULL;
|
||||||
conn->send_queue_tail = NULL;
|
conn->send_queue_tail = NULL;
|
||||||
|
|
||||||
/* default timeouts */
|
/* default timeouts */
|
||||||
conn->connect_timeout = CONNECT_TIMEOUT;
|
conn->connect_timeout = CONNECT_TIMEOUT;
|
||||||
|
|
||||||
conn->lang = xmpp_strdup(conn->ctx, "en");
|
conn->lang = xmpp_strdup(conn->ctx, "en");
|
||||||
if (!conn->lang) {
|
if (!conn->lang) {
|
||||||
xmpp_free(conn->ctx, conn);
|
xmpp_free(conn->ctx, conn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
conn->domain = NULL;
|
conn->domain = NULL;
|
||||||
conn->jid = NULL;
|
conn->jid = NULL;
|
||||||
conn->pass = NULL;
|
conn->pass = NULL;
|
||||||
conn->stream_id = NULL;
|
conn->stream_id = NULL;
|
||||||
conn->bound_jid = NULL;
|
conn->bound_jid = NULL;
|
||||||
|
|
||||||
conn->tls_support = 0;
|
conn->tls_support = 0;
|
||||||
conn->tls_disabled = 0;
|
conn->tls_disabled = 0;
|
||||||
conn->tls_mandatory = 0;
|
conn->tls_mandatory = 0;
|
||||||
conn->tls_legacy_ssl = 0;
|
conn->tls_legacy_ssl = 0;
|
||||||
conn->tls_failed = 0;
|
conn->tls_failed = 0;
|
||||||
conn->sasl_support = 0;
|
conn->sasl_support = 0;
|
||||||
conn->secured = 0;
|
conn->secured = 0;
|
||||||
|
|
||||||
conn->bind_required = 0;
|
conn->bind_required = 0;
|
||||||
conn->session_required = 0;
|
conn->session_required = 0;
|
||||||
|
|
||||||
conn->parser = parser_new(conn->ctx,
|
conn->parser = parser_new(conn->ctx,
|
||||||
_handle_stream_start,
|
_handle_stream_start,
|
||||||
_handle_stream_end,
|
_handle_stream_end,
|
||||||
_handle_stream_stanza,
|
_handle_stream_stanza,
|
||||||
@@ -125,35 +125,35 @@ xmpp_conn_t *xmpp_conn_new(xmpp_ctx_t * const ctx)
|
|||||||
conn->reset_parser = 0;
|
conn->reset_parser = 0;
|
||||||
conn_prepare_reset(conn, auth_handle_open);
|
conn_prepare_reset(conn, auth_handle_open);
|
||||||
|
|
||||||
conn->authenticated = 0;
|
conn->authenticated = 0;
|
||||||
conn->conn_handler = NULL;
|
conn->conn_handler = NULL;
|
||||||
conn->userdata = NULL;
|
conn->userdata = NULL;
|
||||||
conn->timed_handlers = NULL;
|
conn->timed_handlers = NULL;
|
||||||
/* we own (and will free) the hash values */
|
/* we own (and will free) the hash values */
|
||||||
conn->id_handlers = hash_new(conn->ctx, 32, NULL);
|
conn->id_handlers = hash_new(conn->ctx, 32, NULL);
|
||||||
conn->handlers = NULL;
|
conn->handlers = NULL;
|
||||||
|
|
||||||
/* give the caller a reference to connection */
|
/* give the caller a reference to connection */
|
||||||
conn->ref = 1;
|
conn->ref = 1;
|
||||||
|
|
||||||
/* add connection to ctx->connlist */
|
/* add connection to ctx->connlist */
|
||||||
tail = conn->ctx->connlist;
|
tail = conn->ctx->connlist;
|
||||||
while (tail && tail->next) tail = tail->next;
|
while (tail && tail->next) tail = tail->next;
|
||||||
|
|
||||||
item = xmpp_alloc(conn->ctx, sizeof(xmpp_connlist_t));
|
item = xmpp_alloc(conn->ctx, sizeof(xmpp_connlist_t));
|
||||||
if (!item) {
|
if (!item) {
|
||||||
xmpp_error(conn->ctx, "xmpp", "failed to allocate memory");
|
xmpp_error(conn->ctx, "xmpp", "failed to allocate memory");
|
||||||
xmpp_free(conn->ctx, conn->lang);
|
xmpp_free(conn->ctx, conn->lang);
|
||||||
parser_free(conn->parser);
|
parser_free(conn->parser);
|
||||||
xmpp_free(conn->ctx, conn);
|
xmpp_free(conn->ctx, conn);
|
||||||
conn = NULL;
|
conn = NULL;
|
||||||
} else {
|
} else {
|
||||||
item->conn = conn;
|
item->conn = conn;
|
||||||
item->next = NULL;
|
item->next = NULL;
|
||||||
|
|
||||||
if (tail) tail->next = item;
|
if (tail) tail->next = item;
|
||||||
else conn->ctx->connlist = item;
|
else conn->ctx->connlist = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
@@ -194,88 +194,88 @@ int xmpp_conn_release(xmpp_conn_t * const conn)
|
|||||||
int released = 0;
|
int released = 0;
|
||||||
|
|
||||||
if (conn->ref > 1)
|
if (conn->ref > 1)
|
||||||
conn->ref--;
|
conn->ref--;
|
||||||
else {
|
else {
|
||||||
ctx = conn->ctx;
|
ctx = conn->ctx;
|
||||||
|
|
||||||
/* remove connection from context's connlist */
|
/* remove connection from context's connlist */
|
||||||
if (ctx->connlist->conn == conn) {
|
if (ctx->connlist->conn == conn) {
|
||||||
item = ctx->connlist;
|
item = ctx->connlist;
|
||||||
ctx->connlist = item->next;
|
ctx->connlist = item->next;
|
||||||
xmpp_free(ctx, item);
|
xmpp_free(ctx, item);
|
||||||
} else {
|
} else {
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
item = ctx->connlist;
|
item = ctx->connlist;
|
||||||
while (item && item->conn != conn) {
|
while (item && item->conn != conn) {
|
||||||
prev = item;
|
prev = item;
|
||||||
item = item->next;
|
item = item->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
xmpp_error(ctx, "xmpp", "Connection not in context's list\n");
|
xmpp_error(ctx, "xmpp", "Connection not in context's list\n");
|
||||||
} else {
|
} else {
|
||||||
prev->next = item->next;
|
prev->next = item->next;
|
||||||
xmpp_free(ctx, item);
|
xmpp_free(ctx, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free handler stuff
|
/* free handler stuff
|
||||||
* note that userdata is the responsibility of the client
|
* note that userdata is the responsibility of the client
|
||||||
* and the handler pointers don't need to be freed since they
|
* and the handler pointers don't need to be freed since they
|
||||||
* are pointers to functions */
|
* are pointers to functions */
|
||||||
|
|
||||||
hlitem = conn->timed_handlers;
|
hlitem = conn->timed_handlers;
|
||||||
while (hlitem) {
|
while (hlitem) {
|
||||||
thli = hlitem;
|
thli = hlitem;
|
||||||
hlitem = hlitem->next;
|
hlitem = hlitem->next;
|
||||||
|
|
||||||
xmpp_free(ctx, thli);
|
xmpp_free(ctx, thli);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* id handlers
|
/* id handlers
|
||||||
* we have to traverse the hash table freeing list elements
|
* we have to traverse the hash table freeing list elements
|
||||||
* then release the hash table */
|
* then release the hash table */
|
||||||
iter = hash_iter_new(conn->id_handlers);
|
iter = hash_iter_new(conn->id_handlers);
|
||||||
while ((key = hash_iter_next(iter))) {
|
while ((key = hash_iter_next(iter))) {
|
||||||
hlitem = (xmpp_handlist_t *)hash_get(conn->id_handlers, key);
|
hlitem = (xmpp_handlist_t *)hash_get(conn->id_handlers, key);
|
||||||
while (hlitem) {
|
while (hlitem) {
|
||||||
thli = hlitem;
|
thli = hlitem;
|
||||||
hlitem = hlitem->next;
|
hlitem = hlitem->next;
|
||||||
xmpp_free(conn->ctx, thli->id);
|
xmpp_free(conn->ctx, thli->id);
|
||||||
xmpp_free(conn->ctx, thli);
|
xmpp_free(conn->ctx, thli);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hash_iter_release(iter);
|
hash_iter_release(iter);
|
||||||
hash_release(conn->id_handlers);
|
hash_release(conn->id_handlers);
|
||||||
|
|
||||||
hlitem = conn->handlers;
|
hlitem = conn->handlers;
|
||||||
while (hlitem) {
|
while (hlitem) {
|
||||||
thli = hlitem;
|
thli = hlitem;
|
||||||
hlitem = hlitem->next;
|
hlitem = hlitem->next;
|
||||||
|
|
||||||
if (thli->ns) xmpp_free(ctx, thli->ns);
|
if (thli->ns) xmpp_free(ctx, thli->ns);
|
||||||
if (thli->name) xmpp_free(ctx, thli->name);
|
if (thli->name) xmpp_free(ctx, thli->name);
|
||||||
if (thli->type) xmpp_free(ctx, thli->type);
|
if (thli->type) xmpp_free(ctx, thli->type);
|
||||||
xmpp_free(ctx, thli);
|
xmpp_free(ctx, thli);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->stream_error) {
|
if (conn->stream_error) {
|
||||||
xmpp_stanza_release(conn->stream_error->stanza);
|
xmpp_stanza_release(conn->stream_error->stanza);
|
||||||
if (conn->stream_error->text)
|
if (conn->stream_error->text)
|
||||||
xmpp_free(ctx, conn->stream_error->text);
|
xmpp_free(ctx, conn->stream_error->text);
|
||||||
xmpp_free(ctx, conn->stream_error);
|
xmpp_free(ctx, conn->stream_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_free(conn->parser);
|
parser_free(conn->parser);
|
||||||
|
|
||||||
if (conn->domain) xmpp_free(ctx, conn->domain);
|
if (conn->domain) xmpp_free(ctx, conn->domain);
|
||||||
if (conn->jid) xmpp_free(ctx, conn->jid);
|
if (conn->jid) xmpp_free(ctx, conn->jid);
|
||||||
if (conn->bound_jid) xmpp_free(ctx, conn->bound_jid);
|
if (conn->bound_jid) xmpp_free(ctx, conn->bound_jid);
|
||||||
if (conn->pass) xmpp_free(ctx, conn->pass);
|
if (conn->pass) xmpp_free(ctx, conn->pass);
|
||||||
if (conn->stream_id) xmpp_free(ctx, conn->stream_id);
|
if (conn->stream_id) xmpp_free(ctx, conn->stream_id);
|
||||||
if (conn->lang) xmpp_free(ctx, conn->lang);
|
if (conn->lang) xmpp_free(ctx, conn->lang);
|
||||||
xmpp_free(ctx, conn);
|
xmpp_free(ctx, conn);
|
||||||
released = 1;
|
released = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return released;
|
return released;
|
||||||
@@ -366,7 +366,7 @@ 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)
|
xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn)
|
||||||
{
|
{
|
||||||
return conn->ctx;
|
return conn->ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initiate a connection to the XMPP server.
|
/** Initiate a connection to the XMPP server.
|
||||||
@@ -391,10 +391,10 @@ xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn)
|
|||||||
* @ingroup Connections
|
* @ingroup Connections
|
||||||
*/
|
*/
|
||||||
int xmpp_connect_client(xmpp_conn_t * const conn,
|
int xmpp_connect_client(xmpp_conn_t * const conn,
|
||||||
const char * const altdomain,
|
const char * const altdomain,
|
||||||
unsigned short altport,
|
unsigned short altport,
|
||||||
xmpp_conn_handler callback,
|
xmpp_conn_handler callback,
|
||||||
void * const userdata)
|
void * const userdata)
|
||||||
{
|
{
|
||||||
char domain[2048];
|
char domain[2048];
|
||||||
int port;
|
int port;
|
||||||
@@ -551,15 +551,15 @@ void conn_disconnect(xmpp_conn_t * const conn)
|
|||||||
xmpp_debug(conn->ctx, "xmpp", "Closing socket.");
|
xmpp_debug(conn->ctx, "xmpp", "Closing socket.");
|
||||||
conn->state = XMPP_STATE_DISCONNECTED;
|
conn->state = XMPP_STATE_DISCONNECTED;
|
||||||
if (conn->tls) {
|
if (conn->tls) {
|
||||||
tls_stop(conn->tls);
|
tls_stop(conn->tls);
|
||||||
tls_free(conn->tls);
|
tls_free(conn->tls);
|
||||||
conn->tls = NULL;
|
conn->tls = NULL;
|
||||||
}
|
}
|
||||||
sock_close(conn->sock);
|
sock_close(conn->sock);
|
||||||
|
|
||||||
/* fire off connection handler */
|
/* fire off connection handler */
|
||||||
conn->conn_handler(conn, XMPP_CONN_DISCONNECT, conn->error,
|
conn->conn_handler(conn, XMPP_CONN_DISCONNECT, conn->error,
|
||||||
conn->stream_error, conn->userdata);
|
conn->stream_error, conn->userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prepares a parser reset. this is called from handlers. we can't
|
/* prepares a parser reset. this is called from handlers. we can't
|
||||||
@@ -579,10 +579,10 @@ void conn_parser_reset(xmpp_conn_t * const conn)
|
|||||||
|
|
||||||
/* timed handler for cleanup if normal disconnect procedure takes too long */
|
/* timed handler for cleanup if normal disconnect procedure takes too long */
|
||||||
static int _disconnect_cleanup(xmpp_conn_t * const conn,
|
static int _disconnect_cleanup(xmpp_conn_t * const conn,
|
||||||
void * const userdata)
|
void * const userdata)
|
||||||
{
|
{
|
||||||
xmpp_debug(conn->ctx, "xmpp",
|
xmpp_debug(conn->ctx, "xmpp",
|
||||||
"disconnection forced by cleanup timeout");
|
"disconnection forced by cleanup timeout");
|
||||||
|
|
||||||
conn_disconnect(conn);
|
conn_disconnect(conn);
|
||||||
|
|
||||||
@@ -601,15 +601,15 @@ static int _disconnect_cleanup(xmpp_conn_t * const conn,
|
|||||||
void xmpp_disconnect(xmpp_conn_t * const conn)
|
void xmpp_disconnect(xmpp_conn_t * const conn)
|
||||||
{
|
{
|
||||||
if (conn->state != XMPP_STATE_CONNECTING &&
|
if (conn->state != XMPP_STATE_CONNECTING &&
|
||||||
conn->state != XMPP_STATE_CONNECTED)
|
conn->state != XMPP_STATE_CONNECTED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* close the stream */
|
/* close the stream */
|
||||||
xmpp_send_raw_string(conn, "</stream:stream>");
|
xmpp_send_raw_string(conn, "</stream:stream>");
|
||||||
|
|
||||||
/* setup timed handler in case disconnect takes too long */
|
/* setup timed handler in case disconnect takes too long */
|
||||||
handler_add_timed(conn, _disconnect_cleanup,
|
handler_add_timed(conn, _disconnect_cleanup,
|
||||||
DISCONNECT_TIMEOUT, NULL);
|
DISCONNECT_TIMEOUT, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send a raw string to the XMPP server.
|
/** Send a raw string to the XMPP server.
|
||||||
@@ -624,7 +624,7 @@ void xmpp_disconnect(xmpp_conn_t * const conn)
|
|||||||
* arguments to format
|
* arguments to format
|
||||||
*/
|
*/
|
||||||
void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
||||||
const char * const fmt, ...)
|
const char * const fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -636,28 +636,28 @@ void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (len >= 1024) {
|
if (len >= 1024) {
|
||||||
/* we need more space for this data, so we allocate a big
|
/* we need more space for this data, so we allocate a big
|
||||||
* enough buffer and print to that */
|
* enough buffer and print to that */
|
||||||
len++; /* account for trailing \0 */
|
len++; /* account for trailing \0 */
|
||||||
bigbuf = xmpp_alloc(conn->ctx, len);
|
bigbuf = xmpp_alloc(conn->ctx, len);
|
||||||
if (!bigbuf) {
|
if (!bigbuf) {
|
||||||
xmpp_debug(conn->ctx, "xmpp", "Could not allocate memory for send_raw_string");
|
xmpp_debug(conn->ctx, "xmpp", "Could not allocate memory for send_raw_string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
xmpp_vsnprintf(bigbuf, len, fmt, ap);
|
xmpp_vsnprintf(bigbuf, len, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
xmpp_debug(conn->ctx, "conn", "SENT: %s", bigbuf);
|
xmpp_debug(conn->ctx, "conn", "SENT: %s", bigbuf);
|
||||||
|
|
||||||
/* len - 1 so we don't send trailing \0 */
|
/* len - 1 so we don't send trailing \0 */
|
||||||
xmpp_send_raw(conn, bigbuf, len - 1);
|
xmpp_send_raw(conn, bigbuf, len - 1);
|
||||||
|
|
||||||
xmpp_free(conn->ctx, bigbuf);
|
xmpp_free(conn->ctx, bigbuf);
|
||||||
} else {
|
} else {
|
||||||
xmpp_debug(conn->ctx, "conn", "SENT: %s", buf);
|
xmpp_debug(conn->ctx, "conn", "SENT: %s", buf);
|
||||||
|
|
||||||
xmpp_send_raw(conn, buf, len);
|
xmpp_send_raw(conn, buf, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,7 +672,7 @@ void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
|||||||
* @param len the length of the data in the buffer
|
* @param len the length of the data in the buffer
|
||||||
*/
|
*/
|
||||||
void xmpp_send_raw(xmpp_conn_t * const conn,
|
void xmpp_send_raw(xmpp_conn_t * const conn,
|
||||||
const char * const data, const size_t len)
|
const char * const data, const size_t len)
|
||||||
{
|
{
|
||||||
xmpp_send_queue_t *item;
|
xmpp_send_queue_t *item;
|
||||||
|
|
||||||
@@ -684,8 +684,8 @@ void xmpp_send_raw(xmpp_conn_t * const conn,
|
|||||||
|
|
||||||
item->data = xmpp_alloc(conn->ctx, len);
|
item->data = xmpp_alloc(conn->ctx, len);
|
||||||
if (!item->data) {
|
if (!item->data) {
|
||||||
xmpp_free(conn->ctx, item);
|
xmpp_free(conn->ctx, item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(item->data, data, len);
|
memcpy(item->data, data, len);
|
||||||
item->len = len;
|
item->len = len;
|
||||||
@@ -694,13 +694,13 @@ void xmpp_send_raw(xmpp_conn_t * const conn,
|
|||||||
|
|
||||||
/* add item to the send queue */
|
/* add item to the send queue */
|
||||||
if (!conn->send_queue_tail) {
|
if (!conn->send_queue_tail) {
|
||||||
/* first item, set head and tail */
|
/* first item, set head and tail */
|
||||||
conn->send_queue_head = item;
|
conn->send_queue_head = item;
|
||||||
conn->send_queue_tail = item;
|
conn->send_queue_tail = item;
|
||||||
} else {
|
} else {
|
||||||
/* add to the tail */
|
/* add to the tail */
|
||||||
conn->send_queue_tail->next = item;
|
conn->send_queue_tail->next = item;
|
||||||
conn->send_queue_tail = item;
|
conn->send_queue_tail = item;
|
||||||
}
|
}
|
||||||
conn->send_queue_len++;
|
conn->send_queue_len++;
|
||||||
}
|
}
|
||||||
@@ -715,18 +715,18 @@ void xmpp_send_raw(xmpp_conn_t * const conn,
|
|||||||
* @ingroup Connections
|
* @ingroup Connections
|
||||||
*/
|
*/
|
||||||
void xmpp_send(xmpp_conn_t * const conn,
|
void xmpp_send(xmpp_conn_t * const conn,
|
||||||
xmpp_stanza_t * const stanza)
|
xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (conn->state == XMPP_STATE_CONNECTED) {
|
if (conn->state == XMPP_STATE_CONNECTED) {
|
||||||
if ((ret = xmpp_stanza_to_text(stanza, &buf, &len)) == 0) {
|
if ((ret = xmpp_stanza_to_text(stanza, &buf, &len)) == 0) {
|
||||||
xmpp_send_raw(conn, buf, len);
|
xmpp_send_raw(conn, buf, len);
|
||||||
xmpp_debug(conn->ctx, "conn", "SENT: %s", buf);
|
xmpp_debug(conn->ctx, "conn", "SENT: %s", buf);
|
||||||
xmpp_free(conn->ctx, buf);
|
xmpp_free(conn->ctx, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,16 +739,17 @@ void xmpp_send(xmpp_conn_t * const conn,
|
|||||||
void conn_open_stream(xmpp_conn_t * const conn)
|
void conn_open_stream(xmpp_conn_t * const conn)
|
||||||
{
|
{
|
||||||
xmpp_send_raw_string(conn,
|
xmpp_send_raw_string(conn,
|
||||||
"<?xml version=\"1.0\"?>" \
|
"<?xml version=\"1.0\"?>" \
|
||||||
"<stream:stream to=\"%s\" " \
|
"<stream:stream to=\"%s\" " \
|
||||||
"xml:lang=\"%s\" " \
|
"xml:lang=\"%s\" " \
|
||||||
"version=\"1.0\" " \
|
"version=\"1.0\" " \
|
||||||
"xmlns=\"%s\" " \
|
"xmlns=\"%s\" " \
|
||||||
"xmlns:stream=\"%s\">",
|
"xmlns:stream=\"%s\">",
|
||||||
conn->domain,
|
conn->domain,
|
||||||
conn->lang,
|
conn->lang,
|
||||||
conn->type == XMPP_CLIENT ? XMPP_NS_CLIENT : XMPP_NS_COMPONENT,
|
conn->type == XMPP_CLIENT ? XMPP_NS_CLIENT :
|
||||||
XMPP_NS_STREAMS);
|
XMPP_NS_COMPONENT,
|
||||||
|
XMPP_NS_STREAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int conn_tls_start(xmpp_conn_t * const conn)
|
int conn_tls_start(xmpp_conn_t * const conn)
|
||||||
|
|||||||
Reference in New Issue
Block a user