[calls] sip: origin: Add property tracking usage for tel URIs
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] sip: origin: Add property tracking usage for tel URIs
- Date: Sun, 26 Dec 2021 21:06:05 +0000 (UTC)
commit fbbe17139db2861436ddc18da531b120b8c43cb3
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Fri Oct 29 02:39:29 2021 +0200
sip: origin: Add property tracking usage for tel URIs
Fixes #277
plugins/sip/calls-sip-account-widget.c | 1 +
plugins/sip/calls-sip-origin.c | 26 +++++++++++++++++++++++++-
plugins/sip/calls-sip-origin.h | 1 +
plugins/sip/calls-sip-provider.c | 13 +++++++++++++
plugins/sip/calls-sip-provider.h | 1 +
tests/test-sip.c | 3 +++
6 files changed, 44 insertions(+), 1 deletion(-)
---
diff --git a/plugins/sip/calls-sip-account-widget.c b/plugins/sip/calls-sip-account-widget.c
index f0de40a4..51995f60 100644
--- a/plugins/sip/calls-sip-account-widget.c
+++ b/plugins/sip/calls-sip-account-widget.c
@@ -397,6 +397,7 @@ on_apply_clicked (CallsSipAccountWidget *self)
gtk_entry_get_text (self->display_name),
get_selected_protocol (self),
get_port (self),
+ FALSE,
TRUE);
update_header (self);
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index f75878b6..04a823d3 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -74,6 +74,7 @@ enum {
PROP_ACC_ADDRESS,
PROP_CALLS,
PROP_COUNTRY_CODE,
+ PROP_CAN_TEL,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
@@ -109,6 +110,7 @@ struct _CallsSipOrigin
char *transport_protocol;
gboolean auto_connect;
gboolean direct_mode;
+ gboolean can_tel;
gint local_port;
const char *protocol_prefix;
@@ -1102,10 +1104,13 @@ supports_protocol (CallsOrigin *origin,
if (g_strcmp0 (protocol, "sip") == 0)
return TRUE;
+
if (g_strcmp0 (protocol, "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;
}
@@ -1184,6 +1189,10 @@ calls_sip_origin_set_property (GObject *object,
self->local_port = g_value_get_int (value);
break;
+ case PROP_CAN_TEL:
+ self->can_tel = g_value_get_boolean (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1256,6 +1265,10 @@ calls_sip_origin_get_property (GObject *object,
g_value_set_string (value, NULL);
break;
+ case PROP_CAN_TEL:
+ g_value_set_boolean (value, self->can_tel);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1407,6 +1420,14 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass)
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
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");
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 *transport_protocol,
gint port,
+ gboolean can_tel,
gboolean auto_connect)
{
g_return_if_fail (CALLS_IS_SIP_ORIGIN (self));
@@ -1509,5 +1531,7 @@ calls_sip_origin_set_credentials (CallsSipOrigin *self,
self->port = port;
+ self->can_tel = can_tel;
+
recreate_sip (self);
}
diff --git a/plugins/sip/calls-sip-origin.h b/plugins/sip/calls-sip-origin.h
index 5a14b3b6..b1c50c20 100644
--- a/plugins/sip/calls-sip-origin.h
+++ b/plugins/sip/calls-sip-origin.h
@@ -39,6 +39,7 @@ void calls_sip_origin_set_credentials (CallsSipOrigin *sel
const char *display_name,
const char *transport_protocol,
gint port,
+ gboolean use_for_tel,
gboolean auto_connect);
G_END_DECLS
diff --git a/plugins/sip/calls-sip-provider.c b/plugins/sip/calls-sip-provider.c
index faedf3e0..2c95820d 100644
--- a/plugins/sip/calls-sip-provider.c
+++ b/plugins/sip/calls-sip-provider.c
@@ -114,6 +114,7 @@ on_origin_pw_looked_up (GObject *source,
gint local_port = 0;
gboolean auto_connect = TRUE;
gboolean direct_mode = FALSE;
+ gboolean can_tel = FALSE;
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))
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 */
password = secret_password_lookup_finish (result, &error);
if (!direct_mode && error) {
@@ -164,6 +169,7 @@ on_origin_pw_looked_up (GObject *source,
auto_connect,
direct_mode,
local_port,
+ can_tel,
FALSE);
}
static void
@@ -265,6 +271,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
gint local_port;
gboolean auto_connect;
gboolean direct_mode;
+ gboolean can_tel;
g_assert (CALLS_IS_SIP_ORIGIN (origin));
g_assert (key_file);
@@ -279,6 +286,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
"auto-connect", &auto_connect,
"direct-mode", &direct_mode,
"local-port", &local_port,
+ "can-tel", &can_tel,
NULL);
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, "DirectMode", direct_mode);
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",
calls_account_get_address (CALLS_ACCOUNT (origin)));
@@ -639,6 +648,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
TRUE,
FALSE,
0,
+ FALSE,
store_credentials);
}
@@ -653,6 +663,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
* @auto_connect: Whether to automatically try going online
* @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.
+ * @can_tel: Whether this origin can be used for PSTN telephony
* @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
@@ -671,6 +682,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
gboolean auto_connect,
gboolean direct_mode,
gint local_port,
+ gboolean can_tel,
gboolean store_credentials)
{
g_autoptr (CallsSipOrigin) origin = NULL;
@@ -702,6 +714,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
"auto-connect", auto_connect,
"direct-mode", direct_mode,
"local-port", local_port,
+ "can-tel", can_tel,
NULL);
g_list_store_append (self->origins, origin);
diff --git a/plugins/sip/calls-sip-provider.h b/plugins/sip/calls-sip-provider.h
index 2d540331..fb0c4cde 100644
--- a/plugins/sip/calls-sip-provider.h
+++ b/plugins/sip/calls-sip-provider.h
@@ -55,6 +55,7 @@ CallsSipOrigin *calls_sip_provider_add_origin_full (CallsSipProvider *s
gboolean auto_connect,
gboolean direct_mode,
gint local_port,
+ gboolean use_for_tel,
gboolean store_credentials);
gboolean calls_sip_provider_remove_origin (CallsSipProvider *self,
CallsSipOrigin *origin);
diff --git a/tests/test-sip.c b/tests/test-sip.c
index 55083fa2..8a19cff2 100644
--- a/tests/test-sip.c
+++ b/tests/test-sip.c
@@ -371,6 +371,7 @@ setup_sip_origins (SipFixture *fixture,
FALSE,
TRUE,
5060,
+ FALSE,
FALSE);
fixture->origin_bob =
@@ -384,6 +385,7 @@ setup_sip_origins (SipFixture *fixture,
FALSE,
TRUE,
5061,
+ FALSE,
FALSE);
fixture->origin_offline =
@@ -397,6 +399,7 @@ setup_sip_origins (SipFixture *fixture,
FALSE,
FALSE,
0,
+ FALSE,
FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]