1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-08-20 20:42:05 +01:00
commit 63f1798158
9 changed files with 239 additions and 376 deletions

View File

@ -116,11 +116,8 @@ blocked_add(char *jid)
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
char *id = create_unique_id("block"); char *id = create_unique_id("block");
xmpp_stanza_set_id(iq, id); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_t *block = xmpp_stanza_new(ctx); xmpp_stanza_t *block = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(block, STANZA_NAME_BLOCK); xmpp_stanza_set_name(block, STANZA_NAME_BLOCK);
@ -137,10 +134,10 @@ blocked_add(char *jid)
xmpp_stanza_release(block); xmpp_stanza_release(block);
iq_id_handler_add(id, _block_add_result_handler, free, strdup(jid)); iq_id_handler_add(id, _block_add_result_handler, free, strdup(jid));
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
free(id);
return TRUE; return TRUE;
} }
@ -155,11 +152,8 @@ blocked_remove(char *jid)
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
char *id = create_unique_id("unblock"); char *id = create_unique_id("unblock");
xmpp_stanza_set_id(iq, id); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_t *block = xmpp_stanza_new(ctx); xmpp_stanza_t *block = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(block, STANZA_NAME_UNBLOCK); xmpp_stanza_set_name(block, STANZA_NAME_UNBLOCK);
@ -176,10 +170,10 @@ blocked_remove(char *jid)
xmpp_stanza_release(block); xmpp_stanza_release(block);
iq_id_handler_add(id, _block_remove_result_handler, free, strdup(jid)); iq_id_handler_add(id, _block_remove_result_handler, free, strdup(jid));
free(id);
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
free(id);
return TRUE; return TRUE;
} }
@ -239,7 +233,7 @@ _block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
char *jid = (char*)userdata; char *jid = (char*)userdata;
const char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); const char *type = xmpp_stanza_get_type(stanza);
if (type == NULL) { if (type == NULL) {
log_info("Block response received for %s with no type attribute.", jid); log_info("Block response received for %s with no type attribute.", jid);
free(jid); free(jid);
@ -263,7 +257,7 @@ _block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
char *jid = (char*)userdata; char *jid = (char*)userdata;
const char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); const char *type = xmpp_stanza_get_type(stanza);
if (type == NULL) { if (type == NULL) {
log_info("Unblock response received for %s with no type attribute.", jid); log_info("Unblock response received for %s with no type attribute.", jid);
free(jid); free(jid);

View File

@ -406,12 +406,9 @@ _send_bookmarks(void)
{ {
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
char *id = create_unique_id("bookmarks_update"); char *id = create_unique_id("bookmarks_update");
xmpp_stanza_set_id(iq, id); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
free(id); free(id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);

View File

@ -67,7 +67,7 @@ _is_valid_form_element(xmpp_stanza_t *stanza)
return FALSE; return FALSE;
} }
const char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); const char *type = xmpp_stanza_get_type(stanza);
if ((g_strcmp0(type, "form") != 0) && if ((g_strcmp0(type, "form") != 0) &&
(g_strcmp0(type, "submit") != 0) && (g_strcmp0(type, "submit") != 0) &&
(g_strcmp0(type, "cancel") != 0) && (g_strcmp0(type, "cancel") != 0) &&

View File

@ -673,7 +673,7 @@ iq_send_ping(const char *const target)
static void static void
_error_handler(xmpp_stanza_t *const stanza) _error_handler(xmpp_stanza_t *const stanza)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
char *error_msg = stanza_get_error_message(stanza); char *error_msg = stanza_get_error_message(stanza);
if (id) { if (id) {
@ -690,7 +690,7 @@ _error_handler(xmpp_stanza_t *const stanza)
static int static int
_caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
@ -705,7 +705,7 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
log_info("Capabilities response handler fired"); log_info("Capabilities response handler fired");
} }
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
log_info("No from attribute"); log_info("No from attribute");
return 0; return 0;
@ -764,7 +764,7 @@ static int
_caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
char *jid = (char *)userdata; char *jid = (char *)userdata;
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
@ -780,7 +780,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd
log_info("Capabilities response handler fired"); log_info("Capabilities response handler fired");
} }
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
log_info("No from attribute"); log_info("No from attribute");
free(jid); free(jid);
@ -821,7 +821,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd
static int static int
_caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
char *expected_node = (char *)userdata; char *expected_node = (char *)userdata;
@ -838,7 +838,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda
log_info("Capabilities response handler fired"); log_info("Capabilities response handler fired");
} }
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
log_info("No from attribute"); log_info("No from attribute");
free(expected_node); free(expected_node);
@ -925,7 +925,7 @@ _disable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
static int static int
_manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
GDateTime *sent = (GDateTime *)userdata; GDateTime *sent = (GDateTime *)userdata;
@ -1053,7 +1053,7 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
} }
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (g_strcmp0(type, STANZA_TYPE_RESULT) != 0) { if (g_strcmp0(type, STANZA_TYPE_RESULT) != 0) {
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
@ -1068,7 +1068,7 @@ _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
return 0; return 0;
} }
const char *jid = xmpp_stanza_get_attribute(stanza, "from"); const char *jid = xmpp_stanza_get_from(stanza);
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
if (query == NULL) { if (query == NULL) {
@ -1144,9 +1144,9 @@ static void
_ping_get_handler(xmpp_stanza_t *const stanza) _ping_get_handler(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *to = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TO); const char *to = xmpp_stanza_get_to(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (id) { if (id) {
log_debug("IQ ping get handler fired, id: %s.", id); log_debug("IQ ping get handler fired, id: %s.", id);
@ -1158,15 +1158,9 @@ _ping_get_handler(xmpp_stanza_t *const stanza)
return; return;
} }
xmpp_stanza_t *pong = xmpp_stanza_new(ctx); xmpp_stanza_t *pong = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id);
xmpp_stanza_set_name(pong, STANZA_NAME_IQ); xmpp_stanza_set_to(pong, from);
xmpp_stanza_set_attribute(pong, STANZA_ATTR_TO, from); xmpp_stanza_set_from(pong, to);
xmpp_stanza_set_attribute(pong, STANZA_ATTR_FROM, to);
xmpp_stanza_set_attribute(pong, STANZA_ATTR_TYPE, STANZA_TYPE_RESULT);
if (id) {
xmpp_stanza_set_attribute(pong, STANZA_ATTR_ID, id);
}
iq_send_stanza(pong); iq_send_stanza(pong);
xmpp_stanza_release(pong); xmpp_stanza_release(pong);
@ -1176,8 +1170,8 @@ static void
_version_get_handler(xmpp_stanza_t *const stanza) _version_get_handler(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (id) { if (id) {
log_debug("IQ version get handler fired, id: %s.", id); log_debug("IQ version get handler fired, id: %s.", id);
@ -1186,13 +1180,8 @@ _version_get_handler(xmpp_stanza_t *const stanza)
} }
if (from) { if (from) {
xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id);
xmpp_stanza_set_name(response, STANZA_NAME_IQ); xmpp_stanza_set_to(response, from);
if (id) {
xmpp_stanza_set_id(response, id);
}
xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);
xmpp_stanza_set_type(response, STANZA_TYPE_RESULT);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -1241,8 +1230,8 @@ static void
_disco_items_get_handler(xmpp_stanza_t *const stanza) _disco_items_get_handler(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (id) { if (id) {
log_debug("IQ disco items get handler fired, id: %s.", id); log_debug("IQ disco items get handler fired, id: %s.", id);
@ -1251,11 +1240,9 @@ _disco_items_get_handler(xmpp_stanza_t *const stanza)
} }
if (from) { if (from) {
xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_name(response, STANZA_NAME_IQ); xmpp_stanza_set_to(response, from);
xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);
xmpp_stanza_set_type(response, STANZA_TYPE_RESULT);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS); xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS);
@ -1271,7 +1258,7 @@ static void
_last_activity_get_handler(xmpp_stanza_t *const stanza) _last_activity_get_handler(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
return; return;
@ -1282,11 +1269,8 @@ _last_activity_get_handler(xmpp_stanza_t *const stanza)
char str[50]; char str[50];
sprintf(str, "%d", idls_secs); sprintf(str, "%d", idls_secs);
xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_name(response, STANZA_NAME_IQ); xmpp_stanza_set_to(response, from);
xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);
xmpp_stanza_set_type(response, STANZA_TYPE_RESULT);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -1300,11 +1284,8 @@ _last_activity_get_handler(xmpp_stanza_t *const stanza)
xmpp_stanza_release(response); xmpp_stanza_release(response);
} else { } else {
xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_ERROR, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_name(response, STANZA_NAME_IQ); xmpp_stanza_set_to(response, from);
xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);
xmpp_stanza_set_type(response, STANZA_TYPE_ERROR);
xmpp_stanza_t *error = xmpp_stanza_new(ctx); xmpp_stanza_t *error = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(error, STANZA_NAME_ERROR); xmpp_stanza_set_name(error, STANZA_NAME_ERROR);
@ -1330,12 +1311,12 @@ static void
_disco_info_get_handler(xmpp_stanza_t *const stanza) _disco_info_get_handler(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
xmpp_stanza_t *incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); xmpp_stanza_t *incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
const char *node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE); const char *node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE);
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
if (id) { if (id) {
log_debug("IQ disco info get handler fired, id: %s.", id); log_debug("IQ disco info get handler fired, id: %s.", id);
@ -1344,11 +1325,9 @@ _disco_info_get_handler(xmpp_stanza_t *const stanza)
} }
if (from) { if (from) {
xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_name(response, STANZA_NAME_IQ); xmpp_stanza_set_to(response, from);
xmpp_stanza_set_id(response, xmpp_stanza_get_id(stanza));
xmpp_stanza_set_attribute(response, STANZA_ATTR_TO, from);
xmpp_stanza_set_type(response, STANZA_TYPE_RESULT);
xmpp_stanza_t *query = stanza_create_caps_query_element(ctx); xmpp_stanza_t *query = stanza_create_caps_query_element(ctx);
if (node_str) { if (node_str) {
xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node_str); xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node_str);
@ -1364,7 +1343,7 @@ _disco_info_get_handler(xmpp_stanza_t *const stanza)
static int static int
_destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
if (id) { if (id) {
log_debug("IQ destroy room result handler fired, id: %s.", id); log_debug("IQ destroy room result handler fired, id: %s.", id);
@ -1372,7 +1351,7 @@ _destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdat
log_debug("IQ destroy room result handler fired."); log_debug("IQ destroy room result handler fired.");
} }
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (from == NULL) { if (from == NULL) {
log_error("No from attribute for IQ destroy room result"); log_error("No from attribute for IQ destroy room result");
} else { } else {
@ -1385,9 +1364,9 @@ _destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdat
static int static int
_room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (id) { if (id) {
log_debug("IQ room config handler fired, id: %s.", id); log_debug("IQ room config handler fired, id: %s.", id);
@ -1423,7 +1402,7 @@ _room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
return 0; return 0;
} }
const char *form_type = xmpp_stanza_get_attribute(x, STANZA_ATTR_TYPE); const char *form_type = xmpp_stanza_get_type(x);
if (g_strcmp0(form_type, "form") != 0) { if (g_strcmp0(form_type, "form") != 0) {
log_warning("x element not of type 'form' parsing room config response"); log_warning("x element not of type 'form' parsing room config response");
ui_handle_room_configuration_form_error(from, "Form not of type 'form' parsing room config response."); ui_handle_room_configuration_form_error(from, "Form not of type 'form' parsing room config response.");
@ -1440,9 +1419,9 @@ _room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
static int static int
_room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
ProfPrivilegeSet *affiliation_set = (ProfPrivilegeSet*)userdata; ProfPrivilegeSet *affiliation_set = (ProfPrivilegeSet*)userdata;
if (id) { if (id) {
@ -1472,9 +1451,9 @@ _room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const
static int static int
_room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
ProfPrivilegeSet *role_set = (ProfPrivilegeSet*)userdata; ProfPrivilegeSet *role_set = (ProfPrivilegeSet*)userdata;
if (id) { if (id) {
@ -1504,9 +1483,9 @@ _room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userda
static int static int
_room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
char *affiliation = (char *)userdata; char *affiliation = (char *)userdata;
if (id) { if (id) {
@ -1558,9 +1537,9 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *cons
static int static int
_room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
char *role = (char *)userdata; char *role = (char *)userdata;
if (id) { if (id) {
@ -1611,9 +1590,9 @@ _room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userd
static int static int
_room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (id) { if (id) {
log_debug("IQ room config submit handler fired, id: %s.", id); log_debug("IQ room config submit handler fired, id: %s.", id);
@ -1637,9 +1616,9 @@ _room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata
static int static int
_room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
char *nick = (char *)userdata; char *nick = (char *)userdata;
if (id) { if (id) {
@ -1717,7 +1696,7 @@ _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata
} }
} else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) { } else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) {
const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
const char *type = xmpp_stanza_get_attribute(child, STANZA_ATTR_TYPE); const char *type = xmpp_stanza_get_type(child);
const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY); const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
if (name || category || type) { if (name || category || type) {
@ -1765,7 +1744,7 @@ _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata
static int static int
_last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
cons_show_error("Invalid last activity response received."); cons_show_error("Invalid last activity response received.");
log_info("Received last activity response with no from attribute."); log_info("Received last activity response with no from attribute.");
@ -1819,7 +1798,7 @@ _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const user
static int static int
_disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
if (from) { if (from) {
@ -1855,7 +1834,7 @@ _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdat
} }
} else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) { } else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) {
const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME); const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
const char *type = xmpp_stanza_get_attribute(child, STANZA_ATTR_TYPE); const char *type = xmpp_stanza_get_type(child);
const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY); const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
if (name || category || type) { if (name || category || type) {
@ -1896,7 +1875,7 @@ _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdat
static int static int
_disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *const userdata) _disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *const userdata)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
if (from) { if (from) {
@ -1946,7 +1925,7 @@ static int
_http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) _http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{ {
HTTPUpload *upload = (HTTPUpload *)userdata; HTTPUpload *upload = (HTTPUpload *)userdata;
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
const char *type = xmpp_stanza_get_type(stanza); const char *type = xmpp_stanza_get_type(stanza);
if (from) { if (from) {
@ -2000,8 +1979,8 @@ static void
_disco_items_result_handler(xmpp_stanza_t *const stanza) _disco_items_result_handler(xmpp_stanza_t *const stanza)
{ {
log_debug("Received disco#items response"); log_debug("Received disco#items response");
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
GSList *items = NULL; GSList *items = NULL;
if ((g_strcmp0(id, "confreq") != 0) && if ((g_strcmp0(id, "confreq") != 0) &&

View File

@ -141,7 +141,8 @@ message_send_chat(const char *const barejid, const char *const msg, const char *
char *jid = chat_session_get_jid(barejid); char *jid = chat_session_get_jid(barejid);
char *id = create_unique_id("msg"); char *id = create_unique_id("msg");
xmpp_stanza_t *message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, msg);
free(jid); free(jid);
if (state) { if (state) {
@ -179,7 +180,8 @@ message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean
Jid *jidp = jid_create(jid); Jid *jidp = jid_create(jid);
char *encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid); char *encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid);
if (encrypted) { if (encrypted) {
message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, "This message is encrypted."); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, "This message is encrypted.");
xmpp_stanza_t *x = xmpp_stanza_new(ctx); xmpp_stanza_t *x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_name(x, STANZA_NAME_X);
xmpp_stanza_set_ns(x, STANZA_NS_ENCRYPTED); xmpp_stanza_set_ns(x, STANZA_NS_ENCRYPTED);
@ -191,15 +193,18 @@ message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean
xmpp_stanza_release(x); xmpp_stanza_release(x);
free(encrypted); free(encrypted);
} else { } else {
message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, msg);
} }
jid_destroy(jidp); jid_destroy(jidp);
} else { } else {
message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, msg);
} }
account_free(account); account_free(account);
#else #else
message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
xmpp_message_set_body(message, msg);
#endif #endif
free(jid); free(jid);
@ -226,7 +231,9 @@ message_send_chat_otr(const char *const barejid, const char *const msg, gboolean
char *jid = chat_session_get_jid(barejid); char *jid = chat_session_get_jid(barejid);
char *id = create_unique_id("msg"); char *id = create_unique_id("msg");
xmpp_stanza_t *message = stanza_create_message(ctx, id, barejid, STANZA_TYPE_CHAT, msg); xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id);
xmpp_message_set_body(message, msg);
free(jid); free(jid);
if (state) { if (state) {
@ -252,7 +259,10 @@ message_send_private(const char *const fulljid, const char *const msg, const cha
{ {
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
char *id = create_unique_id("prv"); char *id = create_unique_id("prv");
xmpp_stanza_t *message = stanza_create_message(ctx, id, fulljid, STANZA_TYPE_CHAT, msg);
xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
xmpp_message_set_body(message, msg);
free(id); free(id);
if (oob_url) { if (oob_url) {
@ -268,7 +278,10 @@ message_send_groupchat(const char *const roomjid, const char *const msg, const c
{ {
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
char *id = create_unique_id("muc"); char *id = create_unique_id("muc");
xmpp_stanza_t *message = stanza_create_message(ctx, id, roomjid, STANZA_TYPE_GROUPCHAT, msg);
xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, roomjid, id);
xmpp_message_set_body(message, msg);
free(id); free(id);
if (oob_url) { if (oob_url) {
@ -353,11 +366,11 @@ static void
_handle_error(xmpp_stanza_t *const stanza) _handle_error(xmpp_stanza_t *const stanza)
{ {
const char *id = xmpp_stanza_get_id(stanza); const char *id = xmpp_stanza_get_id(stanza);
const char *jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *jid = xmpp_stanza_get_from(stanza);
xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
const char *type = NULL; const char *type = NULL;
if (error_stanza) { if (error_stanza) {
type = xmpp_stanza_get_attribute(error_stanza, STANZA_ATTR_TYPE); type = xmpp_stanza_get_type(error_stanza);
} }
// stanza_get_error never returns NULL // stanza_get_error never returns NULL
@ -402,7 +415,7 @@ _handel_muc_user(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
const char *room = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *room = xmpp_stanza_get_from(stanza);
if (!room) { if (!room) {
log_warning("Message received with no from attribute, ignoring"); log_warning("Message received with no from attribute, ignoring");
@ -415,7 +428,7 @@ _handel_muc_user(xmpp_stanza_t *const stanza)
return; return;
} }
const char *invitor_jid = xmpp_stanza_get_attribute(invite, STANZA_ATTR_FROM); const char *invitor_jid = xmpp_stanza_get_from(invite);
if (!invitor_jid) { if (!invitor_jid) {
log_warning("Chat room invite received with no from attribute"); log_warning("Chat room invite received with no from attribute");
return; return;
@ -454,7 +467,7 @@ _handle_conference(xmpp_stanza_t *const stanza)
{ {
xmpp_stanza_t *xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); xmpp_stanza_t *xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
log_warning("Message received with no from attribute, ignoring"); log_warning("Message received with no from attribute, ignoring");
return; return;
@ -483,7 +496,7 @@ static void
_handle_captcha(xmpp_stanza_t *const stanza) _handle_captcha(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
log_warning("Message received with no from attribute, ignoring"); log_warning("Message received with no from attribute, ignoring");
@ -491,12 +504,7 @@ _handle_captcha(xmpp_stanza_t *const stanza)
} }
// XEP-0158 // XEP-0158
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); char *message = xmpp_message_get_body(stanza);
if (!body) {
return;
}
char *message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
return; return;
} }
@ -510,7 +518,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
{ {
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
char *message = NULL; char *message = NULL;
const char *room_jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *room_jid = xmpp_stanza_get_from(stanza);
Jid *jid = jid_create(room_jid); Jid *jid = jid_create(room_jid);
// handle room subject // handle room subject
@ -526,13 +534,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
// handle room broadcasts // handle room broadcasts
if (!jid->resourcepart) { if (!jid->resourcepart) {
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); message = xmpp_message_get_body(stanza);
if (!body) {
jid_destroy(jid);
return;
}
message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
jid_destroy(jid); jid_destroy(jid);
return; return;
@ -558,15 +560,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
return; return;
} }
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); message = xmpp_message_get_body(stanza);
// check for and deal with message
if (!body) {
jid_destroy(jid);
return;
}
message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
jid_destroy(jid); jid_destroy(jid);
return; return;
@ -589,17 +583,15 @@ void
_message_send_receipt(const char *const fulljid, const char *const message_id) _message_send_receipt(const char *const fulljid, const char *const message_id)
{ {
xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_ctx_t * const ctx = connection_get_ctx();
xmpp_stanza_t *message = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE);
char *id = create_unique_id("receipt"); char *id = create_unique_id("receipt");
xmpp_stanza_set_id(message, id); xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, fulljid, id);
free(id); free(id);
xmpp_stanza_set_attribute(message, STANZA_ATTR_TO, fulljid);
xmpp_stanza_t *receipt = xmpp_stanza_new(ctx); xmpp_stanza_t *receipt = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(receipt, "received"); xmpp_stanza_set_name(receipt, "received");
xmpp_stanza_set_ns(receipt, STANZA_NS_RECEIPTS); xmpp_stanza_set_ns(receipt, STANZA_NS_RECEIPTS);
xmpp_stanza_set_attribute(receipt, STANZA_ATTR_ID, message_id); xmpp_stanza_set_id(receipt, message_id);
xmpp_stanza_add_child(message, receipt); xmpp_stanza_add_child(message, receipt);
xmpp_stanza_release(receipt); xmpp_stanza_release(receipt);
@ -617,12 +609,12 @@ _handle_receipt_received(xmpp_stanza_t *const stanza)
return; return;
} }
const char *id = xmpp_stanza_get_attribute(receipt, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(receipt);
if (!id) { if (!id) {
return; return;
} }
const char *fulljid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *fulljid = xmpp_stanza_get_from(stanza);
if (!fulljid) { if (!fulljid) {
return; return;
} }
@ -654,7 +646,7 @@ _receipt_request_handler(xmpp_stanza_t *const stanza)
return; return;
} }
const gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const gchar *from = xmpp_stanza_get_from(stanza);
Jid *jid = jid_create(from); Jid *jid = jid_create(from);
_message_send_receipt(jid->fulljid, id); _message_send_receipt(jid->fulljid, id);
jid_destroy(jid); jid_destroy(jid);
@ -663,12 +655,7 @@ _receipt_request_handler(xmpp_stanza_t *const stanza)
void void
_private_chat_handler(xmpp_stanza_t *const stanza, const char *const fulljid) _private_chat_handler(xmpp_stanza_t *const stanza, const char *const fulljid)
{ {
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); char *message = xmpp_message_get_body(stanza);
if (!body) {
return;
}
char *message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
return; return;
} }
@ -700,8 +687,8 @@ _handle_carbons(xmpp_stanza_t *const stanza)
xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_ctx_t *ctx = connection_get_ctx();
const gchar *to = xmpp_stanza_get_attribute(message, STANZA_ATTR_TO); const gchar *to = xmpp_stanza_get_to(message);
const gchar *from = xmpp_stanza_get_attribute(message, STANZA_ATTR_FROM); const gchar *from = xmpp_stanza_get_from(message);
// happens when receive a carbon of a self sent message // happens when receive a carbon of a self sent message
if (!to) to = from; if (!to) to = from;
@ -711,28 +698,25 @@ _handle_carbons(xmpp_stanza_t *const stanza)
Jid *my_jid = jid_create(connection_get_fulljid()); Jid *my_jid = jid_create(connection_get_fulljid());
// check for and deal with message // check for and deal with message
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY); char *message_txt = xmpp_message_get_body(message);
if (body) { if (message_txt) {
char *message_txt = xmpp_stanza_get_text(body); // check for pgp encrypted message
if (message_txt) { char *enc_message = NULL;
// check for pgp encrypted message xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED);
char *enc_message = NULL; if (x) {
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED); enc_message = xmpp_stanza_get_text(x);
if (x) {
enc_message = xmpp_stanza_get_text(x);
}
// if we are the recipient, treat as standard incoming message
if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){
sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message_txt, enc_message);
// else treat as a sent message
} else {
sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);
}
xmpp_free(ctx, message_txt);
xmpp_free(ctx, enc_message);
} }
// if we are the recipient, treat as standard incoming message
if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){
sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message_txt, enc_message);
// else treat as a sent message
} else {
sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);
}
xmpp_free(ctx, message_txt);
xmpp_free(ctx, enc_message);
} }
jid_destroy(jid_from); jid_destroy(jid_from);
@ -776,7 +760,7 @@ _handle_chat(xmpp_stanza_t *const stanza)
return; return;
} }
const gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const gchar *from = xmpp_stanza_get_from(stanza);
Jid *jid = jid_create(from); Jid *jid = jid_create(from);
// private message from chat room use full jid (room/nick) // private message from chat room use full jid (room/nick)

View File

@ -172,12 +172,11 @@ presence_subscription(const char *const jid, const jabber_subscr_t action)
break; break;
} }
xmpp_stanza_t *presence = xmpp_stanza_new(ctx); xmpp_stanza_t *presence = xmpp_presence_new(ctx);
char *id = create_unique_id("sub"); char *id = create_unique_id("sub");
xmpp_stanza_set_id(presence, id); xmpp_stanza_set_id(presence, id);
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
xmpp_stanza_set_type(presence, type); xmpp_stanza_set_type(presence, type);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, jidp->barejid); xmpp_stanza_set_to(presence, jidp->barejid);
_send_presence_stanza(presence); _send_presence_stanza(presence);
xmpp_stanza_release(presence); xmpp_stanza_release(presence);
@ -258,7 +257,7 @@ presence_send(const resource_presence_t presence_type, const char *const msg, co
connection_set_presence_msg(msg); connection_set_presence_msg(msg);
connection_set_priority(pri); connection_set_priority(pri);
xmpp_stanza_t *presence = stanza_create_presence(ctx); xmpp_stanza_t *presence = xmpp_presence_new(ctx);
char *id = create_unique_id("presence"); char *id = create_unique_id("presence");
xmpp_stanza_set_id(presence, id); xmpp_stanza_set_id(presence, id);
stanza_attach_show(ctx, presence, show); stanza_attach_show(ctx, presence, show);
@ -310,7 +309,7 @@ _send_room_presence(xmpp_stanza_t *presence)
if (nick) { if (nick) {
char *full_room_jid = create_fulljid(room, nick); char *full_room_jid = create_fulljid(room, nick);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid); xmpp_stanza_set_to(presence, full_room_jid);
log_debug("Sending presence to room: %s", full_room_jid); log_debug("Sending presence to room: %s", full_room_jid);
_send_presence_stanza(presence); _send_presence_stanza(presence);
free(full_room_jid); free(full_room_jid);
@ -397,7 +396,7 @@ static void
_presence_error_handler(xmpp_stanza_t *const stanza) _presence_error_handler(xmpp_stanza_t *const stanza)
{ {
const char *id = xmpp_stanza_get_id(stanza); const char *id = xmpp_stanza_get_id(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR); xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X); xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
const char *xmlns = NULL; const char *xmlns = NULL;
@ -406,7 +405,7 @@ _presence_error_handler(xmpp_stanza_t *const stanza)
} }
const char *type = NULL; const char *type = NULL;
if (error_stanza) { if (error_stanza) {
type = xmpp_stanza_get_attribute(error_stanza, STANZA_ATTR_TYPE); type = xmpp_stanza_get_type(error_stanza);
} }
// handle MUC join errors // handle MUC join errors
@ -467,7 +466,7 @@ _presence_error_handler(xmpp_stanza_t *const stanza)
static void static void
_unsubscribed_handler(xmpp_stanza_t *const stanza) _unsubscribed_handler(xmpp_stanza_t *const stanza)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
Jid *from_jid = jid_create(from); Jid *from_jid = jid_create(from);
log_debug("Unsubscribed presence handler fired for %s", from); log_debug("Unsubscribed presence handler fired for %s", from);
@ -480,7 +479,7 @@ _unsubscribed_handler(xmpp_stanza_t *const stanza)
static void static void
_subscribed_handler(xmpp_stanza_t *const stanza) _subscribed_handler(xmpp_stanza_t *const stanza)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
Jid *from_jid = jid_create(from); Jid *from_jid = jid_create(from);
log_debug("Subscribed presence handler fired for %s", from); log_debug("Subscribed presence handler fired for %s", from);
@ -493,7 +492,7 @@ _subscribed_handler(xmpp_stanza_t *const stanza)
static void static void
_subscribe_handler(xmpp_stanza_t *const stanza) _subscribe_handler(xmpp_stanza_t *const stanza)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
log_debug("Subscribe presence handler fired for %s", from); log_debug("Subscribe presence handler fired for %s", from);
Jid *from_jid = jid_create(from); Jid *from_jid = jid_create(from);
@ -514,7 +513,7 @@ _unavailable_handler(xmpp_stanza_t *const stanza)
xmpp_conn_t *conn = connection_get_conn(); xmpp_conn_t *conn = connection_get_conn();
const char *jid = xmpp_conn_get_jid(conn); const char *jid = xmpp_conn_get_jid(conn);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
log_debug("Unavailable presence handler fired for %s", from); log_debug("Unavailable presence handler fired for %s", from);
Jid *my_jid = jid_create(jid); Jid *my_jid = jid_create(jid);
@ -615,7 +614,7 @@ _available_handler(xmpp_stanza_t *const stanza)
log_warning("Available presence handler fired with no from attribute."); log_warning("Available presence handler fired with no from attribute.");
break; break;
case STANZA_PARSE_ERROR_INVALID_FROM: case STANZA_PARSE_ERROR_INVALID_FROM:
from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); from = xmpp_stanza_get_from(stanza);
log_warning("Available presence handler fired with invalid from attribute: %s", from); log_warning("Available presence handler fired with invalid from attribute: %s", from);
break; break;
default: default:
@ -684,8 +683,8 @@ _muc_user_handler(xmpp_stanza_t *const stanza)
{ {
inp_nonblocking(TRUE); inp_nonblocking(TRUE);
const char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
// handler still fires if error // handler still fires if error
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {

View File

@ -218,7 +218,7 @@ roster_set_handler(xmpp_stanza_t *const stanza)
// if from attribute exists and it is not current users barejid, ignore push // if from attribute exists and it is not current users barejid, ignore push
Jid *my_jid = jid_create(connection_get_fulljid()); Jid *my_jid = jid_create(connection_get_fulljid());
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (from && (strcmp(from, my_jid->barejid) != 0)) { if (from && (strcmp(from, my_jid->barejid) != 0)) {
jid_destroy(my_jid); jid_destroy(my_jid);
return; return;
@ -276,7 +276,7 @@ roster_set_handler(xmpp_stanza_t *const stanza)
void void
roster_result_handler(xmpp_stanza_t *const stanza) roster_result_handler(xmpp_stanza_t *const stanza)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_id(stanza);
if (g_strcmp0(id, "roster") != 0) { if (g_strcmp0(id, "roster") != 0) {
return; return;

View File

@ -72,9 +72,7 @@ static char* _stanza_text_to_str(xmpp_stanza_t *stanza);
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_bookmarks_pubsub_request(xmpp_ctx_t *ctx) stanza_create_bookmarks_pubsub_request(xmpp_ctx_t *ctx)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
@ -96,9 +94,7 @@ stanza_create_bookmarks_pubsub_request(xmpp_ctx_t *ctx)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx) stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_set_ns(iq, "jabber:client"); xmpp_stanza_set_ns(iq, "jabber:client");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
@ -120,9 +116,7 @@ stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_blocked_list_request(xmpp_ctx_t *ctx) stanza_create_blocked_list_request(xmpp_ctx_t *ctx)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_t *blocklist = xmpp_stanza_new(ctx); xmpp_stanza_t *blocklist = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(blocklist, STANZA_NAME_BLOCKLIST); xmpp_stanza_set_name(blocklist, STANZA_NAME_BLOCKLIST);
@ -139,10 +133,9 @@ xmpp_stanza_t*
stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid, stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid,
const gboolean autojoin, const char *const nick) const gboolean autojoin, const char *const nick)
{ {
xmpp_stanza_t *stanza = xmpp_stanza_new(ctx); char *id = create_unique_id("bookmark_add");
xmpp_stanza_set_name(stanza, STANZA_NAME_IQ); xmpp_stanza_t *stanza = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
_stanza_add_unique_id(stanza, "bookmark_add"); free(id);
xmpp_stanza_set_type(stanza, STANZA_TYPE_SET);
xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB); xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
@ -185,13 +178,13 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid,
xmpp_stanza_t *x = xmpp_stanza_new(ctx); xmpp_stanza_t *x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_name(x, STANZA_NAME_X);
xmpp_stanza_set_ns(x, STANZA_NS_DATA); xmpp_stanza_set_ns(x, STANZA_NS_DATA);
xmpp_stanza_set_attribute(x, STANZA_ATTR_TYPE, "submit"); xmpp_stanza_set_type(x, "submit");
xmpp_stanza_add_child(publish_options, x); xmpp_stanza_add_child(publish_options, x);
xmpp_stanza_t *form_type = xmpp_stanza_new(ctx); xmpp_stanza_t *form_type = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(form_type, STANZA_NAME_FIELD); xmpp_stanza_set_name(form_type, STANZA_NAME_FIELD);
xmpp_stanza_set_attribute(form_type, STANZA_ATTR_VAR, "FORM_TYPE"); xmpp_stanza_set_attribute(form_type, STANZA_ATTR_VAR, "FORM_TYPE");
xmpp_stanza_set_attribute(form_type, STANZA_ATTR_TYPE, "hidden"); xmpp_stanza_set_type(form_type, "hidden");
xmpp_stanza_t *form_type_value = xmpp_stanza_new(ctx); xmpp_stanza_t *form_type_value = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(form_type_value, STANZA_NAME_VALUE); xmpp_stanza_set_name(form_type_value, STANZA_NAME_VALUE);
xmpp_stanza_t *form_type_value_text = xmpp_stanza_new(ctx); xmpp_stanza_t *form_type_value_text = xmpp_stanza_new(ctx);
@ -230,11 +223,8 @@ xmpp_stanza_t*
stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id, stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id,
const char *const jid, HTTPUpload *upload) const char *const jid, HTTPUpload *upload)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_set_to(iq, jid);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, jid);
xmpp_stanza_set_id(iq, id);
xmpp_stanza_t *request = xmpp_stanza_new(ctx); xmpp_stanza_t *request = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(request, STANZA_NAME_REQUEST); xmpp_stanza_set_name(request, STANZA_NAME_REQUEST);
@ -283,10 +273,9 @@ stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id,
xmpp_stanza_t* xmpp_stanza_t*
stanza_enable_carbons(xmpp_ctx_t *ctx) stanza_enable_carbons(xmpp_ctx_t *ctx)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("carbons");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
_stanza_add_unique_id(iq, "carbons");
xmpp_stanza_t *carbons_enable = xmpp_stanza_new(ctx); xmpp_stanza_t *carbons_enable = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE); xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE);
@ -301,10 +290,9 @@ stanza_enable_carbons(xmpp_ctx_t *ctx)
xmpp_stanza_t* xmpp_stanza_t*
stanza_disable_carbons(xmpp_ctx_t *ctx) stanza_disable_carbons(xmpp_ctx_t *ctx)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("carbons");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
_stanza_add_unique_id(iq, "carbons");
xmpp_stanza_t *carbons_disable = xmpp_stanza_new(ctx); xmpp_stanza_t *carbons_disable = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE); xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE);
@ -319,12 +307,9 @@ stanza_disable_carbons(xmpp_ctx_t *ctx)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char *const state) stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char *const state)
{ {
xmpp_stanza_t *msg = xmpp_stanza_new(ctx); char *id = create_unique_id(NULL);
xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE); xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
xmpp_stanza_set_type(msg, STANZA_TYPE_CHAT); free(id);
xmpp_stanza_set_attribute(msg, STANZA_ATTR_TO, fulljid);
_stanza_add_unique_id(msg, NULL);
xmpp_stanza_t *chat_state = xmpp_stanza_new(ctx); xmpp_stanza_t *chat_state = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(chat_state, state); xmpp_stanza_set_name(chat_state, state);
@ -338,10 +323,7 @@ stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, const char *const subject) stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, const char *const subject)
{ {
xmpp_stanza_t *msg = xmpp_stanza_new(ctx); xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, room, NULL);
xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE);
xmpp_stanza_set_type(msg, STANZA_TYPE_GROUPCHAT);
xmpp_stanza_set_attribute(msg, STANZA_ATTR_TO, room);
xmpp_stanza_t *subject_st = xmpp_stanza_new(ctx); xmpp_stanza_t *subject_st = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(subject_st, STANZA_NAME_SUBJECT); xmpp_stanza_set_name(subject_st, STANZA_NAME_SUBJECT);
@ -442,36 +424,12 @@ stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *cons
return stanza; return stanza;
} }
xmpp_stanza_t*
stanza_create_message(xmpp_ctx_t *ctx, char *id, const char *const recipient,
const char *const type, const char *const message)
{
xmpp_stanza_t *msg = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE);
xmpp_stanza_set_type(msg, type);
xmpp_stanza_set_attribute(msg, STANZA_ATTR_TO, recipient);
xmpp_stanza_set_id(msg, id);
xmpp_stanza_t *body = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(body, STANZA_NAME_BODY);
xmpp_stanza_t *text = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(text, message);
xmpp_stanza_add_child(body, text);
xmpp_stanza_release(text);
xmpp_stanza_add_child(msg, body);
xmpp_stanza_release(body);
return msg;
}
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid) stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("roster");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
_stanza_add_unique_id(iq, "roster");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -495,12 +453,7 @@ xmpp_stanza_t*
stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id, stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id,
const char *const jid, const char *const handle, GSList *groups) const char *const jid, const char *const handle, GSList *groups)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
if (id) {
xmpp_stanza_set_id(iq, id);
}
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -540,10 +493,9 @@ xmpp_stanza_t*
stanza_create_invite(xmpp_ctx_t *ctx, const char *const room, stanza_create_invite(xmpp_ctx_t *ctx, const char *const room,
const char *const contact, const char *const reason, const char *const password) const char *const contact, const char *const reason, const char *const password)
{ {
xmpp_stanza_t *message = xmpp_stanza_new(ctx); char *id = create_unique_id(NULL);
xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE); xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, contact, id);
xmpp_stanza_set_attribute(message, STANZA_ATTR_TO, contact); free(id);
_stanza_add_unique_id(message, NULL);
xmpp_stanza_t *x = xmpp_stanza_new(ctx); xmpp_stanza_t *x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_name(x, STANZA_NAME_X);
@ -567,10 +519,9 @@ xmpp_stanza_t*
stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room, stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room,
const char *const contact, const char *const reason) const char *const contact, const char *const reason)
{ {
xmpp_stanza_t *message = xmpp_stanza_new(ctx); char *id = create_unique_id(NULL);
xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE); xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, room, id);
xmpp_stanza_set_attribute(message, STANZA_ATTR_TO, room); free(id);
_stanza_add_unique_id(message, NULL);
xmpp_stanza_t *x = xmpp_stanza_new(ctx); xmpp_stanza_t *x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_name(x, STANZA_NAME_X);
@ -578,7 +529,7 @@ stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room,
xmpp_stanza_t *invite = xmpp_stanza_new(ctx); xmpp_stanza_t *invite = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(invite, STANZA_NAME_INVITE); xmpp_stanza_set_name(invite, STANZA_NAME_INVITE);
xmpp_stanza_set_attribute(invite, STANZA_ATTR_TO, contact); xmpp_stanza_set_to(invite, contact);
if (reason) { if (reason) {
xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx); xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
@ -603,9 +554,8 @@ xmpp_stanza_t*
stanza_create_room_join_presence(xmpp_ctx_t *const ctx, stanza_create_room_join_presence(xmpp_ctx_t *const ctx,
const char *const full_room_jid, const char *const passwd) const char *const full_room_jid, const char *const passwd)
{ {
xmpp_stanza_t *presence = xmpp_stanza_new(ctx); xmpp_stanza_t *presence = xmpp_presence_new(ctx);
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); xmpp_stanza_set_to(presence, full_room_jid);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid);
_stanza_add_unique_id(presence, "join"); _stanza_add_unique_id(presence, "join");
xmpp_stanza_t *x = xmpp_stanza_new(ctx); xmpp_stanza_t *x = xmpp_stanza_new(ctx);
@ -633,10 +583,9 @@ xmpp_stanza_t*
stanza_create_room_newnick_presence(xmpp_ctx_t *ctx, stanza_create_room_newnick_presence(xmpp_ctx_t *ctx,
const char *const full_room_jid) const char *const full_room_jid)
{ {
xmpp_stanza_t *presence = xmpp_stanza_new(ctx); xmpp_stanza_t *presence = xmpp_presence_new(ctx);
_stanza_add_unique_id(presence, "sub"); _stanza_add_unique_id(presence, "sub");
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); xmpp_stanza_set_to(presence, full_room_jid);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid);
return presence; return presence;
} }
@ -649,10 +598,9 @@ stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room,
g_string_append(full_jid, "/"); g_string_append(full_jid, "/");
g_string_append(full_jid, nick); g_string_append(full_jid, nick);
xmpp_stanza_t *presence = xmpp_stanza_new(ctx); xmpp_stanza_t *presence = xmpp_presence_new(ctx);
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
xmpp_stanza_set_type(presence, STANZA_TYPE_UNAVAILABLE); xmpp_stanza_set_type(presence, STANZA_TYPE_UNAVAILABLE);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_jid->str); xmpp_stanza_set_to(presence, full_jid->str);
_stanza_add_unique_id(presence, "leave"); _stanza_add_unique_id(presence, "leave");
g_string_free(full_jid, TRUE); g_string_free(full_jid, TRUE);
@ -663,11 +611,10 @@ stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room,
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_jid) stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_jid)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("room");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid); xmpp_stanza_set_to(iq, room_jid);
_stanza_add_unique_id(iq, "room");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -690,11 +637,10 @@ stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_ji
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_jid) stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_jid)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("room");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid); xmpp_stanza_set_to(iq, room_jid);
_stanza_add_unique_id(iq, "room");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -715,11 +661,10 @@ stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_ji
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid) stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("room");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid); xmpp_stanza_set_to(iq, room_jid);
_stanza_add_unique_id(iq, "room");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -734,11 +679,10 @@ stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid) stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("room");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid); xmpp_stanza_set_to(iq, room_jid);
_stanza_add_unique_id(iq, "room");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -761,11 +705,10 @@ stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const affiliation) stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const affiliation)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("affiliation_get");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room); xmpp_stanza_set_to(iq, room);
_stanza_add_unique_id(iq, "affiliation_get");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -786,11 +729,10 @@ stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room,
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const role) stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const role)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("role_get");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room); xmpp_stanza_set_to(iq, room);
_stanza_add_unique_id(iq, "role_get");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -812,11 +754,10 @@ xmpp_stanza_t*
stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid, stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid,
const char *const affiliation, const char *const reason) const char *const affiliation, const char *const reason)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("affiliation_set");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room); xmpp_stanza_set_to(iq, room);
_stanza_add_unique_id(iq, "affiliation_set");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -851,11 +792,10 @@ xmpp_stanza_t*
stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick, stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick,
const char *const role, const char *const reason) const char *const role, const char *const reason)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("role_set");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room); xmpp_stanza_set_to(iq, room);
_stanza_add_unique_id(iq, "role_set");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -890,11 +830,10 @@ xmpp_stanza_t*
stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick, stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick,
const char *const reason) const char *const reason)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("room_kick");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room); xmpp_stanza_set_to(iq, room);
_stanza_add_unique_id(iq, "room_kick");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -925,23 +864,13 @@ stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const
return iq; return iq;
} }
xmpp_stanza_t*
stanza_create_presence(xmpp_ctx_t *const ctx)
{
xmpp_stanza_t *presence = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
return presence;
}
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid) stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("sv");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET); free(id);
_stanza_add_unique_id(iq, "sv"); xmpp_stanza_set_to(iq, fulljid);
xmpp_stanza_set_attribute(iq, "to", fulljid);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -956,10 +885,7 @@ stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_roster_iq(xmpp_ctx_t *ctx) stanza_create_roster_iq(xmpp_ctx_t *ctx)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, "roster");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_set_id(iq, "roster");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -975,11 +901,8 @@ xmpp_stanza_t*
stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to, stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to,
const char *const node) const char *const node)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_set_to(iq, to);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, to);
xmpp_stanza_set_id(iq, id);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -998,11 +921,8 @@ xmpp_stanza_t*
stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id, stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id,
const char *const jid) const char *const jid)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_set_to(iq, jid);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, jid);
xmpp_stanza_set_id(iq, id);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -1017,11 +937,8 @@ stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id,
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to) stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_set_to(iq, to);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, to);
xmpp_stanza_set_id(iq, id);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -1036,11 +953,10 @@ stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, const char
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, DataForm *form) stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, DataForm *form)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("roomconf_submit");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_SET); free(id);
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room); xmpp_stanza_set_to(iq, room);
_stanza_add_unique_id(iq, "roomconf_submit");
xmpp_stanza_t *query = xmpp_stanza_new(ctx); xmpp_stanza_t *query = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(query, STANZA_NAME_QUERY); xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
@ -1066,7 +982,7 @@ stanza_create_caps_query_element(xmpp_ctx_t *ctx)
xmpp_stanza_t *identity = xmpp_stanza_new(ctx); xmpp_stanza_t *identity = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(identity, "identity"); xmpp_stanza_set_name(identity, "identity");
xmpp_stanza_set_attribute(identity, "category", "client"); xmpp_stanza_set_attribute(identity, "category", "client");
xmpp_stanza_set_attribute(identity, "type", "console"); xmpp_stanza_set_type(identity, "console");
GString *name_str = g_string_new("Profanity "); GString *name_str = g_string_new("Profanity ");
g_string_append(name_str, PACKAGE_VERSION); g_string_append(name_str, PACKAGE_VERSION);
@ -1114,13 +1030,12 @@ stanza_contains_chat_state(xmpp_stanza_t *stanza)
xmpp_stanza_t* xmpp_stanza_t*
stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target) stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target)
{ {
xmpp_stanza_t *iq = xmpp_stanza_new(ctx); char *id = create_unique_id("ping");
xmpp_stanza_set_name(iq, STANZA_NAME_IQ); xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
xmpp_stanza_set_type(iq, STANZA_TYPE_GET); free(id);
if (target) { if (target) {
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, target); xmpp_stanza_set_to(iq, target);
} }
_stanza_add_unique_id(iq, "ping");
xmpp_stanza_t *ping = xmpp_stanza_new(ctx); xmpp_stanza_t *ping = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(ping, STANZA_NAME_PING); xmpp_stanza_set_name(ping, STANZA_NAME_PING);
@ -1145,7 +1060,7 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query)
while (child) { while (child) {
if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_IDENTITY) == 0) { if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_IDENTITY) == 0) {
const char *category = xmpp_stanza_get_attribute(child, "category"); const char *category = xmpp_stanza_get_attribute(child, "category");
const char *type = xmpp_stanza_get_attribute(child, "type"); const char *type = xmpp_stanza_get_type(child);
const char *lang = xmpp_stanza_get_attribute(child, "xml:lang"); const char *lang = xmpp_stanza_get_attribute(child, "xml:lang");
const char *name = xmpp_stanza_get_attribute(child, "name"); const char *name = xmpp_stanza_get_attribute(child, "name");
@ -1398,7 +1313,7 @@ stanza_is_muc_self_presence(xmpp_stanza_t *const stanza,
} }
// check if 'from' attribute identifies this user // check if 'from' attribute identifies this user
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (from) { if (from) {
Jid *from_jid = jid_create(from); Jid *from_jid = jid_create(from);
if (muc_active(from_jid->barejid)) { if (muc_active(from_jid->barejid)) {
@ -1825,7 +1740,7 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query)
const char *name = NULL; const char *name = NULL;
if (found) { if (found) {
category = xmpp_stanza_get_attribute(found, "category"); category = xmpp_stanza_get_attribute(found, "category");
type = xmpp_stanza_get_attribute(found, "type"); type = xmpp_stanza_get_type(found);
name = xmpp_stanza_get_attribute(found, "name"); name = xmpp_stanza_get_attribute(found, "name");
} }
@ -2062,7 +1977,7 @@ stanza_free_presence(XMPPPresence *presence)
XMPPPresence* XMPPPresence*
stanza_parse_presence(xmpp_stanza_t *stanza, int *err) stanza_parse_presence(xmpp_stanza_t *stanza, int *err)
{ {
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); const char *from = xmpp_stanza_get_from(stanza);
if (!from) { if (!from) {
*err = STANZA_PARSE_ERROR_NO_FROM; *err = STANZA_PARSE_ERROR_NO_FROM;
return NULL; return NULL;

View File

@ -228,9 +228,6 @@ xmpp_stanza_t* stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stan
xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url); xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url);
xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx, char *id,
const char *const recipient, const char *const type, const char *const message);
xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t *const ctx, xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t *const ctx,
const char *const full_room_jid, const char *const passwd); const char *const full_room_jid, const char *const passwd);
@ -240,8 +237,6 @@ xmpp_stanza_t* stanza_create_room_newnick_presence(xmpp_ctx_t *ctx,
xmpp_stanza_t* stanza_create_room_leave_presence(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_room_leave_presence(xmpp_ctx_t *ctx,
const char *const room, const char *const nick); const char *const room, const char *const nick);
xmpp_stanza_t* stanza_create_presence(xmpp_ctx_t *const ctx);
xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t *ctx); xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t *ctx);
xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target); xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target);
xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id,