}
}
}
+
+ else if (!strcasecmp(el, "message")) {
+ for (i=0; attr[i] != NULL; i+=2) {
+ if (!strcasecmp(attr[i], "to")) {
+ safestrncpy(XMPP->message_to, attr[i+1], sizeof XMPP->message_to);
+ }
+ }
+ }
}
/* Generate the "full JID" of the client resource */
- // snprintf(XMPP->client_jid, sizeof XMPP->client_jid,
- // "%d@%s/%s",
- // CC->cs_pid,
- // config.c_fqdn,
- // XMPP->iq_client_resource
- //);
-
snprintf(XMPP->client_jid, sizeof XMPP->client_jid,
"%s/%s",
CC->cs_inet_email,
jabber_wholist_presence_dump();
}
+ else if (!strcasecmp(el, "body")) {
+ if (XMPP->message_body != NULL) {
+ free(XMPP->message_body);
+ XMPP->message_body = NULL;
+ }
+ if (XMPP->chardata_len > 0) {
+ XMPP->message_body = strdup(XMPP->chardata);
+ }
+ }
+
+ else if (!strcasecmp(el, "message")) {
+ jabber_send_message(XMPP->message_to, XMPP->message_body);
+ }
+
XMPP->chardata_len = 0;
if (XMPP->chardata_alloc > 0) {
XMPP->chardata[0] = 0;
XMPP->chardata = NULL;
XMPP->chardata_len = 0;
XMPP->chardata_alloc = 0;
+ if (XMPP->message_body != NULL) {
+ free(XMPP->message_body);
+ }
}
XML_ParserFree(XMPP->xp);
free(XMPP);
char iq_query_xmlns[256]; /* Namespace of <query> */
char sasl_auth_mech[32]; /* SASL auth mechanism requested by the client */
+
+ char message_to[256];
+ char *message_body; /* Message body in transit */
};
#define XMPP ((struct citxmpp *)CC->session_specific_data)
void xmpp_process_events(void);
void xmpp_presence_notify(char *, char *);
void jabber_roster_item(struct CitContext *);
+void jabber_send_message(char *, char *);
}
}
+/*
+ * Client is sending a message.
+ */
+void jabber_send_message(char *message_to, char *message_body) {
+ char *recp = NULL;
+ int message_sent = 0;
+ struct CitContext *cptr;
+
+ if (message_body == NULL) return;
+ if (message_to == NULL) return;
+ if (IsEmptyStr(message_to)) return;
+
+ for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
+ if (!strcasecmp(cptr->cs_inet_email, message_to)) {
+ recp = cptr->user.fullname;
+ }
+ }
+
+ if (recp) {
+ message_sent = PerformXmsgHooks(CC->user.fullname, CC->cs_inet_email, recp, message_body);
+ }
+}
+
+
#endif /* HAVE_EXPAT */