Back to index

citadel  8.12
xmpp_query_namespace.c File Reference
#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>
#include <time.h>
#include <sys/wait.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <expat.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"
#include "serv_xmpp.h"

Go to the source code of this file.


void xmpp_roster_item (struct CitContext *cptr)
void xmpp_iq_roster_query (void)
void xmpp_query_namespace (char *iq_id, char *iq_from, char *iq_to, char *query_xmlns)

Function Documentation

void xmpp_iq_roster_query ( void  )

Definition at line 81 of file xmpp_query_namespace.c.

       struct CitContext *cptr;
       int nContexts, i;

       cprintf("<query xmlns=\"jabber:iq:roster\">");
       cptr = CtdlGetContextArray(&nContexts);
       if (cptr) {
              for (i=0; i<nContexts; i++) {
                     if (xmpp_is_visible(&cptr[i], CC)) {
                            XMPP_syslog(LOG_DEBUG, "Rosterizing %s\n", cptr[i].user.fullname);
              free (cptr);

Here is the call graph for this function:

Here is the caller graph for this function:

void xmpp_query_namespace ( char *  iq_id,
char *  iq_from,
char *  iq_to,
char *  query_xmlns 

Definition at line 110 of file xmpp_query_namespace.c.

       int supported_namespace = 0;
       int roster_query = 0;
       char xmlbuf[256];

       /* We need to know before we begin the response whether this is a supported namespace, so
        * unfortunately all supported namespaces need to be defined here *and* down below where
        * they are handled.
       if (
              (!strcasecmp(query_xmlns, "jabber:iq:roster:query"))
              || (!strcasecmp(query_xmlns, "jabber:iq:auth:query"))
       ) {
              supported_namespace = 1;

       XMPP_syslog(LOG_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);

        * Beginning of query result.
       if (supported_namespace) {
              cprintf("<iq type=\"result\" ");
       else {
              cprintf("<iq type=\"error\" ");
       if (!IsEmptyStr(iq_from)) {
              cprintf("to=\"%s\" ", xmlesc(xmlbuf, iq_from, sizeof xmlbuf));
       cprintf("id=\"%s\">", xmlesc(xmlbuf, iq_id, sizeof xmlbuf));

        * Is this a query we know how to handle?

       if (!strcasecmp(query_xmlns, "jabber:iq:roster:query")) {
              roster_query = 1;

       else if (!strcasecmp(query_xmlns, "jabber:iq:auth:query")) {
              cprintf("<query xmlns=\"jabber:iq:auth\">"

        * If we didn't hit any known query namespaces then we should deliver a
        * "service unavailable" error (see RFC3921 section 2.4 and

       else {
                         "Unknown query namespace '%s' - returning <service-unavailable/>\n",
              cprintf("<error code=\"503\" type=\"cancel\">"
                     "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"


       /* If we told the client who is on the roster, we also need to tell the client
        * who is *not* on the roster.  (It's down here because we can't do it in the same
        * stanza; this will be an unsolicited push.)
       if (roster_query) {

Here is the call graph for this function:

Here is the caller graph for this function:

void xmpp_roster_item ( struct CitContext cptr)

Definition at line 62 of file xmpp_query_namespace.c.

       char xmlbuf1[256];
       char xmlbuf2[256];

       cprintf("<item jid=\"%s\" name=\"%s\" subscription=\"both\">",
              xmlesc(xmlbuf1, cptr->cs_inet_email, sizeof xmlbuf1),
              xmlesc(xmlbuf2, cptr->user.fullname, sizeof xmlbuf2)
       cprintf("<group>%s</group>", xmlesc(xmlbuf1, config.c_humannode, sizeof xmlbuf1));

Here is the call graph for this function:

Here is the caller graph for this function: