xmpp_stream_start(data, supplied_el, attr);
}
+ else if (!strcasecmp(el, "query")) {
+ XMPP->iq_query_xmlns[0] = 0;
+ safestrncpy(XMPP->iq_query_xmlns, supplied_el, sizeof XMPP->iq_query_xmlns);
+ }
+
else if (!strcasecmp(el, "iq")) {
- const char *iqtype = NULL;
- const char *iqid = NULL;
for (i=0; attr[i] != NULL; i+=2) {
- if (!strcasecmp(attr[i], "type")) iqtype = attr[i+1];
- if (!strcasecmp(attr[i], "id")) iqid = attr[i+1];
- }
- if (iqtype != NULL) {
- safestrncpy(XMPP->iq_type, iqtype, sizeof XMPP->iq_type);
- }
- if ((iqtype != NULL) && (iqid != NULL)) {
- if (!strcasecmp(iqtype, "set")) {
- safestrncpy(XMPP->iq_bind_id, iqid, sizeof XMPP->iq_bind_id);
+ if (!strcasecmp(attr[i], "type")) {
+ safestrncpy(XMPP->iq_type, attr[i+1], sizeof XMPP->iq_type);
+ }
+ else if (!strcasecmp(attr[i], "id")) {
+ safestrncpy(XMPP->iq_id, attr[i+1], sizeof XMPP->iq_id);
+ }
+ else if (!strcasecmp(attr[i], "to")) {
+ safestrncpy(XMPP->iq_to, attr[i+1], sizeof XMPP->iq_to);
}
}
}
else if (!strcasecmp(el, "iq")) {
/*
- * iq type="get"
+ * iq type="get" (handle queries)
*/
if (!strcasecmp(XMPP->iq_type, "get")) {
- lprintf(CTDL_DEBUG, "\e[32m DISCO DUCK! \e[0m\n");
+
+ /*
+ * Query on a namespace
+ */
+ if (!IsEmptyStr(XMPP->iq_query_xmlns)) {
+ xmpp_query_namespace(XMPP->iq_id, XMPP->iq_to, XMPP->iq_query_xmlns);
+ }
+
+ /*
+ * Unknown queries ... return the XML equivalent of a blank stare
+ */
+ else {
+ cprintf("<iq type=\"result\" id=\"%s\">", XMPP->iq_id);
+ cprintf("</iq>");
+ }
}
/*
* If this <iq> stanza was a "bind" attempt, process it ...
*/
- else if ( (!IsEmptyStr(XMPP->iq_bind_id)) && (!IsEmptyStr(XMPP->iq_client_resource)) ) {
+ else if ( (!IsEmptyStr(XMPP->iq_id)) && (!IsEmptyStr(XMPP->iq_client_resource)) ) {
/* Generate the "full JID" of the client resource */
/* Tell the client what its JID is */
- cprintf("<iq type=\"result\" id=\"%s\">", XMPP->iq_bind_id);
+ cprintf("<iq type=\"result\" id=\"%s\">", XMPP->iq_id);
cprintf("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">");
cprintf("<jid>%s</jid>", XMPP->client_jid);
cprintf("</bind>");
}
else if (XMPP->iq_session) {
- cprintf("<iq type=\"result\" id=\"%s\">", XMPP->iq_bind_id);
+ cprintf("<iq type=\"result\" id=\"%s\">", XMPP->iq_id);
cprintf("</iq>");
}
else {
- cprintf("<iq type=\"error\" id=\"%s\">", XMPP->iq_bind_id);
+ cprintf("<iq type=\"error\" id=\"%s\">", XMPP->iq_id);
cprintf("<error></error>");
cprintf("</iq>");
}
/* Now clear these fields out so they don't get used by a future stanza */
- XMPP->iq_bind_id[0] = 0;
+ XMPP->iq_id[0] = 0;
+ XMPP->iq_to[0] = 0;
+ XMPP->iq_type[0] = 0;
XMPP->iq_client_resource[0] = 0;
XMPP->iq_session = 0;
+ XMPP->iq_query_xmlns[0] = 0;
}
else if (!strcasecmp(el, "auth")) {
char client_jid[256]; /* "full JID" of the client */
char iq_type[256];
- char iq_bind_id[256]; /* for <iq> stanzas */
+ char iq_id[256]; /* for <iq> stanzas */
+ char iq_to[256]; /* for <iq> stanzas */
char iq_client_resource[256]; /* resource name requested by the client */
int iq_session; /* nonzero == client is requesting a session */
+ char iq_query_xmlns[256]; /* Namespace of <query> */
char sasl_auth_mech[32]; /* SASL auth mechanism requested by the client */
};
void xmpp_command_loop(void);
void xmpp_sasl_auth(char *, char *);
void xmpp_output_auth_mechs(void);
+void xmpp_query_namespace(char *, char *, char *);
--- /dev/null
+/*
+ * $Id: $
+ *
+ * Handle <iq> <get> <query> type situations (namespace queries)
+ *
+ * Copyright (c) 2007 by Art Cancro
+ * This code is released under the terms of the GNU General Public License.
+ *
+ */
+
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <pwd.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <sys/wait.h>
+#include <string.h>
+#include <limits.h>
+#include <ctype.h>
+#include <libcitadel.h>
+#include "citadel.h"
+#include "server.h"
+#include "citserver.h"
+#include "support.h"
+#include "config.h"
+#include "internet_addressing.h"
+#include "md5.h"
+#include "ctdl_module.h"
+
+#ifdef HAVE_EXPAT
+#include <expat.h>
+#include "serv_xmpp.h"
+
+/*
+ * TODO: handle queries on some or all of these namespaces
+
+xmpp_query_namespace(purple5b5c1e58, splorph.xand.com, http://jabber.org/protocol/disco#items:query)
+xmpp_query_namespace(purple5b5c1e59, splorph.xand.com, http://jabber.org/protocol/disco#info:query)
+xmpp_query_namespace(purple5b5c1e5a, , vcard-temp:query)
+xmpp_query_namespace(purple5b5c1e5b, , jabber:iq:roster:query)
+
+ */
+
+void xmpp_query_namespace(char *iq_id, char *iq_to, char *query_xmlns) {
+
+ lprintf(CTDL_DEBUG, "\e[31mxmpp_query_namespace(%s, %s, %s)\e[0m\n", iq_id, iq_to, query_xmlns);
+
+ /*
+ * Unknown query. Return the XML equivalent of a blank stare (empty result)
+ */
+ cprintf("<iq type=\"result\" id=\"%s\">", iq_id);
+ cprintf("</iq>");
+
+}
+
+#endif /* HAVE_EXPAT */