1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-07 12:25:31 +00:00

sip: origin: Add property tracking usage for tel URIs

Fixes #277
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-10-29 02:39:29 +02:00
parent 66224c9a48
commit fbbe17139d
6 changed files with 44 additions and 1 deletions

View file

@ -397,6 +397,7 @@ on_apply_clicked (CallsSipAccountWidget *self)
gtk_entry_get_text (self->display_name), gtk_entry_get_text (self->display_name),
get_selected_protocol (self), get_selected_protocol (self),
get_port (self), get_port (self),
FALSE,
TRUE); TRUE);
update_header (self); update_header (self);

View file

@ -74,6 +74,7 @@ enum {
PROP_ACC_ADDRESS, PROP_ACC_ADDRESS,
PROP_CALLS, PROP_CALLS,
PROP_COUNTRY_CODE, PROP_COUNTRY_CODE,
PROP_CAN_TEL,
PROP_LAST_PROP, PROP_LAST_PROP,
}; };
static GParamSpec *props[PROP_LAST_PROP]; static GParamSpec *props[PROP_LAST_PROP];
@ -109,6 +110,7 @@ struct _CallsSipOrigin
char *transport_protocol; char *transport_protocol;
gboolean auto_connect; gboolean auto_connect;
gboolean direct_mode; gboolean direct_mode;
gboolean can_tel;
gint local_port; gint local_port;
const char *protocol_prefix; const char *protocol_prefix;
@ -1102,10 +1104,13 @@ supports_protocol (CallsOrigin *origin,
if (g_strcmp0 (protocol, "sip") == 0) if (g_strcmp0 (protocol, "sip") == 0)
return TRUE; return TRUE;
if (g_strcmp0 (protocol, "sips") == 0) if (g_strcmp0 (protocol, "sips") == 0)
return g_strcmp0 (self->protocol_prefix, "sips") == 0; return g_strcmp0 (self->protocol_prefix, "sips") == 0;
/* TODO need to set a property (from the UI) to allow using origin for telephony */ if (g_strcmp0 (protocol, "tel") == 0)
return self->can_tel;
return FALSE; return FALSE;
} }
@ -1184,6 +1189,10 @@ calls_sip_origin_set_property (GObject *object,
self->local_port = g_value_get_int (value); self->local_port = g_value_get_int (value);
break; break;
case PROP_CAN_TEL:
self->can_tel = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break; break;
@ -1256,6 +1265,10 @@ calls_sip_origin_get_property (GObject *object,
g_value_set_string (value, NULL); g_value_set_string (value, NULL);
break; break;
case PROP_CAN_TEL:
g_value_set_boolean (value, self->can_tel);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break; break;
@ -1407,6 +1420,14 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass)
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_SIP_CONTEXT, props[PROP_SIP_CONTEXT]); g_object_class_install_property (object_class, PROP_SIP_CONTEXT, props[PROP_SIP_CONTEXT]);
props[PROP_CAN_TEL] =
g_param_spec_boolean ("can-tel",
"Can telephone",
"Whether to this account can be used for PSTN telephony",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CAN_TEL, props[PROP_CAN_TEL]);
g_object_class_override_property (object_class, PROP_ACC_STATE, "account-state"); g_object_class_override_property (object_class, PROP_ACC_STATE, "account-state");
props[PROP_ACC_STATE] = g_object_class_find_property (object_class, "account-state"); props[PROP_ACC_STATE] = g_object_class_find_property (object_class, "account-state");
@ -1472,6 +1493,7 @@ calls_sip_origin_set_credentials (CallsSipOrigin *self,
const char *display_name, const char *display_name,
const char *transport_protocol, const char *transport_protocol,
gint port, gint port,
gboolean can_tel,
gboolean auto_connect) gboolean auto_connect)
{ {
g_return_if_fail (CALLS_IS_SIP_ORIGIN (self)); g_return_if_fail (CALLS_IS_SIP_ORIGIN (self));
@ -1509,5 +1531,7 @@ calls_sip_origin_set_credentials (CallsSipOrigin *self,
self->port = port; self->port = port;
self->can_tel = can_tel;
recreate_sip (self); recreate_sip (self);
} }

View file

@ -39,6 +39,7 @@ void calls_sip_origin_set_credentials (CallsSipOrigin *sel
const char *display_name, const char *display_name,
const char *transport_protocol, const char *transport_protocol,
gint port, gint port,
gboolean use_for_tel,
gboolean auto_connect); gboolean auto_connect);
G_END_DECLS G_END_DECLS

View file

