1
0
Fork 0

Merge pull request #1560 from profanity-im/feature/1525-jingle

XEP-0353: Display a notice when receiving a call
This commit is contained in:
Michael Vetter 2021-06-10 13:50:18 +02:00 committed by GitHub
commit c83f246a90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -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;
}

View File

@ -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"