mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
Simplify country code handling
This commit is contained in:
parent
04d391c5dd
commit
33ad4dbe86
8 changed files with 55 additions and 165 deletions
|
@ -38,7 +38,6 @@
|
||||||
#include "calls-call-window.h"
|
#include "calls-call-window.h"
|
||||||
#include "calls-main-window.h"
|
#include "calls-main-window.h"
|
||||||
#include "calls-manager.h"
|
#include "calls-manager.h"
|
||||||
#include "calls-settings.h"
|
|
||||||
#include "calls-application.h"
|
#include "calls-application.h"
|
||||||
#include "calls-log.h"
|
#include "calls-log.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -61,13 +60,11 @@ struct _CallsApplication
|
||||||
GtkApplication parent_instance;
|
GtkApplication parent_instance;
|
||||||
|
|
||||||
gboolean daemon;
|
gboolean daemon;
|
||||||
CallsManager *manager;
|
|
||||||
CallsRinger *ringer;
|
CallsRinger *ringer;
|
||||||
CallsNotifier *notifier;
|
CallsNotifier *notifier;
|
||||||
CallsRecordStore *record_store;
|
CallsRecordStore *record_store;
|
||||||
CallsMainWindow *main_window;
|
CallsMainWindow *main_window;
|
||||||
CallsCallWindow *call_window;
|
CallsCallWindow *call_window;
|
||||||
CallsSettings *settings;
|
|
||||||
CallsDBusManager *dbus_manager;
|
CallsDBusManager *dbus_manager;
|
||||||
|
|
||||||
char *uri;
|
char *uri;
|
||||||
|
@ -164,18 +161,19 @@ set_default_providers_action (GSimpleAction *action,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CallsApplication *self = CALLS_APPLICATION (user_data);
|
CallsManager *manager = calls_manager_get_default ();
|
||||||
|
CallsSettings *settings = calls_manager_get_settings (manager);
|
||||||
g_auto (GStrv) plugins = NULL;
|
g_auto (GStrv) plugins = NULL;
|
||||||
/**
|
/**
|
||||||
* Only add default providers when there are none added yet,
|
* Only add default providers when there are none added yet,
|
||||||
* This makes sure we're not resetting explicitly set providers
|
* This makes sure we're not resetting explicitly set providers
|
||||||
*/
|
*/
|
||||||
if (calls_manager_has_any_provider (calls_manager_get_default ()))
|
if (calls_manager_has_any_provider (manager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
plugins = calls_settings_get_autoload_plugins (self->settings);
|
plugins = calls_settings_get_autoload_plugins (settings);
|
||||||
for (guint i = 0; plugins[i] != NULL; i++) {
|
for (guint i = 0; plugins[i] != NULL; i++) {
|
||||||
calls_manager_add_provider (calls_manager_get_default (), plugins[i]);
|
calls_manager_add_provider (manager, plugins[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,8 +358,6 @@ startup (GApplication *application)
|
||||||
{
|
{
|
||||||
g_autoptr (GtkCssProvider) provider = NULL;
|
g_autoptr (GtkCssProvider) provider = NULL;
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
CallsApplication *self = CALLS_APPLICATION (application);
|
|
||||||
CallsManager *manager;
|
|
||||||
|
|
||||||
G_APPLICATION_CLASS (calls_application_parent_class)->startup (application);
|
G_APPLICATION_CLASS (calls_application_parent_class)->startup (application);
|
||||||
|
|
||||||
|
@ -380,14 +376,7 @@ startup (GApplication *application)
|
||||||
G_N_ELEMENTS (actions),
|
G_N_ELEMENTS (actions),
|
||||||
application);
|
application);
|
||||||
|
|
||||||
self->settings = calls_settings_new ();
|
g_signal_connect_swapped (calls_manager_get_default (),
|
||||||
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",
|
"notify::state",
|
||||||
G_CALLBACK (manager_state_changed_cb),
|
G_CALLBACK (manager_state_changed_cb),
|
||||||
application);
|
application);
|
||||||
|
@ -631,7 +620,6 @@ finalize (GObject *object)
|
||||||
g_clear_object (&self->record_store);
|
g_clear_object (&self->record_store);
|
||||||
g_clear_object (&self->ringer);
|
g_clear_object (&self->ringer);
|
||||||
g_clear_object (&self->notifier);
|
g_clear_object (&self->notifier);
|
||||||
g_clear_object (&self->settings);
|
|
||||||
g_free (self->uri);
|
g_free (self->uri);
|
||||||
|
|
||||||
G_OBJECT_CLASS (calls_application_parent_class)->finalize (object);
|
G_OBJECT_CLASS (calls_application_parent_class)->finalize (object);
|
||||||
|
@ -712,37 +700,3 @@ calls_application_new (void)
|
||||||
"register-session", TRUE,
|
"register-session", TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
calls_application_get_use_default_origins_setting (CallsApplication *self)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (CALLS_IS_APPLICATION (self), FALSE);
|
|
||||||
|
|
||||||
return calls_settings_get_use_default_origins (self->settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
calls_application_set_use_default_origins_setting (CallsApplication *self,
|
|
||||||
gboolean enabled)
|
|
||||||
{
|
|
||||||
g_return_if_fail (CALLS_IS_APPLICATION (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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,11 +34,5 @@ G_BEGIN_DECLS
|
||||||
G_DECLARE_FINAL_TYPE (CallsApplication, calls_application, CALLS, APPLICATION, GtkApplication)
|
G_DECLARE_FINAL_TYPE (CallsApplication, calls_application, CALLS, APPLICATION, GtkApplication)
|
||||||
|
|
||||||
CallsApplication *calls_application_new (void);
|
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
|
G_END_DECLS
|
||||||
|
|
|
@ -135,7 +135,6 @@ set_property (GObject *object,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
CallsBestMatch *self = CALLS_BEST_MATCH (object);
|
CallsBestMatch *self = CALLS_BEST_MATCH (object);
|
||||||
const char *country_code;
|
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
case PROP_PHONE_NUMBER:
|
case PROP_PHONE_NUMBER:
|
||||||
|
@ -143,15 +142,12 @@ set_property (GObject *object,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_COUNTRY_CODE:
|
case PROP_COUNTRY_CODE:
|
||||||
country_code = g_value_get_string (value);
|
g_free (self->country_code);
|
||||||
if (country_code) {
|
self->country_code = g_value_dup_string (value);
|
||||||
g_free (self->country_code);
|
|
||||||
self->country_code = g_strdup (country_code);
|
|
||||||
|
|
||||||
if (self->phone_number) {
|
if (self->phone_number) {
|
||||||
g_autofree char *number = g_strdup (self->phone_number);
|
g_autofree char *number = g_strdup (self->phone_number);
|
||||||
calls_best_match_set_phone_number (self, number);
|
calls_best_match_set_phone_number (self, number);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -273,9 +269,6 @@ calls_best_match_class_init (CallsBestMatchClass *klass)
|
||||||
static void
|
static void
|
||||||
calls_best_match_init (CallsBestMatch *self)
|
calls_best_match_init (CallsBestMatch *self)
|
||||||
{
|
{
|
||||||
g_object_bind_property (calls_manager_get_default (), "country-code",
|
|
||||||
self, "country-code",
|
|
||||||
G_BINDING_SYNC_CREATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -307,24 +300,15 @@ calls_best_match_get_phone_number (CallsBestMatch *self)
|
||||||
|
|
||||||
void
|
void
|
||||||
calls_best_match_set_phone_number (CallsBestMatch *self,
|
calls_best_match_set_phone_number (CallsBestMatch *self,
|
||||||
const char *phone_number)
|
const char *phone_number)
|
||||||
{
|
{
|
||||||
g_autoptr (EPhoneNumber) number = NULL;
|
g_autoptr (EPhoneNumber) number = NULL;
|
||||||
g_autoptr (CallsPhoneNumberQuery) query = NULL;
|
g_autoptr (CallsPhoneNumberQuery) query = NULL;
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
gboolean have_country_code_now = FALSE;
|
|
||||||
|
|
||||||
g_return_if_fail (CALLS_IS_BEST_MATCH (self));
|
g_return_if_fail (CALLS_IS_BEST_MATCH (self));
|
||||||
g_return_if_fail (phone_number);
|
g_return_if_fail (phone_number);
|
||||||
|
|
||||||
have_country_code_now = !!self->country_code;
|
|
||||||
|
|
||||||
if (self->phone_number == phone_number &&
|
|
||||||
self->had_country_code_last_time == have_country_code_now)
|
|
||||||
return;
|
|
||||||
|
|
||||||
self->had_country_code_last_time = have_country_code_now;
|
|
||||||
|
|
||||||
g_clear_pointer (&self->phone_number, g_free);
|
g_clear_pointer (&self->phone_number, g_free);
|
||||||
|
|
||||||
// Consider empty string phone numbers as NULL
|
// Consider empty string phone numbers as NULL
|
||||||
|
|
|
@ -48,16 +48,16 @@ struct _CallsContactsProvider
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
FolksIndividualAggregator *folks_aggregator;
|
FolksIndividualAggregator *folks_aggregator;
|
||||||
|
CallsSettings *settings;
|
||||||
|
|
||||||
GHashTable *phone_number_best_matches;
|
GHashTable *phone_number_best_matches;
|
||||||
gchar *country_code;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CallsContactsProvider, calls_contacts_provider, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (CallsContactsProvider, calls_contacts_provider, G_TYPE_OBJECT)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_COUNTRY_CODE,
|
PROP_SETTINGS,
|
||||||
PROP_LAST_PROP
|
PROP_LAST_PROP
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
@ -177,28 +177,8 @@ calls_contacts_provider_set_property (GObject *object,
|
||||||
CallsContactsProvider *self = CALLS_CONTACTS_PROVIDER (object);
|
CallsContactsProvider *self = CALLS_CONTACTS_PROVIDER (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
case PROP_COUNTRY_CODE:
|
case PROP_SETTINGS:
|
||||||
g_free (self->country_code);
|
self->settings = g_value_dup_object (value);
|
||||||
self->country_code = g_value_dup_string (value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
calls_contacts_provider_get_property (GObject *object,
|
|
||||||
guint property_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
CallsContactsProvider *self = CALLS_CONTACTS_PROVIDER (object);
|
|
||||||
|
|
||||||
switch (property_id) {
|
|
||||||
case PROP_COUNTRY_CODE:
|
|
||||||
g_value_set_string (value, self->country_code);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -213,8 +193,8 @@ calls_contacts_provider_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CallsContactsProvider *self = CALLS_CONTACTS_PROVIDER (object);
|
CallsContactsProvider *self = CALLS_CONTACTS_PROVIDER (object);
|
||||||
|
|
||||||
g_clear_object (&self->country_code);
|
|
||||||
g_clear_object (&self->folks_aggregator);
|
g_clear_object (&self->folks_aggregator);
|
||||||
|
g_clear_object (&self->settings);
|
||||||
g_clear_pointer (&self->phone_number_best_matches, g_hash_table_unref);
|
g_clear_pointer (&self->phone_number_best_matches, g_hash_table_unref);
|
||||||
|
|
||||||
G_OBJECT_CLASS (calls_contacts_provider_parent_class)->finalize (object);
|
G_OBJECT_CLASS (calls_contacts_provider_parent_class)->finalize (object);
|
||||||
|
@ -226,7 +206,6 @@ calls_contacts_provider_class_init (CallsContactsProviderClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->get_property = calls_contacts_provider_get_property;
|
|
||||||
object_class->set_property = calls_contacts_provider_set_property;
|
object_class->set_property = calls_contacts_provider_set_property;
|
||||||
object_class->finalize = calls_contacts_provider_finalize;
|
object_class->finalize = calls_contacts_provider_finalize;
|
||||||
|
|
||||||
|
@ -250,11 +229,13 @@ calls_contacts_provider_class_init (CallsContactsProviderClass *klass)
|
||||||
1,
|
1,
|
||||||
FOLKS_TYPE_INDIVIDUAL);
|
FOLKS_TYPE_INDIVIDUAL);
|
||||||
|
|
||||||
props[PROP_COUNTRY_CODE] = g_param_spec_string ("country-code",
|
props[PROP_SETTINGS] =
|
||||||
"country code",
|
g_param_spec_object ("settings",
|
||||||
"The default country code to use",
|
"settings",
|
||||||
NULL,
|
"The settings object to use",
|
||||||
G_PARAM_READWRITE);
|
CALLS_TYPE_SETTINGS,
|
||||||
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||||
}
|
}
|
||||||
|
@ -287,9 +268,9 @@ calls_contacts_provider_init (CallsContactsProvider *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
CallsContactsProvider *
|
CallsContactsProvider *
|
||||||
calls_contacts_provider_new (void)
|
calls_contacts_provider_new (CallsSettings *settings)
|
||||||
{
|
{
|
||||||
return g_object_new (CALLS_TYPE_CONTACTS_PROVIDER, NULL);
|
return g_object_new (CALLS_TYPE_CONTACTS_PROVIDER, "settings", settings, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,7 +302,6 @@ calls_contacts_provider_lookup_phone_number (CallsContactsProvider *self,
|
||||||
const gchar *number)
|
const gchar *number)
|
||||||
{
|
{
|
||||||
g_autoptr (CallsBestMatch) best_match = NULL;
|
g_autoptr (CallsBestMatch) best_match = NULL;
|
||||||
g_autofree gchar *country_code = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CALLS_IS_CONTACTS_PROVIDER (self), NULL);
|
g_return_val_if_fail (CALLS_IS_CONTACTS_PROVIDER (self), NULL);
|
||||||
|
|
||||||
|
@ -330,15 +310,15 @@ calls_contacts_provider_lookup_phone_number (CallsContactsProvider *self,
|
||||||
if (best_match) {
|
if (best_match) {
|
||||||
g_object_ref (best_match);
|
g_object_ref (best_match);
|
||||||
|
|
||||||
g_object_get (best_match, "country-code", &country_code, NULL);
|
|
||||||
if (g_strcmp0 (country_code, self->country_code) != 0)
|
|
||||||
calls_best_match_set_phone_number (best_match, number);
|
|
||||||
|
|
||||||
return g_steal_pointer (&best_match);
|
return g_steal_pointer (&best_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
best_match = calls_best_match_new (number);
|
best_match = calls_best_match_new (number);
|
||||||
|
|
||||||
|
g_object_bind_property (self->settings, "country-code",
|
||||||
|
best_match, "country-code",
|
||||||
|
G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
g_hash_table_insert (self->phone_number_best_matches, g_strdup (number), g_object_ref (best_match));
|
g_hash_table_insert (self->phone_number_best_matches, g_strdup (number), g_object_ref (best_match));
|
||||||
|
|
||||||
return g_steal_pointer (&best_match);
|
return g_steal_pointer (&best_match);
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "calls-settings.h"
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <folks/folks.h>
|
#include <folks/folks.h>
|
||||||
#include <libebook-contacts/libebook-contacts.h>
|
#include <libebook-contacts/libebook-contacts.h>
|
||||||
|
@ -48,7 +50,7 @@ typedef void (*IdleCallback) (gpointer user_data,
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CallsContactsProvider, calls_contacts_provider, CALLS, CONTACTS_PROVIDER, GObject)
|
G_DECLARE_FINAL_TYPE (CallsContactsProvider, calls_contacts_provider, CALLS, CONTACTS_PROVIDER, GObject)
|
||||||
|
|
||||||
CallsContactsProvider *calls_contacts_provider_new (void);
|
CallsContactsProvider *calls_contacts_provider_new (CallsSettings *settings);
|
||||||
GeeCollection *calls_contacts_provider_get_individuals (CallsContactsProvider *self);
|
GeeCollection *calls_contacts_provider_get_individuals (CallsContactsProvider *self);
|
||||||
CallsBestMatch *calls_contacts_provider_lookup_phone_number (CallsContactsProvider *self,
|
CallsBestMatch *calls_contacts_provider_lookup_phone_number (CallsContactsProvider *self,
|
||||||
const gchar *number);
|
const gchar *number);
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "calls-contacts-provider.h"
|
#include "calls-contacts-provider.h"
|
||||||
#include "calls-manager.h"
|
#include "calls-manager.h"
|
||||||
#include "calls-provider.h"
|
#include "calls-provider.h"
|
||||||
|
#include "calls-settings.h"
|
||||||
#include "calls-ussd.h"
|
#include "calls-ussd.h"
|
||||||
|
|
||||||
#include "enum-types.h"
|
#include "enum-types.h"
|
||||||
|
@ -58,7 +59,7 @@ struct _CallsManager
|
||||||
|
|
||||||
CallsManagerState state;
|
CallsManagerState state;
|
||||||
CallsCall *primary_call;
|
CallsCall *primary_call;
|
||||||
char *country_code;
|
CallsSettings *settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CallsManager, calls_manager, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (CallsManager, calls_manager, G_TYPE_OBJECT);
|
||||||
|
@ -66,7 +67,6 @@ G_DEFINE_TYPE (CallsManager, calls_manager, G_TYPE_OBJECT);
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_STATE,
|
PROP_STATE,
|
||||||
PROP_COUNTRY_CODE,
|
|
||||||
PROP_LAST_PROP,
|
PROP_LAST_PROP,
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
@ -258,20 +258,16 @@ update_country_code_cb (CallsOrigin *origin,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
CallsManager *self)
|
CallsManager *self)
|
||||||
{
|
{
|
||||||
CallsApplication *app;
|
|
||||||
g_autofree char *country_code = NULL;
|
g_autofree char *country_code = NULL;
|
||||||
|
|
||||||
g_assert (CALLS_IS_MANAGER (self));
|
g_assert (CALLS_IS_MANAGER (self));
|
||||||
app = CALLS_APPLICATION (g_application_get_default ());
|
|
||||||
|
|
||||||
g_object_get (G_OBJECT (origin), "country-code", &country_code, NULL);
|
g_object_get (G_OBJECT (origin), "country-code", &country_code, NULL);
|
||||||
|
|
||||||
if (country_code && g_strcmp0 (country_code, self->country_code) == 0)
|
if (!country_code || !*country_code)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_free (self->country_code);
|
calls_settings_set_country_code (self->settings, country_code);
|
||||||
self->country_code = country_code;
|
|
||||||
calls_application_set_country_code_setting (app, country_code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -547,35 +543,12 @@ calls_manager_get_property (GObject *object,
|
||||||
g_value_set_enum (value, calls_manager_get_state (self));
|
g_value_set_enum (value, calls_manager_get_state (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_COUNTRY_CODE:
|
|
||||||
g_value_set_string (value, self->country_code);
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
calls_manager_set_property (GObject *object,
|
|
||||||
guint property_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
CallsManager *self = CALLS_MANAGER (object);
|
|
||||||
|
|
||||||
switch (property_id) {
|
|
||||||
case PROP_COUNTRY_CODE:
|
|
||||||
g_free (self->country_code);
|
|
||||||
self->country_code = g_value_dup_string (value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
calls_manager_finalize (GObject *object)
|
calls_manager_finalize (GObject *object)
|
||||||
|
@ -584,7 +557,7 @@ calls_manager_finalize (GObject *object)
|
||||||
|
|
||||||
g_clear_object (&self->origins);
|
g_clear_object (&self->origins);
|
||||||
g_clear_object (&self->contacts_provider);
|
g_clear_object (&self->contacts_provider);
|
||||||
g_clear_pointer (&self->country_code, g_free);
|
g_clear_object (&self->settings);
|
||||||
|
|
||||||
g_clear_pointer (&self->providers, g_hash_table_unref);
|
g_clear_pointer (&self->providers, g_hash_table_unref);
|
||||||
g_clear_pointer (&self->origins_by_protocol, g_hash_table_unref);
|
g_clear_pointer (&self->origins_by_protocol, g_hash_table_unref);
|
||||||
|
@ -600,7 +573,6 @@ calls_manager_class_init (CallsManagerClass *klass)
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->get_property = calls_manager_get_property;
|
object_class->get_property = calls_manager_get_property;
|
||||||
object_class->set_property = calls_manager_set_property;
|
|
||||||
object_class->finalize = calls_manager_finalize;
|
object_class->finalize = calls_manager_finalize;
|
||||||
|
|
||||||
signals[SIGNAL_CALL_ADD] =
|
signals[SIGNAL_CALL_ADD] =
|
||||||
|
@ -683,12 +655,6 @@ calls_manager_class_init (CallsManagerClass *klass)
|
||||||
CALLS_MANAGER_STATE_NO_PROVIDER,
|
CALLS_MANAGER_STATE_NO_PROVIDER,
|
||||||
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
|
||||||
|
|
||||||
props[PROP_COUNTRY_CODE] = g_param_spec_string ("country-code",
|
|
||||||
"country code",
|
|
||||||
"The default country code to use",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READWRITE);
|
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,11 +680,9 @@ calls_manager_init (CallsManager *self)
|
||||||
self->origins = g_list_store_new (calls_origin_get_type ());
|
self->origins = g_list_store_new (calls_origin_get_type ());
|
||||||
self->supported_protocols = g_ptr_array_new_full (5, g_free);
|
self->supported_protocols = g_ptr_array_new_full (5, g_free);
|
||||||
|
|
||||||
|
self->settings = calls_settings_new ();
|
||||||
// Load the contacts provider
|
// Load the contacts provider
|
||||||
self->contacts_provider = calls_contacts_provider_new ();
|
self->contacts_provider = calls_contacts_provider_new (self->settings);
|
||||||
g_object_bind_property (self, "country-code",
|
|
||||||
self->contacts_provider, "country-code",
|
|
||||||
G_BINDING_DEFAULT);
|
|
||||||
|
|
||||||
peas = peas_engine_get_default ();
|
peas = peas_engine_get_default ();
|
||||||
|
|
||||||
|
@ -982,3 +946,12 @@ calls_manager_get_providers (CallsManager *self)
|
||||||
|
|
||||||
return g_hash_table_get_values (self->providers);
|
return g_hash_table_get_values (self->providers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CallsSettings *
|
||||||
|
calls_manager_get_settings (CallsManager *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CALLS_IS_MANAGER (self), NULL);
|
||||||
|
|
||||||
|
return self->settings;
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "calls-contacts-provider.h"
|
#include "calls-contacts-provider.h"
|
||||||
#include "calls-origin.h"
|
#include "calls-origin.h"
|
||||||
|
#include "calls-settings.h"
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ typedef enum
|
||||||
CallsManager *calls_manager_new (void);
|
CallsManager *calls_manager_new (void);
|
||||||
CallsManager *calls_manager_get_default (void);
|
CallsManager *calls_manager_get_default (void);
|
||||||
CallsContactsProvider *calls_manager_get_contacts_provider (CallsManager *self);
|
CallsContactsProvider *calls_manager_get_contacts_provider (CallsManager *self);
|
||||||
|
CallsSettings *calls_manager_get_settings (CallsManager *self);
|
||||||
void calls_manager_add_provider (CallsManager *self,
|
void calls_manager_add_provider (CallsManager *self,
|
||||||
const char *name);
|
const char *name);
|
||||||
void calls_manager_remove_provider (CallsManager *self,
|
void calls_manager_remove_provider (CallsManager *self,
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
|
|
||||||
#define G_LOG_DOMAIN "CallsNewCallBox"
|
#define G_LOG_DOMAIN "CallsNewCallBox"
|
||||||
|
|
||||||
#include "calls-application.h"
|
|
||||||
#include "calls-new-call-box.h"
|
#include "calls-new-call-box.h"
|
||||||
#include "calls-ussd.h"
|
#include "calls-ussd.h"
|
||||||
#include "calls-main-window.h"
|
#include "calls-main-window.h"
|
||||||
#include "calls-manager.h"
|
#include "calls-manager.h"
|
||||||
|
#include "calls-settings.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <handy.h>
|
#include <handy.h>
|
||||||
|
@ -83,11 +83,12 @@ static CallsOrigin *
|
||||||
get_origin (CallsNewCallBox *self,
|
get_origin (CallsNewCallBox *self,
|
||||||
const char *target)
|
const char *target)
|
||||||
{
|
{
|
||||||
CallsApplication *app = CALLS_APPLICATION (g_application_get_default ());
|
CallsManager *manager = calls_manager_get_default ();
|
||||||
|
CallsSettings *settings = calls_manager_get_settings (manager);
|
||||||
g_autoptr (CallsOrigin) origin = NULL;
|
g_autoptr (CallsOrigin) origin = NULL;
|
||||||
GListModel *model;
|
GListModel *model;
|
||||||
gboolean auto_use_def_origin =
|
gboolean auto_use_def_origin =
|
||||||
calls_application_get_use_default_origins_setting (app);
|
calls_settings_get_use_default_origins (settings);
|
||||||
|
|
||||||
if (auto_use_def_origin) {
|
if (auto_use_def_origin) {
|
||||||
model = calls_manager_get_suitable_origins (calls_manager_get_default (),
|
model = calls_manager_get_suitable_origins (calls_manager_get_default (),
|
||||||
|
|
Loading…
Reference in a new issue