@ -114,6 +114,7 @@ on_origin_pw_looked_up (GObject *source,
gint local_port = 0; gint local_port = 0;
gboolean auto_connect = TRUE; gboolean auto_connect = TRUE;
gboolean direct_mode = FALSE; gboolean direct_mode = FALSE;
gboolean can_tel = FALSE;
g_assert (user_data); g_assert (user_data);
@ -136,6 +137,10 @@ on_origin_pw_looked_up (GObject *source,
if (g_key_file_has_key (data->key_file, data->name, "DirectMode", NULL)) if (g_key_file_has_key (data->key_file, data->name, "DirectMode", NULL))
direct_mode = g_key_file_get_boolean (data->key_file, data->name, "DirectMode", NULL); direct_mode = g_key_file_get_boolean (data->key_file, data->name, "DirectMode", NULL);
if (g_key_file_has_key (data->key_file, data->name, "CanTel", NULL))
can_tel =
g_key_file_get_boolean (data->key_file, data->name, "CanTel", NULL);
/* PW */ /* PW */
password = secret_password_lookup_finish (result, &error); password = secret_password_lookup_finish (result, &error);
if (!direct_mode && error) { if (!direct_mode && error) {
@ -164,6 +169,7 @@ on_origin_pw_looked_up (GObject *source,
auto_connect, auto_connect,
direct_mode, direct_mode,
local_port, local_port,
can_tel,
FALSE); FALSE);
} }
static void static void
@ -265,6 +271,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
gint local_port; gint local_port;
gboolean auto_connect; gboolean auto_connect;
gboolean direct_mode; gboolean direct_mode;
gboolean can_tel;
g_assert (CALLS_IS_SIP_ORIGIN (origin)); g_assert (CALLS_IS_SIP_ORIGIN (origin));
g_assert (key_file); g_assert (key_file);
@ -279,6 +286,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
"auto-connect", &auto_connect, "auto-connect", &auto_connect,
"direct-mode", &direct_mode, "direct-mode", &direct_mode,
"local-port", &local_port, "local-port", &local_port,
"can-tel", &can_tel,
NULL); NULL);
g_key_file_set_string (key_file, name, "Host", host); g_key_file_set_string (key_file, name, "Host", host);
@ -289,6 +297,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
g_key_file_set_boolean (key_file, name, "AutoConnect", auto_connect); g_key_file_set_boolean (key_file, name, "AutoConnect", auto_connect);
g_key_file_set_boolean (key_file, name, "DirectMode", direct_mode); g_key_file_set_boolean (key_file, name, "DirectMode", direct_mode);
g_key_file_set_integer (key_file, name, "LocalPort", local_port); g_key_file_set_integer (key_file, name, "LocalPort", local_port);
g_key_file_set_boolean (key_file, name, "CanTel", can_tel);
label_secret = g_strdup_printf ("Calls Password for %s", label_secret = g_strdup_printf ("Calls Password for %s",
calls_account_get_address (CALLS_ACCOUNT (origin))); calls_account_get_address (CALLS_ACCOUNT (origin)));
@ -639,6 +648,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
TRUE, TRUE,
FALSE, FALSE,
0, 0,
FALSE,
store_credentials); store_credentials);
} }
@ -653,6 +663,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
* @auto_connect: Whether to automatically try going online * @auto_connect: Whether to automatically try going online
* @direct_mode: Whether to use direct connection mode. Useful when you don't want to * @direct_mode: Whether to use direct connection mode. Useful when you don't want to
* connect to a SIP server. Mostly useful for testing and debugging. * connect to a SIP server. Mostly useful for testing and debugging.
* @can_tel: Whether this origin can be used for PSTN telephony
* @store_credentials: Whether to store credentials for this origin to disk * @store_credentials: Whether to store credentials for this origin to disk
* *
* Adds a new origin (SIP account). If @direct_mode is %TRUE then @host, @user and * Adds a new origin (SIP account). If @direct_mode is %TRUE then @host, @user and
@ -671,6 +682,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
gboolean auto_connect, gboolean auto_connect,
gboolean direct_mode, gboolean direct_mode,
gint local_port, gint local_port,
gboolean can_tel,
gboolean store_credentials) gboolean store_credentials)
{ {
g_autoptr (CallsSipOrigin) origin = NULL; g_autoptr (CallsSipOrigin) origin = NULL;
@ -702,6 +714,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
"auto-connect", auto_connect, "auto-connect", auto_connect,
"direct-mode", direct_mode, "direct-mode", direct_mode,
"local-port", local_port, "local-port", local_port,
"can-tel", can_tel,
NULL); NULL);
g_list_store_append (self->origins, origin); g_list_store_append (self->origins, origin);

View file

@ -55,6 +55,7 @@ CallsSipOrigin *calls_sip_provider_add_origin_full (CallsSipProvider *s
gboolean auto_connect, gboolean auto_connect,
gboolean direct_mode, gboolean direct_mode,
gint local_port, gint local_port,
gboolean use_for_tel,
gboolean store_credentials); gboolean store_credentials);
gboolean calls_sip_provider_remove_origin (CallsSipProvider *self, gboolean calls_sip_provider_remove_origin (CallsSipProvider *self,
CallsSipOrigin *origin); CallsSipOrigin *origin);

View file

@ -371,6 +371,7 @@ setup_sip_origins (SipFixture *fixture,
FALSE, FALSE,
TRUE, TRUE,
5060, 5060,
FALSE,
FALSE); FALSE);
fixture->origin_bob = fixture->origin_bob =
@ -384,6 +385,7 @@ setup_sip_origins (SipFixture *fixture,
FALSE, FALSE,
TRUE, TRUE,
5061, 5061,
FALSE,
FALSE); FALSE);
fixture->origin_offline = fixture->origin_offline =
@ -397,6 +399,7 @@ setup_sip_origins (SipFixture *fixture,
FALSE, FALSE,
FALSE, FALSE,
0, 0,
FALSE,
FALSE); FALSE);
} }