diff --git a/src/xmpp/message.c b/src/xmpp/message.c index fc841ae2..e14ae07d 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -93,6 +93,7 @@ static void _send_message_stanza(xmpp_stanza_t* const stanza); static gboolean _handle_mam(xmpp_stanza_t* const stanza); static void _handle_pubsub(xmpp_stanza_t* const stanza, xmpp_stanza_t* const event); static gboolean _handle_form(xmpp_stanza_t* const stanza); +static gboolean _handle_jingle_message(xmpp_stanza_t* const stanza); #ifdef HAVE_LIBGPGME static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text); @@ -170,6 +171,11 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) == 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) == 0) { // type: chat, normal (==NULL) + // XEP-0353: Jingle Message Initiation + if (_handle_jingle_message(stanza)) { + return 1; + } + // XEP-0045: Multi-User Chat 8.6 Voice Requests if (_handle_form(stanza)) { return 1; @@ -1664,3 +1670,20 @@ message_request_voice(const char* const roomjid) _send_message_stanza(stanza); xmpp_stanza_release(stanza); } + +static gboolean +_handle_jingle_message(xmpp_stanza_t* const stanza) +{ + xmpp_stanza_t* propose = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_PROPOSE, STANZA_NS_JINGLE_MESSAGE); + + if (propose) { + xmpp_stanza_t* description = xmpp_stanza_get_child_by_ns(propose, STANZA_NS_JINGLE_RTP); + if (description) { + const char* const from = xmpp_stanza_get_from(stanza); + cons_show("Ring ring: %s is trying to call you", from); + cons_alert(NULL); + return TRUE; + } + } + return FALSE; +} diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 06b2815a..5effaf3e 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -121,6 +121,7 @@ #define STANZA_NAME_LAST "last" #define STANZA_NAME_AFTER "after" #define STANZA_NAME_USERNAME "username" +#define STANZA_NAME_PROPOSE "propose" // error conditions #define STANZA_NAME_BAD_REQUEST "bad-request" @@ -238,6 +239,8 @@ #define STANZA_NS_RSM "http://jabber.org/protocol/rsm" #define STANZA_NS_REGISTER "jabber:iq:register" #define STANZA_NS_VOICEREQUEST "http://jabber.org/protocol/muc#request" +#define STANZA_NS_JINGLE_MESSAGE "urn:xmpp:jingle-message:0" +#define STANZA_NS_JINGLE_RTP "urn:xmpp:jingle:apps:rtp:1" #define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"