mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Parse data form for room configuration
This commit is contained in:
parent
763356464a
commit
5e1023dfd9
@ -463,6 +463,23 @@ handle_room_destroy(const char * const room)
|
||||
ui_room_destroyed(room);
|
||||
}
|
||||
|
||||
void
|
||||
handle_room_configure(const char * const room, DataForm *form)
|
||||
{
|
||||
cons_show("Recieved configuration form for %s", room);
|
||||
if (form->form_type != NULL) {
|
||||
cons_show("Form type: %s", form->form_type);
|
||||
} else {
|
||||
cons_show("No form type specified");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_room_configuration_form_error(void)
|
||||
{
|
||||
cons_show("Error parsing room configuration form.");
|
||||
}
|
||||
|
||||
void
|
||||
handle_room_roster_complete(const char * const room)
|
||||
{
|
||||
|
@ -95,5 +95,7 @@ void handle_presence_error(const char *from, const char * const type,
|
||||
const char *err_msg);
|
||||
void handle_xmpp_stanza(const char * const msg);
|
||||
void handle_ping_result(const char * const from, int millis);
|
||||
void handle_room_configure(const char * const room, DataForm *form);
|
||||
void handle_room_configuration_form_error(void);
|
||||
|
||||
#endif
|
||||
|
@ -592,10 +592,29 @@ _room_config_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
log_error("No from attribute for IQ destroy room result");
|
||||
} else {
|
||||
// get form
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
if (query == NULL) {
|
||||
log_error("No query element found parsing room config response");
|
||||
handle_room_configuration_form_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
|
||||
if (x == NULL) {
|
||||
log_error("No x element found with %s namespace parsing room config response", STANZA_NS_DATA);
|
||||
handle_room_configuration_form_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *type = xmpp_stanza_get_attribute(x, STANZA_ATTR_TYPE);
|
||||
if (g_strcmp0(type, "form") != 0) {
|
||||
log_error("x element not of type 'form' parsing room config response");
|
||||
handle_room_configuration_form_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// handle_room_configure(from);
|
||||
DataForm *form = stanza_create_form(x);
|
||||
handle_room_configure(from, form);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define XMPP_STANZA_H
|
||||
|
||||
#include <strophe.h>
|
||||
#include <xmpp/xmpp.h>
|
||||
|
||||
#define STANZA_NAME_ACTIVE "active"
|
||||
#define STANZA_NAME_INACTIVE "inactive"
|
||||
@ -154,16 +155,6 @@
|
||||
|
||||
#define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
|
||||
|
||||
typedef struct form_field_t {
|
||||
char *var;
|
||||
GSList *values;
|
||||
} FormField;
|
||||
|
||||
typedef struct data_form_t {
|
||||
char *form_type;
|
||||
GSList *fields;
|
||||
} DataForm;
|
||||
|
||||
xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx);
|
||||
|
||||
xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx,
|
||||
|
@ -86,6 +86,16 @@ typedef struct disco_identity_t {
|
||||
char *category;
|
||||
} DiscoIdentity;
|
||||
|
||||
typedef struct form_field_t {
|
||||
char *var;
|
||||
GSList *values;
|
||||
} FormField;
|
||||
|
||||
typedef struct data_form_t {
|
||||
char *form_type;
|
||||
GSList *fields;
|
||||
} DataForm;
|
||||
|
||||
void jabber_init_module(void);
|
||||
void bookmark_init_module(void);
|
||||
void capabilities_init_module(void);
|
||||
|
Loading…
Reference in New Issue
Block a user