mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-23 09:56:21 +00:00
Added /disco command
This commit is contained in:
@@ -98,6 +98,26 @@ iq_room_list_request(gchar *conferencejid)
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
void
|
||||
iq_disco_info_request(gchar *jid)
|
||||
{
|
||||
xmpp_conn_t * const conn = connection_get_conn();
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, "discoinforeq", jid, NULL);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
void
|
||||
iq_disco_items_request(gchar *jid)
|
||||
{
|
||||
xmpp_conn_t * const conn = connection_get_conn();
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, "discoitemsreq", jid);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
void
|
||||
iq_send_software_version(const char * const fulljid)
|
||||
{
|
||||
@@ -353,7 +373,9 @@ _iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
log_debug("Recieved diso#info response");
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
|
||||
if ((id != NULL) && (g_str_has_prefix(id, "disco"))) {
|
||||
if ((id != NULL) && (g_strcmp0(id, "discoinforeq") == 0)) {
|
||||
cons_show("GOT DISO INFO RESULT");
|
||||
} else if ((id != NULL) && (g_str_has_prefix(id, "disco"))) {
|
||||
log_debug("Response to query: %s", id);
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
|
||||
@@ -457,18 +479,15 @@ _iq_handle_discoinfo_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
|
||||
|
||||
//stanza_destroy_form(form);
|
||||
free(caps_key);
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_iq_handle_discoitems_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
void * const userdata)
|
||||
{
|
||||
GSList *rooms = NULL;
|
||||
|
||||
log_debug("Recieved diso#items response");
|
||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||
@@ -476,8 +495,9 @@ _iq_handle_discoitems_result(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
|
||||
|
||||
if ((id != NULL) && (g_strcmp0(id, "confreq") == 0)) {
|
||||
log_debug("Response to query: %s", id);
|
||||
|
||||
GSList *rooms = NULL;
|
||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||
|
||||
if (query != NULL) {
|
||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||
while (child != NULL) {
|
||||
@@ -492,10 +512,12 @@ _iq_handle_discoitems_result(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
|
||||
child = xmpp_stanza_get_next(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prof_handle_room_list(rooms, from);
|
||||
g_slist_free_full(rooms, free);
|
||||
prof_handle_room_list(rooms, from);
|
||||
g_slist_free_full(rooms, free);
|
||||
} else if ((id != NULL) && (g_strcmp0(id, "discoitemsreq") == 0)) {
|
||||
cons_show("GOT DISO ITEMS RESULT");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ _get_caps_key(xmpp_stanza_t * const stanza)
|
||||
log_debug("Node string: %s.", node);
|
||||
if (!caps_contains(caps_key)) {
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", caps_key);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, "disco", from, node);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, "disco", from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
} else {
|
||||
@@ -509,7 +509,7 @@ _get_caps_key(xmpp_stanza_t * const stanza)
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", from);
|
||||
GString *id = g_string_new("disco_");
|
||||
g_string_append(id, from_hash_str);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, id->str, from, node);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id->str, from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
g_string_free(id, TRUE);
|
||||
@@ -538,7 +538,7 @@ _get_caps_key(xmpp_stanza_t * const stanza)
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", from);
|
||||
GString *id = g_string_new("disco_");
|
||||
g_string_append(id, from_hash_str);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, id->str, from, node);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id->str, from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
g_string_free(id, TRUE);
|
||||
|
||||
@@ -178,7 +178,7 @@ stanza_create_roster_iq(xmpp_ctx_t *ctx)
|
||||
}
|
||||
|
||||
xmpp_stanza_t *
|
||||
stanza_create_disco_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)
|
||||
{
|
||||
xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
|
||||
@@ -190,7 +190,9 @@ stanza_create_disco_iq(xmpp_ctx_t *ctx, const char * const id, const char * cons
|
||||
xmpp_stanza_t *query = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
|
||||
xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO);
|
||||
xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node);
|
||||
if (node != NULL) {
|
||||
xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node);
|
||||
}
|
||||
|
||||
xmpp_stanza_add_child(iq, query);
|
||||
xmpp_stanza_release(query);
|
||||
|
||||
@@ -126,7 +126,7 @@ 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_ping_iq(xmpp_ctx_t *ctx);
|
||||
xmpp_stanza_t* stanza_create_disco_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,
|
||||
const char * const to, const char * const node);
|
||||
|
||||
gboolean stanza_contains_chat_state(xmpp_stanza_t *stanza);
|
||||
|
||||
@@ -93,6 +93,8 @@ void presence_update(resource_presence_t status, const char * const msg,
|
||||
// iq functions
|
||||
void iq_send_software_version(const char * const fulljid);
|
||||
void iq_room_list_request(gchar *conferencejid);
|
||||
void iq_disco_info_request(gchar *jid);
|
||||
void iq_disco_items_request(gchar *jid);
|
||||
|
||||
// caps functions
|
||||
Capabilities* caps_get(const char * const caps_str);
|
||||
|
||||
Reference in New Issue
Block a user