]> code.citadel.org Git - citadel.git/commitdiff
XMPP presence dump of wholist
authorArt Cancro <ajc@citadel.org>
Thu, 29 Nov 2007 16:44:04 +0000 (16:44 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 29 Nov 2007 16:44:04 +0000 (16:44 +0000)
citadel/modules/jabber/serv_xmpp.c
citadel/modules/jabber/serv_xmpp.h
citadel/modules/jabber/xmpp_presence.c [new file with mode: 0644]
citadel/modules/jabber/xmpp_query_namespace.c

index e23ad7cc15c3e77f319fac8adc6be0a754280f39..ecf73671c4cd4cecaafec9644b1dcd717cd0a4ce 100644 (file)
@@ -256,6 +256,14 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                XMPP->iq_session = 1;
        }
 
+       else if (!strcasecmp(el, "presence")) {
+
+               /* Respond to a <presence> update by firing back with presence information
+                * on the entire wholist.  Check this assumption, it's probably wrong.
+                */
+               jabber_wholist_presence_dump();
+       }
+
        XMPP->chardata_len = 0;
        if (XMPP->chardata_alloc > 0) {
                XMPP->chardata[0] = 0;
index 0c97c0fbc5ef6bb05d9ff56bf89ab0ba56cba046..e45a744bcc24f197370f0a38487e53a6f80253fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id$
+ * $Id$
  *
  */
 
@@ -30,3 +30,4 @@ void xmpp_command_loop(void);
 void xmpp_sasl_auth(char *, char *);
 void xmpp_output_auth_mechs(void);
 void xmpp_query_namespace(char *, char *, char *, char *);
+void jabber_wholist_presence_dump(void);
diff --git a/citadel/modules/jabber/xmpp_presence.c b/citadel/modules/jabber/xmpp_presence.c
new file mode 100644 (file)
index 0000000..1b10ef4
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * $Id$ 
+ *
+ * Handle XMPP presence exchanges
+ *
+ * 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"
+
+
+/* 
+ * Initial dump of the entire wholist
+ */
+void jabber_wholist_presence_dump(void)
+{
+       struct CitContext *cptr;
+       int aide = (CC->user.axlevel >= 6);
+
+       for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
+               if (
+                  (((cptr->cs_flags&CS_STEALTH)==0) || (aide))         /* aides can see everyone */
+                  && (cptr->user.usernum != CC->user.usernum)          /* don't tell me about myself */
+                  ) {
+                       cprintf("<presence type=\"available\" from=\"%s\"></presence>", cptr->cs_inet_email);
+               }
+       }
+}
+
+
+#endif /* HAVE_EXPAT */
index 5fd3e223e23c48582de9914da9471cc761e92c60..995cc5381a97bc543ef5569ead8eb8154d71715c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id:  
+ * $Id$ 
  *
  * Handle <iq> <get> <query> type situations (namespace queries)
  *
@@ -51,7 +51,8 @@
 /* 
  * Return the results for a "jabber:iq:roster:query"
  *
- * Since we are not yet managing a roster, we simply return the entire wholist.
+ * Since we are not yet managing a roster, we simply return the entire wholist
+ * (minus any entries for this user -- don't tell me about myself)
  *
  */
 void jabber_iq_roster_query(void)
@@ -63,7 +64,10 @@ void jabber_iq_roster_query(void)
 
        for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
 
-               if (((cptr->cs_flags&CS_STEALTH)==0) || (aide)) {
+               if (
+                  (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
+                  && (cptr->user.usernum != CC->user.usernum)
+                  ) {
                        cprintf("<item jid=\"%s\" name=\"%s\" subscription=\"both\">",
                                cptr->cs_inet_email,
                                cptr->user.fullname
@@ -73,22 +77,6 @@ void jabber_iq_roster_query(void)
                }
        }
 
-/**** these remain here for documentation example only
-
-       cprintf("<item jid=\"romeo@example.net\" name=\"Romeo\" subscription=\"both\">");
-       cprintf("<group>Friends</group>");
-       cprintf("</item>");
-
-       cprintf("<item jid=\"mercutio@example.org\" name=\"Mercutio\" subscription=\"from\">");
-       cprintf("<group>Friends</group>");
-       cprintf("</item>");
-
-       cprintf("<item jid=\"benvolio@example.org\" name=\"Benvolio\" subscription=\"both\">");
-       cprintf("<group>Friends</group>");
-       cprintf("</item>");
-
- ****/
-
        cprintf("</query>");
 }
 
@@ -99,7 +87,6 @@ void jabber_iq_roster_query(void)
 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)
  *
  */