1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-06-28 14:49:30 +00:00

sip: origin: Explicitly include contact header for sofia > 1.13

Fixes #304
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-07-12 19:08:38 +02:00 committed by Evangelos Ribeiro Tzaras
parent d4ee8b4bc9
commit 864a15d799

View file

@ -40,6 +40,7 @@
#include <glib/gi18n.h>
#include <glib-object.h>
#include <sofia-sip/sofia_features.h>
#include <sofia-sip/nua.h>
#include <sofia-sip/su_tag.h>
#include <sofia-sip/su_tag_io.h>
@ -70,6 +71,8 @@ enum {
};
static GParamSpec *props[PROP_LAST_PROP];
static gboolean set_contact_header = FALSE;
struct _CallsSipOrigin
{
GObject parent_instance;
@ -77,6 +80,7 @@ struct _CallsSipOrigin
CallsSipContext *ctx;
nua_t *nua;
CallsSipHandles *oper;
char *contact_header; /* Needed for sofia SIP >= 1.13 */
/* Direct connection mode is useful for debugging purposes */
gboolean use_direct_connection;
@ -231,6 +235,7 @@ add_call (CallsSipOrigin *self,
SOATAG_AF (SOA_AF_IP4_IP6),
SOATAG_USER_SDP_STR (local_sdp),
SIPTAG_TO_STR (address),
TAG_IF (!!self->contact_header, SIPTAG_CONTACT_STR (self->contact_header)),
SOATAG_RTP_SORT (SOA_RTP_SORT_REMOTE),
SOATAG_RTP_SELECT (SOA_RTP_SELECT_ALL),
TAG_END ());
@ -457,6 +462,7 @@ sip_r_register (int status,
if (status == 200) {
g_debug ("REGISTER successful");
origin->state = CALLS_ACCOUNT_ONLINE;
nua_get_params (nua, TAG_ANY (), TAG_END());
} else if (status == 401 || status == 407) {
sip_authenticate (origin, nh, sip);
@ -598,6 +604,35 @@ sip_i_state (int status,
}
static void
sip_r_get_params (int status,
char const *phrase,
nua_t *nua,
CallsSipOrigin *origin,
nua_handle_t *nh,
CallsSipHandles *op,
sip_t const *sip,
tagi_t tags[])
{
tagi_t *from = NULL;
const char *from_str = NULL;
g_debug ("response to get_params: %03d %s", status, phrase);
if (!set_contact_header)
return;
if ((status != 200) || ((from = tl_find (tags, siptag_from_str)) == NULL)) {
g_warning ("Could not find 'siptag_from_tag' among the tags");
return;
}
from_str = (const char *) from->t_value;
g_free (origin->contact_header);
origin->contact_header = g_strdup (from_str);
}
static void
sip_callback (nua_event_t event,
int status,
@ -694,6 +729,17 @@ sip_callback (nua_event_t event,
tags);
break;
case nua_r_get_params:
sip_r_get_params (status,
phrase,
nua,
origin,
nh,
op,
sip,
tags);
break;
case nua_r_set_params:
g_debug ("response to set_params: %03d %s", status, phrase);
break;
@ -1134,6 +1180,16 @@ calls_sip_origin_constructed (GObject *object)
{
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
g_autoptr (GError) error = NULL;
int major = 0;
int minor = 0;
int patch = 0;
if (sscanf (SOFIA_SIP_VERSION, "%d.%d.%d", &major, &minor, &patch) == 3) {
if (major > 2 || (major == 1 && minor >= 13)) {
/* Sofia 1.13 does no longer include the contact header by default, see #304 */
set_contact_header = TRUE;
}
}
if (!init_sip_account (self, &error)) {
g_warning ("Error initializing the SIP account: %s", error->message);