2 * XMPP (Jabber) service for the Citadel system
3 * Copyright (c) 2007-2011 by Art Cancro
5 * This program is open source software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <sys/types.h>
31 #if TIME_WITH_SYS_TIME
32 # include <sys/time.h>
36 # include <sys/time.h>
46 #define SHOW_ME_VAPPEND_PRINTF
47 #include <libcitadel.h>
51 #include "citserver.h"
57 #include "internet_addressing.h"
59 #include "ctdl_module.h"
60 #include "serv_xmpp.h"
62 /* XML_StopParser is present in expat 2.x */
63 #if XML_MAJOR_VERSION > 1
64 #define HAVE_XML_STOPPARSER
67 struct xmpp_event *xmpp_queue = NULL;
68 HashList *XMPP_StartHandlers = NULL;
69 HashList *XMPP_EndHandlers = NULL;
70 HashList *XMPP_SupportedNamespaces = NULL;
71 HashList *XMPP_NameSpaces = 0;
72 HashList *FlatToken = NULL;
74 int XMPPSrvDebugEnable = 0;
80 cputbuf(Xmpp->OutBuf);
81 FlushStrBuf(Xmpp->OutBuf);
84 void XPutBody(const char *Str, long Len)
86 StrBufXMLEscAppend(XMPP->OutBuf, NULL, Str, Len, 0);
89 void XPutProp(const char *Str, long Len)
91 StrEscAppend(XMPP->OutBuf, NULL, Str, 0, 1);
94 void XPut(const char *Str, long Len)
96 StrBufAppendBufPlain(XMPP->OutBuf, Str, Len, 0);
99 void XPrintf(const char *Format, ...)
102 va_start(arg_ptr, Format);
103 StrBufVAppendPrintf(XMPP->OutBuf, Format, arg_ptr);
108 void XPrint(const char *Token, long tlen,
125 va_start(arg_ptr, Flags);
128 ArgType = va_arg(arg_ptr, int);
132 PName = va_arg(arg_ptr, char*);
133 PLen = va_arg(arg_ptr, long);
134 Val = va_arg(arg_ptr, char*);
135 VLen = va_arg(arg_ptr, long);
143 PName = va_arg(arg_ptr, char*);
144 PLen = va_arg(arg_ptr, long);
145 Val = va_arg(arg_ptr, char*);
146 VLen = va_arg(arg_ptr, long);
157 PName = va_arg(arg_ptr, char*);
158 PLen = va_arg(arg_ptr, long);
159 VLen = va_arg(arg_ptr, long);
163 XPrintf("%ld", VLen);
169 Val = va_arg(arg_ptr, char*);
170 VLen = va_arg(arg_ptr, long);
178 if (Flags == XCLOSED)
198 #ifdef HAVE_XML_STOPPARSER
199 /* Stop the parser if an entity declaration is hit. */
200 static void xmpp_entity_declaration(void *userData, const XML_Char *entityName,
201 int is_parameter_entity, const XML_Char *value,
202 int value_length, const XML_Char *base,
203 const XML_Char *systemId, const XML_Char *publicId,
204 const XML_Char *notationName
206 XMPPM_syslog(LOG_WARNING, "Illegal entity declaration encountered; stopping parser.");
207 XML_StopParser(XMPP->xp, XML_FALSE);
212 * We have just received a <stream> tag from the client, so send them ours
214 void xmpp_stream_start(void *data, const char *supplied_el, const char **attr)
216 citxmpp *Xmpp = XMPP;
219 if (!strcasecmp(attr[0], "to")) {
220 safestrncpy(Xmpp->server_name, attr[1], sizeof Xmpp->server_name);
225 XPUT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
227 XPUT("<stream:stream ");
229 XPutProp(Xmpp->server_name, strlen(Xmpp->server_name));
231 XPrintf("%08x\" ", CC->cs_pid);
232 XPUT("version=\"1.0\" "
233 "xmlns:stream=\"http://etherx.jabber.org/streams\" "
234 "xmlns=\"jabber:client\">"
235 /* The features of this stream are... */
236 "<stream:features>");
239 * TLS encryption (but only if it isn't already active)
243 if (!CC->redirect_ssl) {
244 XPUT("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>");
248 if (!CC->logged_in) {
249 /* If we're not logged in yet, offer SASL as our feature set */
250 xmpp_output_auth_mechs();
252 /* Also offer non-SASL authentication */
253 XPUT("<auth xmlns=\"http://jabber.org/features/iq-auth\"/>");
256 /* Offer binding and sessions as part of our feature set */
257 XPUT("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
258 "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
259 "</stream:features>");
261 CC->is_async = 1; /* XMPP sessions are inherently async-capable */
264 void xmpp_start_query(void *data, const char *supplied_el, const char **attr)
266 XMPP->iq_query_xmlns[0] = 0;
267 safestrncpy(XMPP->iq_query_xmlns, supplied_el, sizeof XMPP->iq_query_xmlns);
270 void xmpp_start_bind(void *data, const char *supplied_el, const char **attr)
272 XMPP->bind_requested = 1;
275 void xmpp_start_iq(void *data, const char *supplied_el, const char **attr)
279 for (i=0; attr[i] != NULL; i+=2) {
280 if (!strcasecmp(attr[i], "type")) {
281 safestrncpy(XMPP->iq_type, attr[i+1], sizeof XMPP->iq_type);
283 else if (!strcasecmp(attr[i], "id")) {
284 safestrncpy(XMPP->iq_id, attr[i+1], sizeof XMPP->iq_id);
286 else if (!strcasecmp(attr[i], "from")) {
287 safestrncpy(XMPP->iq_from, attr[i+1], sizeof XMPP->iq_from);
289 else if (!strcasecmp(attr[i], "to")) {
290 safestrncpy(XMPP->iq_to, attr[i+1], sizeof XMPP->iq_to);
296 void xmpp_start_auth(void *data, const char *supplied_el, const char **attr)
300 XMPP->sasl_auth_mech[0] = 0;
301 for (i=0; attr[i] != NULL; i+=2) {
302 if (!strcasecmp(attr[i], "mechanism")) {
303 safestrncpy(XMPP->sasl_auth_mech, attr[i+1], sizeof XMPP->sasl_auth_mech);
308 void xmpp_start_message(void *data, const char *supplied_el, const char **attr)
312 for (i=0; attr[i] != NULL; i+=2) {
313 if (!strcasecmp(attr[i], "to")) {
314 safestrncpy(XMPP->message_to, attr[i+1], sizeof XMPP->message_to);
319 void xmpp_start_html(void *data, const char *supplied_el, const char **attr)
321 ++XMPP->html_tag_level;
324 void xmpp_xml_start(void *data, const char *supplied_el, const char **attr)
326 HashList *ThisNamespace = NULL;
329 const char *NS = NULL;
334 /* Axe the namespace, we don't care about it */
335 pToken = supplied_el;
336 pch = strchr(pToken, ':');
340 pch = strchr(pToken + 1, ':');
346 NSLen = pToken - supplied_el;
347 if (GetHash(XMPP_NameSpaces, NS, NSLen, &pv))
356 len = strlen(pToken);
359 if (ThisNamespace != NULL)
361 if (GetHash(ThisNamespace, pToken, len, &pv))
367 th = (TokenHandler*) pv;
368 value = th->GetToken();
370 while (attr[i] != NULL)
373 if (GetHash(th->Properties, attr[i], strlen(attr[i]), &pv))
375 PropertyHandler* ph = pv;
380 len = strlen(attr[i+1]);
383 pVal = (StrBuf**) val;
385 StrBufPlain(*pVal, attr[i+1], len);
387 *pVal = NewStrBufPlain(attr[i+1], len);
396 XMPP_syslog(LOG_DEBUG, "XMPP ELEMENT START: <%s>\n", el);
397 for (i=0; attr[i] != NULL; i+=2) {
398 XMPP_syslog(LOG_DEBUG, " Attribute '%s' = '%s'\n", attr[i], attr[i+1]);
400 uncomment for more verbosity */
402 if (GetHash(XMPP_StartHandlers, pToken, len, &pv))
405 h = (xmpp_handler*) pv;
406 h->Handler(data, supplied_el, attr);
410 void xmpp_end_resource(void *data, const char *supplied_el, const char **attr)
412 if (XMPP->chardata_len > 0) {
413 safestrncpy(XMPP->iq_client_resource, XMPP->chardata,
414 sizeof XMPP->iq_client_resource);
415 striplt(XMPP->iq_client_resource);
419 void xmpp_end_username(void *data, const char *supplied_el, const char **attr)
422 if (XMPP->chardata_len > 0) {
423 safestrncpy(XMPP->iq_client_username, XMPP->chardata,
424 sizeof XMPP->iq_client_username);
425 striplt(XMPP->iq_client_username);
429 void xmpp_end_password(void *data, const char *supplied_el, const char **attr)
430 { /* NON SASL ONLY */
431 if (XMPP->chardata_len > 0) {
432 safestrncpy(XMPP->iq_client_password, XMPP->chardata,
433 sizeof XMPP->iq_client_password);
434 striplt(XMPP->iq_client_password);
438 void xmpp_end_iq(void *data, const char *supplied_el, const char **attr)
440 citxmpp *Xmpp = XMPP;
443 * iq type="get" (handle queries)
445 if (!strcasecmp(ChrPtr(Xmpp->IQ.type), "get"))
448 * Query on a namespace
450 if (!IsEmptyStr(Xmpp->iq_query_xmlns)) {
451 xmpp_query_namespace(&Xmpp->IQ, Xmpp->iq_query_xmlns);
455 * ping ( http://xmpp.org/extensions/xep-0199.html )
457 else if (Xmpp->ping_requested) {
458 XPUT("<iq type=\"result\" ");
459 if (StrLength(Xmpp->IQ.from) > 0) {
461 XPutSProp(Xmpp->IQ.from);
464 if (StrLength(Xmpp->IQ.to)>0) {
466 XPutSProp(Xmpp->IQ.to);
470 XPutSProp(Xmpp->IQ.id);
475 * Unknown query ... return the XML equivalent of a blank stare
479 Xmpp_syslog(LOG_DEBUG,
480 "Unknown query <%s> - returning <service-unavailable/>\n",
484 XPUT("<iq type=\"error\" id=\"");
485 XPutSProp(Xmpp->IQ.id);
487 "<error code=\"503\" type=\"cancel\">"
488 "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
495 * Non SASL authentication
498 (!strcasecmp(ChrPtr(Xmpp->IQ.type), "set"))
499 && (!strcasecmp(Xmpp->iq_query_xmlns, "jabber:iq:auth:query"))
502 xmpp_non_sasl_authenticate(
504 Xmpp->iq_client_username,
505 Xmpp->iq_client_password,
506 Xmpp->iq_client_resource
511 * If this <iq> stanza was a "bind" attempt, process it ...
514 (Xmpp->bind_requested)
515 && (StrLength(Xmpp->IQ.id)>0)
516 && (!IsEmptyStr(Xmpp->iq_client_resource))
520 /* Generate the "full JID" of the client resource */
522 snprintf(Xmpp->client_jid, sizeof Xmpp->client_jid,
525 Xmpp->iq_client_resource
528 /* Tell the client what its JID is */
530 XPUT("<iq type=\"result\" id=\"");
531 XPutSProp(Xmpp->IQ.id);
533 "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">");
535 XPutBody(Xmpp->client_jid, strlen(Xmpp->client_jid));
541 else if (Xmpp->iq_session) {
542 XPUT("<iq type=\"result\" id=\"");
543 XPutSProp(Xmpp->IQ.id);
549 XPUT("<iq type=\"error\" id=\"");
550 XPutSProp(Xmpp->IQ.id);
552 XPUT("<error>Don't know howto do '");
553 XPutBody(SKEY(Xmpp->IQ.type));
558 /* Now clear these fields out so they don't get used by a future stanza */
559 FlushStrBuf(Xmpp->IQ.id);
560 FlushStrBuf(Xmpp->IQ.from);
561 FlushStrBuf(Xmpp->IQ.to);
562 FlushStrBuf(Xmpp->IQ.type);
563 Xmpp->iq_client_resource[0] = 0;
564 Xmpp->iq_session = 0;
565 Xmpp->iq_query_xmlns[0] = 0;
566 Xmpp->bind_requested = 0;
567 Xmpp->ping_requested = 0;
571 void xmpp_end_auth(void *data, const char *supplied_el, const char **attr)
573 /* Try to authenticate (this function is responsible for the output stanza) */
574 xmpp_sasl_auth(XMPP->sasl_auth_mech, (XMPP->chardata != NULL ? XMPP->chardata : "") );
576 /* Now clear these fields out so they don't get used by a future stanza */
577 XMPP->sasl_auth_mech[0] = 0;
580 void xmpp_end_session(void *data, const char *supplied_el, const char **attr)
582 XMPP->iq_session = 1;
585 void xmpp_end_body(void *data, const char *supplied_el, const char **attr)
587 if (XMPP->html_tag_level == 0)
589 if (XMPP->message_body != NULL)
591 free(XMPP->message_body);
592 XMPP->message_body = NULL;
594 if (XMPP->chardata_len > 0) {
595 XMPP->message_body = strdup(XMPP->chardata);
600 void xmpp_end_html(void *data, const char *supplied_el, const char **attr)
602 --XMPP->html_tag_level;
605 void xmpp_end_starttls(void *data, const char *supplied_el, const char **attr)
608 XPUT("<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
610 CtdlModuleStartCryptoMsgs(NULL, NULL, NULL);
611 if (!CC->redirect_ssl) CC->kill_me = KILLME_NO_CRYPTO;
613 XPUT("<failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
614 CC->kill_me = KILLME_NO_CRYPTO;
618 void xmpp_end_ping(void *data, const char *supplied_el, const char **attr)
620 XMPP->ping_requested = 1;
623 void xmpp_end_stream(void *data, const char *supplied_el, const char **attr)
625 XMPPM_syslog(LOG_DEBUG, "XMPP client shut down their stream\n");
626 xmpp_massacre_roster();
628 CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
631 void xmpp_xml_end(void *data, const char *supplied_el)
638 /* Axe the namespace, we don't care about it */
639 pToken = supplied_el;
640 pch = strchr(pToken, ':');
644 pch = strchr(pToken + 1, ':');
650 len = strlen(pToken);
653 XMPP_syslog(LOG_DEBUG, "XMPP ELEMENT END : <%s>\n", el);
654 if (XMPP->chardata_len > 0) {
655 XMPP_syslog(LOG_DEBUG, " chardata: %s\n", XMPP->chardata);
657 uncomment for more verbosity */
659 if (GetHash(XMPP_EndHandlers, pToken, len, &pv))
662 h = (xmpp_handler*) pv;
663 h->Handler(data, supplied_el, NULL);
667 XMPP_syslog(LOG_DEBUG, "Ignoring unknown tag <%s>\n", pToken);
670 XMPP->chardata_len = 0;
671 if (XMPP->chardata_alloc > 0) {
672 XMPP->chardata[0] = 0;
677 void xmpp_xml_chardata(void *data, const XML_Char *s, int len)
681 if (X->chardata_alloc == 0) {
682 X->chardata_alloc = SIZ;
683 X->chardata = malloc(X->chardata_alloc);
685 if ((X->chardata_len + len + 1) > X->chardata_alloc) {
686 X->chardata_alloc = X->chardata_len + len + 1024;
687 X->chardata = realloc(X->chardata, X->chardata_alloc);
689 memcpy(&X->chardata[X->chardata_len], s, len);
690 X->chardata_len += len;
691 X->chardata[X->chardata_len] = 0;
696 * This cleanup function blows away the temporary memory and files used by the XMPP service.
698 void xmpp_cleanup_function(void) {
700 /* Don't do this stuff if this is not a XMPP session! */
701 if (CC->h_command_function != xmpp_command_loop) return;
703 if (XMPP->chardata != NULL) {
704 free(XMPP->chardata);
705 XMPP->chardata = NULL;
706 XMPP->chardata_len = 0;
707 XMPP->chardata_alloc = 0;
708 if (XMPP->message_body != NULL) {
709 free(XMPP->message_body);
712 free_buf_iq(&XMPP->IQ);
714 XML_ParserFree(XMPP->xp);
715 FreeStrBuf(&XMPP->OutBuf);
722 * Here's where our XMPP session begins its happy day.
724 void xmpp_greeting(void) {
725 client_set_inbound_buf(4);
726 strcpy(CC->cs_clientname, "XMPP session");
727 CC->session_specific_data = malloc(sizeof(citxmpp));
728 memset(XMPP, 0, sizeof(citxmpp));
729 XMPP->last_event_processed = queue_event_seq;
730 XMPP->OutBuf = NewStrBufPlain(NULL, SIZ);
731 /* XMPP does not use a greeting, but we still have to initialize some things. */
733 XMPP->xp = XML_ParserCreateNS("UTF-8", ':');
734 if (XMPP->xp == NULL) {
735 XMPPM_syslog(LOG_ALERT, "Cannot create XML parser!\n");
736 CC->kill_me = KILLME_XML_PARSER;
740 XML_SetElementHandler(XMPP->xp, xmpp_xml_start, xmpp_xml_end);
741 XML_SetCharacterDataHandler(XMPP->xp, xmpp_xml_chardata);
742 // XML_SetUserData(XMPP->xp, something...);
744 /* Prevent the "billion laughs" attack against expat by disabling
745 * internal entity expansion. With 2.x, forcibly stop the parser
746 * if an entity is declared - this is safer and a more obvious
747 * failure mode. With older versions, simply prevent expansion
748 * of such entities. */
749 #ifdef HAVE_XML_STOPPARSER
750 XML_SetEntityDeclHandler(XMPP->xp, xmpp_entity_declaration);
752 XML_SetDefaultHandler(XMPP->xp, NULL);
755 CC->can_receive_im = 1; /* This protocol is capable of receiving instant messages */
761 * Main command loop for XMPP sessions.
763 void xmpp_command_loop(void) {
765 StrBuf *stream_input = NewStrBuf();
768 rc = client_read_random_blob(stream_input, 30);
770 XML_Parse(XMPP->xp, ChrPtr(stream_input), rc, 0);
773 XMPPM_syslog(LOG_ERR, "client disconnected: ending session.\n");
774 CC->kill_me = KILLME_CLIENT_DISCONNECTED;
776 FreeStrBuf(&stream_input);
782 * Async loop for XMPP sessions (handles the transmission of unsolicited stanzas)
784 void xmpp_async_loop(void) {
785 xmpp_process_events();
786 xmpp_output_incoming_messages();
791 * Login hook for XMPP sessions
793 void xmpp_login_hook(void) {
794 xmpp_queue_event(XMPP_EVT_LOGIN, CC->cs_inet_email);
799 * Logout hook for XMPP sessions
801 void xmpp_logout_hook(void) {
802 xmpp_queue_event(XMPP_EVT_LOGOUT, CC->cs_inet_email);
806 void LogXMPPSrvDebugEnable(const int n)
808 XMPPSrvDebugEnable = n;
810 const char *CitadelServiceXMPP="XMPP";
811 extern void xmpp_cleanup_events(void);
815 /******************************************************************************
816 * XMPP handler registering logic *
817 ******************************************************************************/
819 void AddXMPPStartHandler(const char *key,
821 xmpp_handler_func Handler,
825 h = (xmpp_handler*) malloc(sizeof (xmpp_handler));
827 h->Handler = Handler;
828 Put(XMPP_StartHandlers, key, len, h, NULL);
831 void AddXMPPEndHandler(const char *key,
833 xmpp_handler_func Handler,
837 h = (xmpp_handler*) malloc(sizeof (xmpp_handler));
839 h->Handler = Handler;
840 Put(XMPP_EndHandlers, key, len, h, NULL);
843 void HFreePropertyHandler(void *FreeMe)
848 void HDeleteTokenHandler(void *FreeMe)
850 TokenHandler *th = (TokenHandler *) FreeMe;
851 DeleteHash(&th->Properties);
855 void XMPP_RegisterTokenProperty(const char *NS, long NSLen,
856 const char *Token, long TLen,
857 const char *Property, long PLen,
858 GetTokenDataFunc GetToken,
862 HashList *ThisNamespace = NULL;
866 h = (PropertyHandler*) malloc(sizeof(PropertyHandler));
868 h->NameSpaceLen = NSLen;
871 h->Property = Property;
872 h->PropertyLen = PLen;
875 if (!GetHash(XMPP_SupportedNamespaces, NS, NSLen, &pv))
877 Put(XMPP_SupportedNamespaces, NS, NSLen, NewStrBufPlain(NS, NSLen), HFreeStrBuf);
881 if (GetHash(XMPP_NameSpaces, NS, NSLen, &pv))
887 ThisNamespace = NewHash(1, NULL);
888 Put(XMPP_NameSpaces, NS, NSLen, ThisNamespace, HDeleteHash);
891 if (GetHash(ThisNamespace, Token, TLen, &pv))
897 th = (TokenHandler*) malloc (sizeof(TokenHandler));
898 th->GetToken = GetToken;
899 th->Properties = NewHash(1, NULL);
900 Put(ThisNamespace, Token, TLen, th, HDeleteTokenHandler);
903 Put(th->Properties, Property, PLen, h, HFreePropertyHandler);
905 if (!GetHash(FlatToken, Token, TLen, &pv))
907 // todo mark pv as non uniq
908 Put(FlatToken, Token, TLen, ThisToken, reference_free_handler);
915 CTDL_MODULE_INIT(xmpp)
918 CtdlRegisterServiceHook(config.c_xmpp_c2s_port,
926 XMPP_StartHandlers = NewHash(1, NULL);
927 XMPP_EndHandlers = NewHash(1, NULL);
928 XMPP_NameSpaces = NewHash(1, NULL);
929 XMPP_SupportedNamespaces = NewHash(1, NULL);
930 FlatToken = NewHash(1, NULL);
932 AddXMPPEndHandler(HKEY("resource"), xmpp_end_resource, 0);
933 AddXMPPEndHandler(HKEY("username"), xmpp_end_username, 0);
934 AddXMPPEndHandler(HKEY("password"), xmpp_end_password, 0);
935 AddXMPPEndHandler(HKEY("iq"), xmpp_end_iq, 0);
936 AddXMPPEndHandler(HKEY("auth"), xmpp_end_auth, 0);
937 AddXMPPEndHandler(HKEY("session"), xmpp_end_session, 0);
938 AddXMPPEndHandler(HKEY("body"), xmpp_end_body, 0);
939 AddXMPPEndHandler(HKEY("html"), xmpp_end_html, 0);
940 AddXMPPEndHandler(HKEY("starttls"), xmpp_end_starttls, 0);
941 AddXMPPEndHandler(HKEY("ping"), xmpp_end_ping, 0);
942 AddXMPPEndHandler(HKEY("stream"), xmpp_end_stream, 0);
944 AddXMPPStartHandler(HKEY("stream"), xmpp_stream_start, 0);
945 AddXMPPStartHandler(HKEY("query"), xmpp_start_query, 0);
946 AddXMPPStartHandler(HKEY("bind"), xmpp_start_bind, 0);
947 AddXMPPStartHandler(HKEY("iq"), xmpp_start_iq, 0);
948 AddXMPPStartHandler(HKEY("auth"), xmpp_start_auth, 0);
949 AddXMPPStartHandler(HKEY("message"), xmpp_start_message, 0);
950 AddXMPPStartHandler(HKEY("html"), xmpp_start_html, 0);
953 CtdlRegisterDebugFlagHook(HKEY("serv_xmpp"), LogXMPPSrvDebugEnable, &XMPPSrvDebugEnable);
954 CtdlRegisterSessionHook(xmpp_cleanup_function, EVT_STOP, PRIO_STOP + 70);
955 CtdlRegisterSessionHook(xmpp_login_hook, EVT_LOGIN, PRIO_LOGIN + 90);
956 CtdlRegisterSessionHook(xmpp_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 90);
957 CtdlRegisterSessionHook(xmpp_login_hook, EVT_UNSTEALTH, PRIO_UNSTEALTH + 1);
958 CtdlRegisterSessionHook(xmpp_logout_hook, EVT_STEALTH, PRIO_STEALTH + 1);
959 CtdlRegisterCleanupHook(xmpp_cleanup_events);
962 /* return our module name for the log */