mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 20:35:31 +00:00
sip: origin: Explicitly include contact header for sofia > 1.13
Fixes #304
This commit is contained in:
parent
d4ee8b4bc9
commit
864a15d799
1 changed files with 56 additions and 0 deletions
|
@ -40,6 +40,7 @@
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include <sofia-sip/sofia_features.h>
|
||||||
#include <sofia-sip/nua.h>
|
#include <sofia-sip/nua.h>
|
||||||
#include <sofia-sip/su_tag.h>
|
#include <sofia-sip/su_tag.h>
|
||||||
#include <sofia-sip/su_tag_io.h>
|
#include <sofia-sip/su_tag_io.h>
|
||||||
|
@ -70,6 +71,8 @@ enum {
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
|
static gboolean set_contact_header = FALSE;
|
||||||
|
|
||||||
struct _CallsSipOrigin
|
struct _CallsSipOrigin
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
@ -77,6 +80,7 @@ struct _CallsSipOrigin
|
||||||
CallsSipContext *ctx;
|
CallsSipContext *ctx;
|
||||||
nua_t *nua;
|
nua_t *nua;
|
||||||
CallsSipHandles *oper;
|
CallsSipHandles *oper;
|
||||||
|
char *contact_header; /* Needed for sofia SIP >= 1.13 */
|
||||||
|
|
||||||
/* Direct connection mode is useful for debugging purposes */
|
/* Direct connection mode is useful for debugging purposes */
|
||||||
gboolean use_direct_connection;
|
gboolean use_direct_connection;
|
||||||
|
@ -231,6 +235,7 @@ add_call (CallsSipOrigin *self,
|
||||||
SOATAG_AF (SOA_AF_IP4_IP6),
|
SOATAG_AF (SOA_AF_IP4_IP6),
|
||||||
SOATAG_USER_SDP_STR (local_sdp),
|
SOATAG_USER_SDP_STR (local_sdp),
|
||||||
SIPTAG_TO_STR (address),
|
SIPTAG_TO_STR (address),
|
||||||
|
TAG_IF (!!self->contact_header, SIPTAG_CONTACT_STR (self->contact_header)),
|
||||||
SOATAG_RTP_SORT (SOA_RTP_SORT_REMOTE),
|
SOATAG_RTP_SORT (SOA_RTP_SORT_REMOTE),
|
||||||
SOATAG_RTP_SELECT (SOA_RTP_SELECT_ALL),
|
SOATAG_RTP_SELECT (SOA_RTP_SELECT_ALL),
|
||||||
TAG_END ());
|
TAG_END ());
|
||||||
|
@ -457,6 +462,7 @@ sip_r_register (int status,
|
||||||
if (status == 200) {
|
if (status == 200) {
|
||||||
g_debug ("REGISTER successful");
|
g_debug ("REGISTER successful");
|
||||||
origin->state = CALLS_ACCOUNT_ONLINE;
|
origin->state = CALLS_ACCOUNT_ONLINE;
|
||||||
|
nua_get_params (nua, TAG_ANY (), TAG_END());
|
||||||
|
|
||||||
} else if (status == 401 || status == 407) {
|
} else if (status == 401 || status == 407) {
|
||||||
sip_authenticate (origin, nh, sip);
|
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
|
static void
|
||||||
sip_callback (nua_event_t event,
|
sip_callback (nua_event_t event,
|
||||||
int status,
|
int status,
|
||||||
|
@ -694,6 +729,17 @@ sip_callback (nua_event_t event,
|
||||||
tags);
|
tags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case nua_r_get_params:
|
||||||
|
sip_r_get_params (status,
|
||||||
|
phrase,
|
||||||
|
nua,
|
||||||
|
origin,
|
||||||
|
nh,
|
||||||
|
op,
|
||||||
|
sip,
|
||||||
|
tags);
|
||||||
|
break;
|
||||||
|
|
||||||
case nua_r_set_params:
|
case nua_r_set_params:
|
||||||
g_debug ("response to set_params: %03d %s", status, phrase);
|
g_debug ("response to set_params: %03d %s", status, phrase);
|
||||||
break;
|
break;
|
||||||
|
@ -1134,6 +1180,16 @@ calls_sip_origin_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
||||||
g_autoptr (GError) error = NULL;
|
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)) {
|
if (!init_sip_account (self, &error)) {
|
||||||
g_warning ("Error initializing the SIP account: %s", error->message);
|
g_warning ("Error initializing the SIP account: %s", error->message);
|
||||||
|
|
Loading…
Reference in a new issue