4 * Handle messages sent and received using XMPP (Jabber) protocol
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>
36 #include <libcitadel.h>
39 #include "citserver.h"
42 #include "internet_addressing.h"
44 #include "ctdl_module.h"
48 #include "serv_xmpp.h"
52 * This function is called by the XMPP service's async loop.
53 * If the client session has instant messages waiting, it outputs
54 * unsolicited XML stanzas containing them.
56 void jabber_output_incoming_messages(void) {
58 struct ExpressMessage *ptr;
60 while (CC->FirstExpressMessage != NULL) {
62 begin_critical_section(S_SESSION_TABLE);
63 ptr = CC->FirstExpressMessage;
64 CC->FirstExpressMessage = CC->FirstExpressMessage->next;
65 end_critical_section(S_SESSION_TABLE);
67 /* FIXME we have to get the sender's email address. This may involve tweaking
68 * the core IM module a bit.
70 cprintf("<message to=\"%s\" from=\"FIXME@example.org\" type=\"chat\">", XMPP->client_jid);
71 if (ptr->text != NULL) {
73 memfmout(ptr->text, 0, "\n");
74 if (ptr->text[strlen(ptr->text)-1] != '\n') cprintf("\n");
78 cprintf("</message>");
84 #endif /* HAVE_EXPAT */