Ejemplo n.º 1
0
    int
handle_disco_items(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
        void * const userdata)
{
    xmpp_stanza_t *query, *item;
    xmppipe_state_t *state = userdata;
    xmpp_ctx_t *ctx = state->ctx;

    query = xmpp_stanza_get_child_by_name(stanza, "query");

    if (query == NULL)
        return 1;

    for (item = xmpp_stanza_get_children(query); item != NULL;
            item = xmpp_stanza_get_next(item)) {
        xmpp_stanza_t *iq, *reply;
        const char *jid = NULL;
        const char *name = NULL;
        char *id = NULL;

        name = xmpp_stanza_get_name(item);
        if (name == NULL)
            continue;

        if (XMPPIPE_STRNEQ(name, "item"))
            continue;

        jid = xmpp_stanza_get_attribute(item, "jid");
        if (jid == NULL)
            continue;

        iq = xmppipe_stanza_new(ctx);
        xmppipe_stanza_set_name(iq, "iq");
        xmppipe_stanza_set_type(iq, "get");
        xmppipe_stanza_set_attribute(iq, "to", jid);

        id = xmpp_uuid_gen(state->ctx);
        if (id == NULL) {
            errx(EXIT_FAILURE, "unable to allocate message id");
        }
        xmppipe_stanza_set_id(iq, id);

        reply = xmppipe_stanza_new(ctx);
        xmppipe_stanza_set_name(reply, "query");
        xmppipe_stanza_set_ns(reply, "http://jabber.org/protocol/disco#info");

        xmppipe_stanza_add_child(iq, reply);

        xmppipe_send(state, iq);
        (void)xmpp_stanza_release(iq);
        xmpp_free(state->ctx, id);
    }

    return 0;
}
Ejemplo n.º 2
0
char*
connection_create_uuid(void)
{
    return xmpp_uuid_gen(conn.xmpp_ctx);
}
Ejemplo n.º 3
0
char*
jabber_create_uuid(void)
{
    return xmpp_uuid_gen(jabber_conn.ctx);
}