[calls] origin: Add "numeric-addresses" property



commit c7731b189ab051c4fa33b51171e43b4f43b4d849
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Sat Jul 17 15:25:16 2021 +0200

    origin: Add "numeric-addresses" property
    
    This will be useful in the dialpad to determine whether we should allow
    only numeric input or not.

 plugins/dummy/calls-dummy-origin.c |  6 ++++++
 plugins/mm/calls-mm-origin.c       |  6 ++++++
 plugins/ofono/calls-ofono-origin.c |  6 ++++++
 plugins/sip/calls-sip-origin.c     |  6 ++++++
 src/calls-origin.c                 | 25 +++++++++++++++++++++++++
 src/calls-origin.h                 |  1 +
 6 files changed, 50 insertions(+)
---
diff --git a/plugins/dummy/calls-dummy-origin.c b/plugins/dummy/calls-dummy-origin.c
index b0e1b897..73671460 100644
--- a/plugins/dummy/calls-dummy-origin.c
+++ b/plugins/dummy/calls-dummy-origin.c
@@ -59,6 +59,7 @@ enum {
 
   PROP_CALLS,
   PROP_COUNTRY_CODE,
+  PROP_NUMERIC,
   PROP_LAST_PROP,
 };
 static GParamSpec *props[PROP_LAST_PROP];
@@ -214,6 +215,10 @@ get_property (GObject      *object,
     g_value_set_string (value, NULL);
     break;
 
+  case PROP_NUMERIC:
+    g_value_set_boolean (value, TRUE);
+    break;
+
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     break;
@@ -269,6 +274,7 @@ calls_dummy_origin_class_init (CallsDummyOriginClass *klass)
   IMPLEMENTS (PROP_NAME, "name");
   IMPLEMENTS (PROP_CALLS, "calls");
   IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
+  IMPLEMENTS (PROP_NUMERIC, "numeric-addresses");
 
 #undef IMPLEMENTS
 }
diff --git a/plugins/mm/calls-mm-origin.c b/plugins/mm/calls-mm-origin.c
index 647a4e22..5e30bb80 100644
--- a/plugins/mm/calls-mm-origin.c
+++ b/plugins/mm/calls-mm-origin.c
@@ -72,6 +72,7 @@ enum {
   PROP_CALLS,
   PROP_MODEM,
   PROP_COUNTRY_CODE,
+  PROP_NUMERIC,
   PROP_LAST_PROP,
 };
 static GParamSpec *props[PROP_LAST_PROP];
@@ -666,6 +667,10 @@ get_property (GObject      *object,
     g_value_set_string (value, self->country_code);
     break;
 
+  case PROP_NUMERIC:
+    g_value_set_boolean (value, TRUE);
+    break;
+
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     break;
@@ -881,6 +886,7 @@ calls_mm_origin_class_init (CallsMMOriginClass *klass)
   IMPLEMENTS (PROP_NAME, "name");
   IMPLEMENTS (PROP_CALLS, "calls");
   IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
+  IMPLEMENTS (PROP_NUMERIC, "numeric-addresses");
 
 #undef IMPLEMENTS
 
diff --git a/plugins/ofono/calls-ofono-origin.c b/plugins/ofono/calls-ofono-origin.c
index a97cfff5..abfe6af3 100644
--- a/plugins/ofono/calls-ofono-origin.c
+++ b/plugins/ofono/calls-ofono-origin.c
@@ -59,6 +59,7 @@ enum {
   PROP_CALLS,
   PROP_MODEM,
   PROP_COUNTRY_CODE,
+  PROP_NUMERIC,
   PROP_LAST_PROP,
 };
 static GParamSpec *props[PROP_LAST_PROP];
@@ -176,6 +177,10 @@ get_property (GObject      *object,
     g_value_set_string (value, NULL);
     break;
 
+  case PROP_NUMERIC:
+    g_value_set_boolean (value, TRUE);
+    break;
+
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     break;
@@ -572,6 +577,7 @@ calls_ofono_origin_class_init (CallsOfonoOriginClass *klass)
   IMPLEMENTS (PROP_NAME, "name");
   IMPLEMENTS (PROP_CALLS, "calls");
   IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
+  IMPLEMENTS (PROP_NUMERIC, "numeric-addresses");
 
 #undef IMPLEMENTS
 
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index ceac592b..1557e77d 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -73,6 +73,7 @@ enum {
   PROP_ACC_ADDRESS,
   PROP_CALLS,
   PROP_COUNTRY_CODE,
+  PROP_NUMERIC,
   PROP_LAST_PROP,
 };
 static GParamSpec *props[PROP_LAST_PROP];
@@ -1184,6 +1185,10 @@ calls_sip_origin_get_property (GObject      *object,
     g_value_set_string (value, NULL);
     break;
 
+  case PROP_NUMERIC:
+    g_value_set_boolean (value, FALSE);
+    break;
+
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     break;
@@ -1365,6 +1370,7 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass)
   IMPLEMENTS (PROP_NAME, "name");
   IMPLEMENTS (PROP_CALLS, "calls");
   IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
+  IMPLEMENTS (PROP_NUMERIC, "numeric-addresses");
 
 #undef IMPLEMENTS
 }
diff --git a/src/calls-origin.c b/src/calls-origin.c
index 82bbdc64..9eb0de36 100644
--- a/src/calls-origin.c
+++ b/src/calls-origin.c
@@ -70,6 +70,14 @@ calls_origin_default_init (CallsOriginInterface *iface)
                          NULL,
                          G_PARAM_READABLE));
 
+  g_object_interface_install_property (
+    iface,
+    g_param_spec_boolean ("numeric-addresses",
+                          "Numeric addresses",
+                          "Whether this origin can only dial numeric addresses (aka numbers)",
+                          TRUE,
+                          G_PARAM_READABLE));
+
   signals[SIGNAL_CALL_ADDED] =
     g_signal_newv ("call-added",
                   G_TYPE_FROM_INTERFACE (iface),
@@ -113,6 +121,23 @@ DEFINE_ORIGIN_GETTER(name, char *, NULL);
  */
 DEFINE_ORIGIN_GETTER(calls, GList *, NULL);
 
+/**
+ * calls_origin_get_numeric_addresses:
+ * @self: a #CallsOrigin
+ *
+ * Returns: %TRUE if this origin can only dial numeric addresses (i.e. telephone numbers),
+ * %FALSE otherwise.
+ */
+gboolean
+calls_origin_get_numeric_addresses (CallsOrigin *origin)
+{
+  gboolean numeric;
+
+  g_return_val_if_fail (CALLS_IS_ORIGIN (origin), FALSE);
+
+  g_object_get (origin, "numeric-addresses", &numeric, NULL);
+  return numeric;
+}
 
 /**
  * calls_origin_foreach_call:
diff --git a/src/calls-origin.h b/src/calls-origin.h
index d237fd34..3461e84a 100644
--- a/src/calls-origin.h
+++ b/src/calls-origin.h
@@ -52,6 +52,7 @@ typedef void (*CallsOriginForeachCallFunc) (gpointer param, CallsCall* call, Cal
 
 char *                 calls_origin_get_name                (CallsOrigin *self);
 GList *                calls_origin_get_calls               (CallsOrigin *self);
+gboolean               calls_origin_get_numeric_addresses   (CallsOrigin *self);
 void                   calls_origin_foreach_call            (CallsOrigin *self,
                                                              CallsOriginForeachCallFunc callback,
                                                              gpointer     param);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]