mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 04:06:21 +00:00
Added /caps command
This commit is contained in:
@@ -48,7 +48,8 @@ void
|
||||
caps_add(const char * const caps_str, const char * const category,
|
||||
const char * const type, const char * const name,
|
||||
const char * const software, const char * const software_version,
|
||||
const char * const os, const char * const os_version)
|
||||
const char * const os, const char * const os_version,
|
||||
GSList *features)
|
||||
{
|
||||
Capabilities *new_caps = malloc(sizeof(struct capabilities_t));
|
||||
|
||||
@@ -87,6 +88,11 @@ caps_add(const char * const caps_str, const char * const category,
|
||||
} else {
|
||||
new_caps->os_version = NULL;
|
||||
}
|
||||
if (features != NULL) {
|
||||
new_caps->features = features;
|
||||
} else {
|
||||
new_caps->features = NULL;
|
||||
}
|
||||
|
||||
g_hash_table_insert(capabilities, strdup(caps_str), new_caps);
|
||||
}
|
||||
@@ -284,6 +290,10 @@ _caps_destroy(Capabilities *caps)
|
||||
FREE_SET_NULL(caps->software_version);
|
||||
FREE_SET_NULL(caps->os);
|
||||
FREE_SET_NULL(caps->os_version);
|
||||
if (caps->features != NULL) {
|
||||
g_slist_free_full(caps->features, free);
|
||||
caps->features = NULL;
|
||||
}
|
||||
FREE_SET_NULL(caps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void caps_init(void);
|
||||
void caps_add(const char * const caps_str, const char * const category,
|
||||
const char * const type, const char * const name,
|
||||
const char * const software, const char * const software_version,
|
||||
const char * const os, const char * const os_version);
|
||||
const char * const os, const char * const os_version, GSList *features);
|
||||
gboolean caps_contains(const char * const caps_str);
|
||||
char* caps_create_sha1_str(xmpp_stanza_t * const query);
|
||||
xmpp_stanza_t* caps_create_query_response_stanza(xmpp_ctx_t * const ctx);
|
||||
|
||||
@@ -324,6 +324,7 @@ _iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
const char *software_version = NULL;
|
||||
const char *os = NULL;
|
||||
const char *os_version = NULL;
|
||||
GSList *features = NULL;
|
||||
|
||||
xmpp_stanza_t *identity = xmpp_stanza_get_child_by_name(query, "identity");
|
||||
if (identity != NULL) {
|
||||
@@ -356,8 +357,17 @@ _iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
}
|
||||
}
|
||||
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||
while (child != NULL) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) {
|
||||
features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var")));
|
||||
}
|
||||
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
|
||||
caps_add(caps_key, category, type, name, software, software_version,
|
||||
os, os_version);
|
||||
os, os_version, features);
|
||||
|
||||
//stanza_destroy_form(form);
|
||||
free(caps_key);
|
||||
|
||||
@@ -54,6 +54,7 @@ typedef struct capabilities_t {
|
||||
char *software_version;
|
||||
char *os;
|
||||
char *os_version;
|
||||
GSList *features;
|
||||
} Capabilities;
|
||||
|
||||
// connection functions
|
||||
|
||||
Reference in New Issue
Block a user