diff --git a/data/sm.puri.Calls.gschema.xml b/data/sm.puri.Calls.gschema.xml
index 806be34..c957571 100644
--- a/data/sm.puri.Calls.gschema.xml
+++ b/data/sm.puri.Calls.gschema.xml
@@ -8,5 +8,11 @@
Whether calls should automatically use the default origin
+
+ ''
+ The country code as reported by the modem
+ The country code is used for contact name lookup
+
+
diff --git a/src/calls-application.c b/src/calls-application.c
index 308a3df..d040abc 100644
--- a/src/calls-application.c
+++ b/src/calls-application.c
@@ -300,6 +300,8 @@ startup (GApplication *application)
{
g_autoptr (GtkCssProvider) provider = NULL;
g_autoptr (GError) error = NULL;
+ CallsApplication *self = CALLS_APPLICATION (application);
+ CallsManager *manager;
G_APPLICATION_CLASS (calls_application_parent_class)->startup (application);
@@ -318,7 +320,14 @@ startup (GApplication *application)
G_N_ELEMENTS (actions),
application);
- g_signal_connect_swapped (calls_manager_get_default (),
+ self->settings = calls_settings_new ();
+ g_assert (self->settings != NULL);
+
+ manager = calls_manager_get_default ();
+ g_object_bind_property (self->settings, "country-code",
+ manager, "country-code",
+ G_BINDING_SYNC_CREATE);
+ g_signal_connect_swapped (manager,
"notify::state",
G_CALLBACK (manager_state_changed_cb),
application);
@@ -377,9 +386,6 @@ start_proper (CallsApplication *self)
self->call_window = calls_call_window_new (gtk_app);
g_assert (self->call_window != NULL);
- self->settings = calls_settings_new ();
- g_assert (self->settings != NULL);
-
g_signal_connect (self->call_window,
"notify::visible",
G_CALLBACK (notify_window_visible_cb),
@@ -617,3 +623,20 @@ calls_application_set_use_default_origins_setting (CallsApplication *self,
calls_settings_set_use_default_origins (self->settings, enabled);
}
+
+char *
+calls_application_get_country_code_setting (CallsApplication *self)
+{
+ g_return_val_if_fail (CALLS_IS_APPLICATION (self), FALSE);
+
+ return calls_settings_get_country_code (self->settings);
+}
+
+void
+calls_application_set_country_code_setting (CallsApplication *self,
+ const char *country_code)
+{
+ g_return_if_fail (CALLS_IS_APPLICATION (self));
+
+ calls_settings_set_country_code (self->settings, country_code);
+}
diff --git a/src/calls-application.h b/src/calls-application.h
index 361fb74..cf4dff6 100644
--- a/src/calls-application.h
+++ b/src/calls-application.h
@@ -37,5 +37,8 @@ CallsApplication *calls_application_new (void);
gboolean calls_application_get_use_default_origins_setting (CallsApplication *self);
void calls_application_set_use_default_origins_setting (CallsApplication *self,
gboolean enabled);
+char *calls_application_get_country_code_setting (CallsApplication *self);
+void calls_application_set_country_code_setting (CallsApplication *self,
+ const char *country_code);
G_END_DECLS
diff --git a/src/calls-settings.c b/src/calls-settings.c
index c6aef96..1506f96 100644
--- a/src/calls-settings.c
+++ b/src/calls-settings.c
@@ -39,6 +39,7 @@
enum {
PROP_0,
PROP_AUTO_USE_DEFAULT_ORIGINS,
+ PROP_COUNTRY_CODE,
PROP_LAST_PROP
};
static GParamSpec *props[PROP_LAST_PROP];
@@ -65,6 +66,10 @@ calls_settings_set_property (GObject *object,
calls_settings_set_use_default_origins (self, g_value_get_boolean (value));
break;
+ case PROP_COUNTRY_CODE:
+ calls_settings_set_country_code (self, g_value_get_string (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -85,6 +90,10 @@ calls_settings_get_property (GObject *object,
g_value_set_boolean (value, calls_settings_get_use_default_origins (self));
break;
+ case PROP_COUNTRY_CODE:
+ g_value_set_string (value, calls_settings_get_country_code (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -131,6 +140,12 @@ calls_settings_class_init (CallsSettingsClass *klass)
"Automatically use default origins",
TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ props[PROP_COUNTRY_CODE] =
+ g_param_spec_string ("country-code",
+ "country code",
+ "The country code (usually from the modem)",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
}
@@ -184,3 +199,36 @@ calls_settings_set_use_default_origins (CallsSettings *self,
g_debug ("%sabling the use of default origins", enable ? "En" : "Dis");
g_settings_set_boolean (G_SETTINGS (self->settings), "auto-use-default-origins", enable);
}
+
+/**
+ * calls_settings_get_country_code:
+ * @self: A #CallsSettings
+ *
+ * Whether to prompt the user when there multiple origigins or fall back to defaults
+ *
+ * Returns: (transfer full): The used country code
+ */
+char *
+calls_settings_get_country_code (CallsSettings *self)
+{
+ g_return_val_if_fail (CALLS_IS_SETTINGS (self), NULL);
+
+ return g_settings_get_string (G_SETTINGS (self->settings), "country-code");
+}
+
+/**
+ * calls_settings_set_country_code:
+ * @self: A #CallsSettings
+ * @country_code: The country code to set
+ *
+ * Sets the country code
+ */
+void
+calls_settings_set_country_code (CallsSettings *self,
+ const char *country_code)
+{
+ g_return_if_fail (CALLS_IS_SETTINGS (self));
+
+ g_debug ("Setting country code to %s", country_code);
+ g_settings_set_string (G_SETTINGS (self->settings), "country-code", country_code);
+}
diff --git a/src/calls-settings.h b/src/calls-settings.h
index 6ec602f..57c9b7d 100644
--- a/src/calls-settings.h
+++ b/src/calls-settings.h
@@ -36,6 +36,9 @@ CallsSettings *calls_settings_new (void);
gboolean calls_settings_get_use_default_origins (CallsSettings *self);
void calls_settings_set_use_default_origins (CallsSettings *self,
gboolean enable);
+char *calls_settings_get_country_code (CallsSettings *self);
+void calls_settings_set_country_code (CallsSettings *self,
+ const char *country_code);
G_END_DECLS