mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 04:46:20 +00:00
Use libstrophe convenience functions for stanza attributes
This commit is contained in:
@@ -185,13 +185,13 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid,
|
||||
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(x, STANZA_NAME_X);
|
||||
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_t *form_type = xmpp_stanza_new(ctx);
|
||||
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_TYPE, "hidden");
|
||||
xmpp_stanza_set_type(form_type, "hidden");
|
||||
xmpp_stanza_t *form_type_value = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(form_type_value, STANZA_NAME_VALUE);
|
||||
xmpp_stanza_t *form_type_value_text = xmpp_stanza_new(ctx);
|
||||
@@ -233,7 +233,7 @@ stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id,
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, jid);
|
||||
xmpp_stanza_set_to(iq, jid);
|
||||
xmpp_stanza_set_id(iq, id);
|
||||
|
||||
xmpp_stanza_t *request = xmpp_stanza_new(ctx);
|
||||
@@ -322,7 +322,7 @@ stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char
|
||||
xmpp_stanza_t *msg = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE);
|
||||
xmpp_stanza_set_type(msg, STANZA_TYPE_CHAT);
|
||||
xmpp_stanza_set_attribute(msg, STANZA_ATTR_TO, fulljid);
|
||||
xmpp_stanza_set_to(msg, fulljid);
|
||||
_stanza_add_unique_id(msg, NULL);
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, cons
|
||||
xmpp_stanza_t *msg = xmpp_stanza_new(ctx);
|
||||
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_set_to(msg, room);
|
||||
|
||||
xmpp_stanza_t *subject_st = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(subject_st, STANZA_NAME_SUBJECT);
|
||||
@@ -449,7 +449,7 @@ stanza_create_message(xmpp_ctx_t *ctx, char *id, const char *const recipient,
|
||||
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_to(msg, recipient);
|
||||
xmpp_stanza_set_id(msg, id);
|
||||
|
||||
xmpp_stanza_t *body = xmpp_stanza_new(ctx);
|
||||
@@ -542,7 +542,7 @@ stanza_create_invite(xmpp_ctx_t *ctx, const char *const room,
|
||||
{
|
||||
xmpp_stanza_t *message = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE);
|
||||
xmpp_stanza_set_attribute(message, STANZA_ATTR_TO, contact);
|
||||
xmpp_stanza_set_to(message, contact);
|
||||
_stanza_add_unique_id(message, NULL);
|
||||
|
||||
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
|
||||
@@ -569,7 +569,7 @@ stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room,
|
||||
{
|
||||
xmpp_stanza_t *message = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE);
|
||||
xmpp_stanza_set_attribute(message, STANZA_ATTR_TO, room);
|
||||
xmpp_stanza_set_to(message, room);
|
||||
_stanza_add_unique_id(message, NULL);
|
||||
|
||||
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
|
||||
@@ -578,7 +578,7 @@ stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room,
|
||||
|
||||
xmpp_stanza_t *invite = xmpp_stanza_new(ctx);
|
||||
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) {
|
||||
xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
|
||||
@@ -605,7 +605,7 @@ stanza_create_room_join_presence(xmpp_ctx_t *const ctx,
|
||||
{
|
||||
xmpp_stanza_t *presence = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
|
||||
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid);
|
||||
xmpp_stanza_set_to(presence, full_room_jid);
|
||||
_stanza_add_unique_id(presence, "join");
|
||||
|
||||
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
|
||||
@@ -636,7 +636,7 @@ stanza_create_room_newnick_presence(xmpp_ctx_t *ctx,
|
||||
xmpp_stanza_t *presence = xmpp_stanza_new(ctx);
|
||||
_stanza_add_unique_id(presence, "sub");
|
||||
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
|
||||
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid);
|
||||
xmpp_stanza_set_to(presence, full_room_jid);
|
||||
|
||||
return presence;
|
||||
}
|
||||
@@ -652,7 +652,7 @@ stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room,
|
||||
xmpp_stanza_t *presence = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE);
|
||||
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");
|
||||
|
||||
g_string_free(full_jid, TRUE);
|
||||
@@ -666,7 +666,7 @@ stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_ji
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
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);
|
||||
@@ -693,7 +693,7 @@ stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_ji
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
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);
|
||||
@@ -718,7 +718,7 @@ stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
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);
|
||||
@@ -737,7 +737,7 @@ stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid)
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
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);
|
||||
@@ -764,7 +764,7 @@ stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room,
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
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);
|
||||
@@ -789,7 +789,7 @@ stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const c
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
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);
|
||||
@@ -815,7 +815,7 @@ stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, c
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
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);
|
||||
@@ -854,7 +854,7 @@ stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, co
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
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);
|
||||
@@ -893,7 +893,7 @@ stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
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);
|
||||
@@ -941,7 +941,7 @@ stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid)
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
_stanza_add_unique_id(iq, "sv");
|
||||
xmpp_stanza_set_attribute(iq, "to", fulljid);
|
||||
xmpp_stanza_set_to(iq, fulljid);
|
||||
|
||||
xmpp_stanza_t *query = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
|
||||
@@ -978,7 +978,7 @@ stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, const char *c
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, to);
|
||||
xmpp_stanza_set_to(iq, to);
|
||||
xmpp_stanza_set_id(iq, id);
|
||||
|
||||
xmpp_stanza_t *query = xmpp_stanza_new(ctx);
|
||||
@@ -1001,7 +1001,7 @@ stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id,
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, jid);
|
||||
xmpp_stanza_set_to(iq, jid);
|
||||
xmpp_stanza_set_id(iq, id);
|
||||
|
||||
xmpp_stanza_t *query = xmpp_stanza_new(ctx);
|
||||
@@ -1020,7 +1020,7 @@ stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, const char
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, to);
|
||||
xmpp_stanza_set_to(iq, to);
|
||||
xmpp_stanza_set_id(iq, id);
|
||||
|
||||
xmpp_stanza_t *query = xmpp_stanza_new(ctx);
|
||||
@@ -1039,7 +1039,7 @@ stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, Dat
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
|
||||
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);
|
||||
@@ -1066,7 +1066,7 @@ stanza_create_caps_query_element(xmpp_ctx_t *ctx)
|
||||
xmpp_stanza_t *identity = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(identity, "identity");
|
||||
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 ");
|
||||
g_string_append(name_str, PACKAGE_VERSION);
|
||||
@@ -1118,7 +1118,7 @@ stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target)
|
||||
xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
|
||||
xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
|
||||
if (target) {
|
||||
xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, target);
|
||||
xmpp_stanza_set_to(iq, target);
|
||||
}
|
||||
_stanza_add_unique_id(iq, "ping");
|
||||
|
||||
@@ -1145,7 +1145,7 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query)
|
||||
while (child) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_IDENTITY) == 0) {
|
||||
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 *name = xmpp_stanza_get_attribute(child, "name");
|
||||
|
||||
@@ -1398,7 +1398,7 @@ stanza_is_muc_self_presence(xmpp_stanza_t *const stanza,
|
||||
}
|
||||
|
||||
// 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) {
|
||||
Jid *from_jid = jid_create(from);
|
||||
if (muc_active(from_jid->barejid)) {
|
||||
@@ -1825,7 +1825,7 @@ stanza_create_caps_from_query_element(xmpp_stanza_t *query)
|
||||
const char *name = NULL;
|
||||
if (found) {
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -2062,7 +2062,7 @@ stanza_free_presence(XMPPPresence *presence)
|
||||
XMPPPresence*
|
||||
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) {
|
||||
*err = STANZA_PARSE_ERROR_NO_FROM;
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user