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 HashList *XMPP_StartHandlers = NULL;
68 HashList *XMPP_EndHandlers = NULL;
69 HashList *XMPP_SupportedNamespaces = NULL;
70 HashList *XMPP_NameSpaces = NULL;
71 HashList *XMPP_EndToken = NULL;
72 HashList *FlatToken = NULL;
74 int XMPPSrvDebugEnable = 1;
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)
199 separate_namespace(const char *supplied_el,
200 const char **Token, long *TLen,
201 HashList **ThisNamespace)
205 const char *NS = NULL;
209 *ThisNamespace = NULL;
211 pToken = supplied_el;
212 pch = strchr(pToken, ':');
216 pch = strchr(pToken + 1, ':');
222 NSLen = pToken - supplied_el;
223 if (GetHash(XMPP_NameSpaces, NS, NSLen, &pv))
232 *TLen = strlen(pToken);
235 #ifdef HAVE_XML_STOPPARSER
236 /* Stop the parser if an entity declaration is hit. */
237 static void xmpp_entity_declaration(void *userData, const XML_Char *entityName,
238 int is_parameter_entity, const XML_Char *value,
239 int value_length, const XML_Char *base,
240 const XML_Char *systemId, const XML_Char *publicId,
241 const XML_Char *notationName
243 XMPPM_syslog(LOG_WARNING, "Illegal entity declaration encountered; stopping parser.");
244 XML_StopParser(XMPP->xp, XML_FALSE);
249 * We have just received a <stream> tag from the client, so send them ours
251 void xmpp_stream_start(void *data, const char *supplied_el, const char **attr)
253 citxmpp *Xmpp = XMPP;
256 if (!strcasecmp(attr[0], "to")) {
257 safestrncpy(Xmpp->server_name, attr[1], sizeof Xmpp->server_name);
262 XPUT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
264 XPUT("<stream:stream ");
266 XPutProp(Xmpp->server_name, strlen(Xmpp->server_name));
268 XPrintf("%08x\" ", CC->cs_pid);
269 XPUT("version=\"1.0\" "
270 "xmlns:stream=\"http://etherx.jabber.org/streams\" "
271 "xmlns=\"jabber:client\">"
272 /* The features of this stream are... */
273 "<stream:features>");
276 * TLS encryption (but only if it isn't already active)
280 if (!CC->redirect_ssl) {
281 XPUT("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>");
285 if (!CC->logged_in) {
286 /* If we're not logged in yet, offer SASL as our feature set */
287 xmpp_output_auth_mechs();
289 /* Also offer non-SASL authentication */
290 XPUT("<auth xmlns=\"http://jabber.org/features/iq-auth\"/>");
293 /* Offer binding and sessions as part of our feature set */
294 XPUT("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
295 "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
296 "</stream:features>");
298 CC->is_async = 1; /* XMPP sessions are inherently async-capable */
301 void xmpp_start_query(void *data, const char *supplied_el, const char **attr)
303 XMPP->iq_query_xmlns[0] = 0;
304 safestrncpy(XMPP->iq_query_xmlns, supplied_el, sizeof XMPP->iq_query_xmlns);
307 void xmpp_start_bind(void *data, const char *supplied_el, const char **attr)
309 XMPP->bind_requested = 1;
312 void xmpp_start_auth(void *data, const char *supplied_el, const char **attr)
316 XMPP->sasl_auth_mech[0] = 0;
317 for (i=0; attr[i] != NULL; i+=2) {
318 if (!strcasecmp(attr[i], "mechanism")) {
319 safestrncpy(XMPP->sasl_auth_mech, attr[i+1], sizeof XMPP->sasl_auth_mech);
324 void xmpp_start_message(void *data, const char *supplied_el, const char **attr)
328 for (i=0; attr[i] != NULL; i+=2) {
329 if (!strcasecmp(attr[i], "to")) {
330 safestrncpy(XMPP->message_to, attr[i+1], sizeof XMPP->message_to);
335 void xmpp_start_html(void *data, const char *supplied_el, const char **attr)
337 ++XMPP->html_tag_level;
341 void xmpp_xml_start(void *data, const char *supplied_el, const char **attr)
343 HashList *ThisNamespace;
348 separate_namespace(supplied_el, &pToken, &len, &ThisNamespace);
350 if (ThisNamespace != NULL)
352 if (GetHash(ThisNamespace, pToken, len, &pv))
358 th = (TokenHandler*) pv;
359 value = th->GetToken();
361 while (attr[i] != NULL)
364 if (GetHash(th->Properties, attr[i], strlen(attr[i]), &pv))
366 PropertyHandler* ph = pv;
371 len = strlen(attr[i+1]);
374 pVal = (StrBuf**) val;
376 StrBufPlain(*pVal, attr[i+1], len);
378 *pVal = NewStrBufPlain(attr[i+1], len);
387 XMPP_syslog(LOG_DEBUG, "XMPP ELEMENT START: <%s>\n", el);
388 for (i=0; attr[i] != NULL; i+=2) {
389 XMPP_syslog(LOG_DEBUG, " Attribute '%s' = '%s'\n", attr[i], attr[i+1]);
391 uncomment for more verbosity */
393 if (GetHash(XMPP_StartHandlers, pToken, len, &pv))
396 h = (xmpp_handler*) pv;
397 h->Handler(data, supplied_el, attr);
401 void xmpp_end_resource(void *data, const char *supplied_el, const char **attr)
403 if (XMPP->chardata_len > 0) {
404 safestrncpy(XMPP->iq_client_resource, XMPP->chardata,
405 sizeof XMPP->iq_client_resource);
406 striplt(XMPP->iq_client_resource);
410 void xmpp_end_username(void *data, const char *supplied_el, const char **attr)
413 if (XMPP->chardata_len > 0) {
414 safestrncpy(XMPP->iq_client_username, XMPP->chardata,
415 sizeof XMPP->iq_client_username);
416 striplt(XMPP->iq_client_username);
420 void xmpp_end_password(void *data, const char *supplied_el, const char **attr)
421 { /* NON SASL ONLY */
422 if (XMPP->chardata_len > 0) {
423 safestrncpy(XMPP->iq_client_password, XMPP->chardata,
424 sizeof XMPP->iq_client_password);
425 striplt(XMPP->iq_client_password);
429 void xmpp_end_iq(void *data, const char *supplied_el, const char **attr)
431 citxmpp *Xmpp = XMPP;
434 * iq type="get" (handle queries)
436 if (!strcasecmp(ChrPtr(Xmpp->IQ.type), "get"))
439 * Query on a namespace
441 if (!IsEmptyStr(Xmpp->iq_query_xmlns)) {
442 xmpp_query_namespace(&Xmpp->IQ, Xmpp->iq_query_xmlns);
446 * ping ( http://xmpp.org/extensions/xep-0199.html )
448 else if (Xmpp->ping_requested) {
449 XPUT("<iq type=\"result\" ");
450 if (StrLength(Xmpp->IQ.from) > 0) {
452 XPutSProp(Xmpp->IQ.from);
455 if (StrLength(Xmpp->IQ.to)>0) {
457 XPutSProp(Xmpp->IQ.to);
461 XPutSProp(Xmpp->IQ.id);
466 * Unknown query ... return the XML equivalent of a blank stare
470 Xmpp_syslog(LOG_DEBUG,
471 "Unknown query <%s> - returning <service-unavailable/>\n",
475 XPUT("<iq type=\"error\" id=\"");
476 XPutSProp(Xmpp->IQ.id);
478 "<error code=\"503\" type=\"cancel\">"
479 "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
486 * Non SASL authentication
489 (!strcasecmp(ChrPtr(Xmpp->IQ.type), "set"))
490 && (!strcasecmp(Xmpp->iq_query_xmlns, "jabber:iq:auth:query"))
493 xmpp_non_sasl_authenticate(
495 Xmpp->iq_client_username,
496 Xmpp->iq_client_password,
497 Xmpp->iq_client_resource
502 * If this <iq> stanza was a "bind" attempt, process it ...
505 (Xmpp->bind_requested)
506 && (StrLength(Xmpp->IQ.id)>0)
507 && (!IsEmptyStr(Xmpp->iq_client_resource))
511 /* Generate the "full JID" of the client resource */
513 snprintf(Xmpp->client_jid, sizeof Xmpp->client_jid,
516 Xmpp->iq_client_resource
519 /* Tell the client what its JID is */
521 XPUT("<iq type=\"result\" id=\"");
522 XPutSProp(Xmpp->IQ.id);
524 "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">");
526 XPutBody(Xmpp->client_jid, strlen(Xmpp->client_jid));
532 else if (Xmpp->iq_session) {
533 XPUT("<iq type=\"result\" id=\"");
534 XPutSProp(Xmpp->IQ.id);
540 XPUT("<iq type=\"error\" id=\"");
541 XPutSProp(Xmpp->IQ.id);
543 XPUT("<error>Don't know howto do '");
544 XPutBody(SKEY(Xmpp->IQ.type));
549 /* Now clear these fields out so they don't get used by a future stanza */
550 FlushStrBuf(Xmpp->IQ.id);
551 FlushStrBuf(Xmpp->IQ.from);
552 FlushStrBuf(Xmpp->IQ.to);
553 FlushStrBuf(Xmpp->IQ.type);
554 Xmpp->iq_client_resource[0] = 0;
555 Xmpp->iq_session = 0;
556 Xmpp->iq_query_xmlns[0] = 0;
557 Xmpp->bind_requested = 0;
558 Xmpp->ping_requested = 0;
562 void xmpp_end_auth(void *data, const char *supplied_el, const char **attr)
564 /* Try to authenticate (this function is responsible for the output stanza) */
565 xmpp_sasl_auth(XMPP->sasl_auth_mech, (XMPP->chardata != NULL ? XMPP->chardata : "") );
567 /* Now clear these fields out so they don't get used by a future stanza */
568 XMPP->sasl_auth_mech[0] = 0;
571 void xmpp_end_session(void *data, const char *supplied_el, const char **attr)
573 XMPP->iq_session = 1;
576 void xmpp_end_body(void *data, const char *supplied_el, const char **attr)
578 if (XMPP->html_tag_level == 0)
580 if (XMPP->message_body != NULL)
582 free(XMPP->message_body);
583 XMPP->message_body = NULL;
585 if (XMPP->chardata_len > 0) {
586 XMPP->message_body = strdup(XMPP->chardata);
591 void xmpp_end_html(void *data, const char *supplied_el, const char **attr)
593 --XMPP->html_tag_level;
596 void xmpp_end_starttls(void *data, const char *supplied_el, const char **attr)
599 XPUT("<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
601 CtdlModuleStartCryptoMsgs(NULL, NULL, NULL);
602 if (!CC->redirect_ssl) CC->kill_me = KILLME_NO_CRYPTO;
604 XPUT("<failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
605 CC->kill_me = KILLME_NO_CRYPTO;
609 void xmpp_end_ping(void *data, const char *supplied_el, const char **attr)
611 XMPP->ping_requested = 1;
614 void xmpp_end_stream(void *data, const char *supplied_el, const char **attr)
616 XMPPM_syslog(LOG_DEBUG, "XMPP client shut down their stream\n");
617 xmpp_massacre_roster();
619 CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
622 void xmpp_xml_end(void *data, const char *supplied_el)
624 HashList *ThisNamespace;
629 separate_namespace(supplied_el, &pToken, &len, &ThisNamespace);
631 if (ThisNamespace != NULL)
633 if (GetHash(XMPP_EndToken, pToken, len, &pv))
639 th = (TokenHandler*) pv;
640 value = th->GetToken();
642 while (attr[i] != NULL)
645 if (GetHash(th->Properties, attr[i], strlen(attr[i]), &pv))
647 PropertyHandler* ph = pv;
652 len = strlen(attr[i+1]);
655 pVal = (StrBuf**) val;
657 StrBufPlain(*pVal, attr[i+1], len);
659 *pVal = NewStrBufPlain(attr[i+1], len);
671 XMPP_syslog(LOG_DEBUG, "XMPP ELEMENT END : <%s>\n", el);
672 if (XMPP->chardata_len > 0) {
673 XMPP_syslog(LOG_DEBUG, " chardata: %s\n", XMPP->chardata);
675 uncomment for more verbosity */
677 if (GetHash(XMPP_EndHandlers, pToken, len, &pv))
680 h = (xmpp_handler*) pv;
681 h->Handler(data, supplied_el, NULL);
685 XMPP_syslog(LOG_DEBUG, "Ignoring unknown tag <%s>\n", pToken);
688 XMPP->chardata_len = 0;
689 if (XMPP->chardata_alloc > 0) {
690 XMPP->chardata[0] = 0;
695 void xmpp_xml_chardata(void *data, const XML_Char *s, int len)
699 if (X->chardata_alloc == 0) {
700 X->chardata_alloc = SIZ;
701 X->chardata = malloc(X->chardata_alloc);
703 if ((X->chardata_len + len + 1) > X->chardata_alloc) {
704 X->chardata_alloc = X->chardata_len + len + 1024;
705 X->chardata = realloc(X->chardata, X->chardata_alloc);
707 memcpy(&X->chardata[X->chardata_len], s, len);
708 X->chardata_len += len;
709 X->chardata[X->chardata_len] = 0;
714 * This cleanup function blows away the temporary memory and files used by the XMPP service.
716 void xmpp_cleanup_function(void) {
718 /* Don't do this stuff if this is not a XMPP session! */
719 if (CC->h_command_function != xmpp_command_loop) return;
721 if (XMPP->chardata != NULL) {
722 free(XMPP->chardata);
723 XMPP->chardata = NULL;
724 XMPP->chardata_len = 0;
725 XMPP->chardata_alloc = 0;
726 if (XMPP->message_body != NULL) {
727 free(XMPP->message_body);
730 free_buf_iq(&XMPP->IQ);
732 XML_ParserFree(XMPP->xp);
733 FreeStrBuf(&XMPP->OutBuf);
740 * Here's where our XMPP session begins its happy day.
742 void xmpp_greeting(void) {
743 client_set_inbound_buf(4);
744 strcpy(CC->cs_clientname, "XMPP session");
745 CC->session_specific_data = malloc(sizeof(citxmpp));
746 memset(XMPP, 0, sizeof(citxmpp));
747 XMPP->last_event_processed = queue_event_seq;
748 XMPP->OutBuf = NewStrBufPlain(NULL, SIZ);
749 /* XMPP does not use a greeting, but we still have to initialize some things. */
751 XMPP->xp = XML_ParserCreateNS("UTF-8", ':');
752 if (XMPP->xp == NULL) {
753 XMPPM_syslog(LOG_ALERT, "Cannot create XML parser!\n");
754 CC->kill_me = KILLME_XML_PARSER;
758 XML_SetElementHandler(XMPP->xp, xmpp_xml_start, xmpp_xml_end);
759 XML_SetCharacterDataHandler(XMPP->xp, xmpp_xml_chardata);
760 // XML_SetUserData(XMPP->xp, something...);
762 /* Prevent the "billion laughs" attack against expat by disabling
763 * internal entity expansion. With 2.x, forcibly stop the parser
764 * if an entity is declared - this is safer and a more obvious
765 * failure mode. With older versions, simply prevent expansion
766 * of such entities. */
767 #ifdef HAVE_XML_STOPPARSER
768 XML_SetEntityDeclHandler(XMPP->xp, xmpp_entity_declaration);
770 XML_SetDefaultHandler(XMPP->xp, NULL);
773 CC->can_receive_im = 1; /* This protocol is capable of receiving instant messages */
779 * Main command loop for XMPP sessions.
781 void xmpp_command_loop(void) {
783 StrBuf *stream_input = NewStrBuf();
786 rc = client_read_random_blob(stream_input, 30);
788 XML_Parse(XMPP->xp, ChrPtr(stream_input), rc, 0);
791 XMPPM_syslog(LOG_ERR, "client disconnected: ending session.\n");
792 CC->kill_me = KILLME_CLIENT_DISCONNECTED;
794 FreeStrBuf(&stream_input);
800 * Async loop for XMPP sessions (handles the transmission of unsolicited stanzas)
802 void xmpp_async_loop(void) {
803 xmpp_process_events();
804 xmpp_output_incoming_messages();
809 * Login hook for XMPP sessions
811 void xmpp_login_hook(void) {
812 xmpp_queue_event(XMPP_EVT_LOGIN, CC->cs_inet_email);
817 * Logout hook for XMPP sessions
819 void xmpp_logout_hook(void) {
820 xmpp_queue_event(XMPP_EVT_LOGOUT, CC->cs_inet_email);
824 void LogXMPPSrvDebugEnable(const int n)
826 XMPPSrvDebugEnable = n;
828 const char *CitadelServiceXMPP="XMPP";
832 /******************************************************************************
833 * XMPP handler registering logic *
834 ******************************************************************************/
836 void AddXMPPStartHandler(const char *key,
838 xmpp_handler_func Handler,
842 h = (xmpp_handler*) malloc(sizeof (xmpp_handler));
844 h->Handler = Handler;
845 Put(XMPP_StartHandlers, key, len, h, NULL);
848 void AddXMPPEndHandler(const char *key,
850 xmpp_handler_func Handler,
854 h = (xmpp_handler*) malloc(sizeof (xmpp_handler));
856 h->Handler = Handler;
857 Put(XMPP_EndHandlers, key, len, h, NULL);
860 void HFreePropertyHandler(void *FreeMe)
865 void HDeleteTokenHandler(void *FreeMe)
867 TokenHandler *th = (TokenHandler *) FreeMe;
868 DeleteHash(&th->Properties);
872 void XMPP_RegisterTokenProperty(const char *NS, long NSLen,
873 const char *Token, long TLen,
874 const char *Property, long PLen,
875 const char *PayloadSubToken, long pslen,
876 GetTokenDataFunc GetToken,
880 HashList *ThisNamespace = NULL;
884 const char *pNS, *pToken, *pProperty, *pPayloadSubToken;
886 pToken = (Token)?Token:"";
888 pProperty = (Property)?Property:"";
889 pPayloadSubToken = (PayloadSubToken)?PayloadSubToken:"";
891 XMPP_syslog(LOG_DEBUG,
892 "New tag: Token <%s> Namespace <%s> Property <%s> PayloadSubToken <%s>\n",
893 pToken, pNS, pProperty, pPayloadSubToken);
895 h = (PropertyHandler*) malloc(sizeof(PropertyHandler));
897 h->NameSpaceLen = NSLen;
900 h->Property = Property;
901 h->PropertyLen = PLen;
903 h->PayloadSubToken = PayloadSubToken;
906 if (!GetHash(XMPP_SupportedNamespaces, NS, NSLen, &pv))
908 Put(XMPP_SupportedNamespaces, NS, NSLen, NewStrBufPlain(NS, NSLen), HFreeStrBuf);
912 if (GetHash(XMPP_NameSpaces, NS, NSLen, &pv))
918 ThisNamespace = NewHash(1, NULL);
919 Put(XMPP_NameSpaces, NS, NSLen, ThisNamespace, HDeleteHash);
922 if (GetHash(ThisNamespace, Token, TLen, &pv))
928 th = (TokenHandler*) malloc (sizeof(TokenHandler));
929 th->GetToken = GetToken;
930 th->Properties = NewHash(1, NULL);
931 Put(ThisNamespace, Token, TLen, th, HDeleteTokenHandler);
937 Put(th->Properties, Property, PLen, h, HFreePropertyHandler);
941 Put(XMPP_EndToken, PayloadSubToken, pslen, h, reference_free_handler);
945 if (!GetHash(FlatToken, Token, TLen, &pv))
947 // todo mark pv as non uniq
948 Put(FlatToken, Token, TLen, ThisToken, reference_free_handler);
953 void xmpp_cleanup(void)
955 DeleteHash(&XMPP_StartHandlers);
956 DeleteHash(&XMPP_EndHandlers);
957 DeleteHash(&XMPP_SupportedNamespaces);
958 DeleteHash(&XMPP_NameSpaces);
959 DeleteHash(&FlatToken);
962 CTDL_MODULE_INIT(xmpp)
965 CtdlRegisterDebugFlagHook(HKEY("serv_xmpp"), LogXMPPSrvDebugEnable, &XMPPSrvDebugEnable);
967 CtdlRegisterServiceHook(config.c_xmpp_c2s_port,
975 XMPP_StartHandlers = NewHash(1, NULL);
976 XMPP_EndHandlers = NewHash(1, NULL);
977 XMPP_NameSpaces = NewHash(1, NULL);
978 XMPP_SupportedNamespaces = NewHash(1, NULL);
979 FlatToken = NewHash(1, NULL);
981 AddXMPPEndHandler(HKEY("resource"), xmpp_end_resource, 0);
982 AddXMPPEndHandler(HKEY("username"), xmpp_end_username, 0);
983 AddXMPPEndHandler(HKEY("password"), xmpp_end_password, 0);
984 AddXMPPEndHandler(HKEY("iq"), xmpp_end_iq, 0);
985 AddXMPPEndHandler(HKEY("auth"), xmpp_end_auth, 0);
986 AddXMPPEndHandler(HKEY("session"), xmpp_end_session, 0);
987 AddXMPPEndHandler(HKEY("body"), xmpp_end_body, 0);
988 AddXMPPEndHandler(HKEY("html"), xmpp_end_html, 0);
989 AddXMPPEndHandler(HKEY("starttls"), xmpp_end_starttls, 0);
990 AddXMPPEndHandler(HKEY("ping"), xmpp_end_ping, 0);
991 AddXMPPEndHandler(HKEY("stream"), xmpp_end_stream, 0);
993 AddXMPPStartHandler(HKEY("stream"), xmpp_stream_start, 0);
994 AddXMPPStartHandler(HKEY("query"), xmpp_start_query, 0);
995 AddXMPPStartHandler(HKEY("bind"), xmpp_start_bind, 0);
996 AddXMPPStartHandler(HKEY("auth"), xmpp_start_auth, 0);
997 /// AddXMPPStartHandler(HKEY("message"), xmpp_start_message, 0);
998 AddXMPPStartHandler(HKEY("html"), xmpp_start_html, 0);
1001 CtdlRegisterSessionHook(xmpp_cleanup_function, EVT_STOP, PRIO_STOP + 70);
1002 CtdlRegisterSessionHook(xmpp_login_hook, EVT_LOGIN, PRIO_LOGIN + 90);
1003 CtdlRegisterSessionHook(xmpp_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 90);
1004 CtdlRegisterSessionHook(xmpp_login_hook, EVT_UNSTEALTH, PRIO_UNSTEALTH + 1);
1005 CtdlRegisterSessionHook(xmpp_logout_hook, EVT_STEALTH, PRIO_STEALTH + 1);
1006 CtdlRegisterCleanupHook(xmpp_cleanup);
1009 /* return our module name for the log */