OBJECTS = sort_udns.o tcp_connect.o iksemel_extra.o tictactoe.o \
- xmpp.o features.o sasl.o bind.o
+ xmpp.o features.o sasl.o bind.o disco.o
CC = gcc
CFLAGS = -g -Wall `pkg-config --cflags iksemel libgsasl`
LIBS = -ludns `pkg-config --libs iksemel libgsasl`
--- /dev/null
+/*
+ * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include "xmpp_internal.h"
+#include "disco.h"
+
+void
+hc_xmpp_send_disco_info (hc_xmpp_t *xmpp, char *to)
+{
+ iks *disco;
+ iks *query;
+ disco = iks_new ("iq");
+ iks_insert_attrib (disco, "type", "get");
+ iks_insert_attrib (disco, "to", to);
+ query = iks_insert (disco, "query");
+ iks_insert_attrib (query, "xmlns", HC_XMPP_NS_DISCO_INFO);
+ hc_xmpp_send_iks (xmpp, disco);
+ iks_delete (disco);
+}
+
+void
+hc_xmpp_recv_disco (hc_xmpp_t *xmpp, iks *disco)
+{
+ char *ns = iks_find_attrib (iks_child (disco), "xmlns");
+ if (!iks_strcmp (ns, HC_XMPP_NS_DISCO_INFO))
+ {
+ iks *c;
+ for (c = iks_child (iks_child (disco)); c != NULL; c = iks_next (c))
+ {
+ fprintf (stdout, "%s\n", iks_find_attrib (c, "var"));
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef HC_XMPP_DISCO_H
+#define HC_XMPP_DISCO_H
+
+#include "xmpp.h"
+
+void hc_xmpp_send_disco_info (hc_xmpp_t *, char *);
+void hc_xmpp_recv_disco (hc_xmpp_t *, iks *);
+
+#endif
#include "xmpp.h"
#include "sasl.h"
#include "bind.h"
+#include "disco.h"
static void write_stream (hc_xmpp_t *);
static void
send_message_test (hc_xmpp_t *xmpp)
{
- iks *msg;
- msg = iks_new ("message");
- iks_insert_attrib (msg, "to", "metal@jabber-br.org");
- iks_insert_cdata (iks_insert (msg, "body"), "pubsub", 0);
- hc_xmpp_send_iks (xmpp, msg);
- iks_delete (msg);
+ hc_xmpp_send_disco_info (xmpp, "");
}
static int
if (hc_xmpp_status (data) == HC_XMPP_SESSION)
send_message_test (data);
}
+ else if (!iks_strcmp (ns, HC_XMPP_NS_DISCO_INFO))
+ {
+ hc_xmpp_recv_disco (data, stanza);
+ }
}
else if (!iks_strcmp (iks_name (stanza), "stream:features"))
{
#define HC_XMPP_NS_SASL "urn:ietf:params:xml:ns:xmpp-sasl"
#define HC_XMPP_NS_BIND "urn:ietf:params:xml:ns:xmpp-bind"
#define HC_XMPP_NS_SESSION "urn:ietf:params:xml:ns:xmpp-session"
+#define HC_XMPP_NS_DISCO "http://jabber.org/protocol/disco"
+#define HC_XMPP_NS_DISCO_INFO "http://jabber.org/protocol/disco#info"
hc_xmpp_t * hc_xmpp_new (iksStreamHook *, char *, char *, char *);
int hc_xmpp_is_tls_supported (hc_xmpp_t *);