mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 10:46:20 +00:00
Show message when room requires config
This commit is contained in:
@@ -708,6 +708,11 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
// handle roster complete
|
||||
} else if (!muc_get_roster_received(from_room)) {
|
||||
handle_room_roster_complete(from_room);
|
||||
|
||||
// room configuration required
|
||||
if (stanza_muc_requires_config(stanza)) {
|
||||
handle_room_requires_config(from_room);
|
||||
}
|
||||
}
|
||||
|
||||
// handle presence from room members
|
||||
|
||||
@@ -649,6 +649,52 @@ stanza_is_muc_presence(xmpp_stanza_t * const stanza)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
stanza_muc_requires_config(xmpp_stanza_t * const stanza)
|
||||
{
|
||||
// no stanza, or not presence stanza
|
||||
if ((stanza == NULL) || (g_strcmp0(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// muc user namespaced x element
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
|
||||
if (x != NULL) {
|
||||
|
||||
// check for item element with owner affiliation
|
||||
xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, "item");
|
||||
if (item == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
char *affiliation = xmpp_stanza_get_attribute(item, "affiliation");
|
||||
if (g_strcmp0(affiliation, "owner") != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// check for status code 110 and 201
|
||||
gboolean has110 = FALSE;
|
||||
gboolean has201 = FALSE;
|
||||
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
|
||||
while (x_children != NULL) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
|
||||
char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
|
||||
if (g_strcmp0(code, "110") == 0) {
|
||||
has110 = TRUE;
|
||||
}
|
||||
if (g_strcmp0(code, "201") == 0) {
|
||||
has201 = TRUE;
|
||||
}
|
||||
}
|
||||
x_children = xmpp_stanza_get_next(x_children);
|
||||
}
|
||||
|
||||
if (has110 && has201) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
|
||||
const char * const self_jid)
|
||||
|
||||
@@ -198,6 +198,7 @@ gboolean stanza_is_muc_presence(xmpp_stanza_t * const stanza);
|
||||
gboolean stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
|
||||
const char * const self_jid);
|
||||
gboolean stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
|
||||
gboolean stanza_muc_requires_config(xmpp_stanza_t * const stanza);
|
||||
|
||||
char * stanza_get_new_nick(xmpp_stanza_t * const stanza);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user