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>
37 #include <libcitadel.h>
40 #include "citserver.h"
43 #include "internet_addressing.h"
45 #include "ctdl_module.h"
46 #include "serv_xmpp.h"
50 * Output a single roster item, for roster queries or pushes
52 void jabber_roster_item(struct CitContext *cptr) {
53 cprintf("<item jid=\"%s\" name=\"%s\" subscription=\"both\">",
57 cprintf("<group>%s</group>", config.c_humannode);
62 * Return the results for a "jabber:iq:roster:query"
64 * Since we are not yet managing a roster, we simply return the entire wholist
65 * (minus any entries for this user -- don't tell me about myself)
68 void jabber_iq_roster_query(void)
70 struct CitContext *cptr;
72 int aide = (CC->user.axlevel >= 6);
74 cprintf("<query xmlns=\"jabber:iq:roster\">");
76 cptr = CtdlGetContextArray(&nContexts);
78 return ; /** FIXME: Does jabber need to send something to maintain the protocol? */
80 for (i=0; i<nContexts; i++) {
81 if (cptr[i].logged_in) {
83 (((cptr[i].cs_flags&CS_STEALTH)==0) || (aide))
84 && (cptr[i].user.usernum != CC->user.usernum)
86 jabber_roster_item(&cptr[i]);
96 * TODO: handle queries on some or all of these namespaces
98 xmpp_query_namespace(purple5b5c1e58, splorph.xand.com, http://jabber.org/protocol/disco#items:query)
99 xmpp_query_namespace(purple5b5c1e59, splorph.xand.com, http://jabber.org/protocol/disco#info:query)
100 xmpp_query_namespace(purple5b5c1e5a, , vcard-temp:query)
104 void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_xmlns) {
106 lprintf(CTDL_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);
109 * Beginning of query result.
111 cprintf("<iq type=\"result\" ");
112 if (!IsEmptyStr(iq_from)) {
113 cprintf("to=\"%s\" ", iq_from);
115 cprintf("id=\"%s\">", iq_id);
118 * Is this a query we know how to handle?
121 if (!strcasecmp(query_xmlns, "jabber:iq:roster:query")) {
122 jabber_iq_roster_query();
125 else if (!strcasecmp(query_xmlns, "jabber:iq:auth:query")) {
126 cprintf("<query xmlns=\"jabber:iq:auth\">"
127 "<username/><password/><resource/>"
133 * End of query result. If we didn't hit any known namespaces then we will
134 * have simply delivered an empty result stanza, which should be ok.