4 * Handle <iq> <get> <query> type situations (namespace queries)
6 * Copyright (c) 2007 by Art Cancro
7 * This code is released under the terms of the GNU General Public License.
19 #include <sys/types.h>
21 #if TIME_WITH_SYS_TIME
22 # include <sys/time.h>
26 # include <sys/time.h>
36 #include <libcitadel.h>
39 #include "citserver.h"
42 #include "internet_addressing.h"
44 #include "ctdl_module.h"
48 #include "serv_xmpp.h"
52 * Output a single roster item, for roster queries or pushes
54 void jabber_roster_item(struct CitContext *cptr) {
55 cprintf("<item jid=\"%s\" name=\"%s\" subscription=\"both\">",
59 cprintf("<group>%s</group>", config.c_humannode);
64 * Return the results for a "jabber:iq:roster:query"
66 * Since we are not yet managing a roster, we simply return the entire wholist
67 * (minus any entries for this user -- don't tell me about myself)
70 void jabber_iq_roster_query(void)
72 struct CitContext *cptr;
74 int aide = (CC->user.axlevel >= 6);
76 cprintf("<query xmlns=\"jabber:iq:roster\">");
78 cptr = CtdlGetContextArray(&nContexts);
80 return ; /** FIXME: Does jabber need to send something to maintain the protocol? */
82 for (i=0; i<nContexts; i++) {
83 if (cptr[i].logged_in) {
85 (((cptr[i].cs_flags&CS_STEALTH)==0) || (aide))
86 && (cptr[i].user.usernum != CC->user.usernum)
88 jabber_roster_item(&cptr[i]);
98 * TODO: handle queries on some or all of these namespaces
100 xmpp_query_namespace(purple5b5c1e58, splorph.xand.com, http://jabber.org/protocol/disco#items:query)
101 xmpp_query_namespace(purple5b5c1e59, splorph.xand.com, http://jabber.org/protocol/disco#info:query)
102 xmpp_query_namespace(purple5b5c1e5a, , vcard-temp:query)
106 void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_xmlns) {
108 lprintf(CTDL_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);
111 * Beginning of query result.
113 cprintf("<iq type=\"result\" ");
114 if (!IsEmptyStr(iq_from)) {
115 cprintf("to=\"%s\" ", iq_from);
117 cprintf("id=\"%s\">", iq_id);
120 * Is this a query we know how to handle?
123 if (!strcasecmp(query_xmlns, "jabber:iq:roster:query")) {
124 jabber_iq_roster_query();
127 else if (!strcasecmp(query_xmlns, "jabber:iq:auth:query")) {
128 cprintf("<query xmlns=\"jabber:iq:auth\">"
129 "<username/><password/><resource/>"
135 * End of query result. If we didn't hit any known namespaces then we will
136 * have simply delivered an empty result stanza, which should be ok.
142 #endif /* HAVE_EXPAT */