From 1ef053f46e31460f8f128621690a967e2ca08fc6 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 24 Aug 2011 13:51:12 +0200 Subject: account-settings: add API to set 'tel' in the URISchemes property of the account https://bugzilla.gnome.org/show_bug.cgi?id=657220 --- libempathy/empathy-account-settings.c | 65 +++++++++++++++++++++++++++++++++++ libempathy/empathy-account-settings.h | 6 ++++ 2 files changed, 71 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index 55af8f8f7..91ba61023 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -100,6 +100,10 @@ struct _EmpathyAccountSettingsPriv gulong managers_ready_id; gboolean preparing_protocol; + /* If TRUE, the account should have 'tel' in its + * Account.Interface.Addressing.URISchemes property. */ + gboolean uri_scheme_tel; + GSimpleAsyncResult *apply_result; }; @@ -243,6 +247,7 @@ empathy_account_settings_constructed (GObject *object) GQuark features[] = { TP_ACCOUNT_FEATURE_CORE, TP_ACCOUNT_FEATURE_STORAGE, + TP_ACCOUNT_FEATURE_ADDRESSING, 0 }; if (priv->account != NULL) @@ -524,6 +529,25 @@ empathy_account_settings_try_migrating_password (EmpathyAccountSettings *self) priv->password_original = g_strdup (password); } +static gboolean +account_has_uri_scheme_tel (TpAccount *account) +{ + const gchar * const * uri_schemes; + guint i; + + uri_schemes = tp_account_get_uri_schemes (account); + if (uri_schemes == NULL) + return FALSE; + + for (i = 0; uri_schemes[i] != NULL; i++) + { + if (!tp_strdiff (uri_schemes[i], "tel")) + return TRUE; + } + + return FALSE; +} + static void empathy_account_settings_check_readyness (EmpathyAccountSettings *self) { @@ -561,6 +585,8 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self) g_free (priv->icon_name); priv->icon_name = g_strdup (tp_account_get_icon_name (priv->account)); + + priv->uri_scheme_tel = account_has_uri_scheme_tel (priv->account); } tp_protocol = tp_connection_manager_get_protocol (priv->manager, @@ -919,6 +945,11 @@ empathy_account_settings_discard_changes (EmpathyAccountSettings *settings) priv->password_changed = FALSE; g_free (priv->password); priv->password = g_strdup (priv->password_original); + + if (priv->account != NULL) + priv->uri_scheme_tel = account_has_uri_scheme_tel (priv->account); + else + priv->uri_scheme_tel = FALSE; } const gchar * @@ -1420,6 +1451,18 @@ empathy_account_settings_delete_password_cb (GObject *source, empathy_keyring_delete_account_password_finish); } +static void +update_account_uri_schemes (EmpathyAccountSettings *self) +{ + EmpathyAccountSettingsPriv *priv = GET_PRIV (self); + + if (priv->uri_scheme_tel == account_has_uri_scheme_tel (priv->account)) + return; + + tp_account_set_uri_scheme_association_async (priv->account, "tel", + priv->uri_scheme_tel, NULL, NULL); +} + static void empathy_account_settings_account_updated (GObject *source, GAsyncResult *result, @@ -1460,6 +1503,8 @@ empathy_account_settings_account_updated (GObject *source, return; } + update_account_uri_schemes (settings); + g_simple_async_result_set_op_res_gboolean (priv->apply_result, g_strv_length (reconnect_required) > 0); @@ -1508,6 +1553,8 @@ empathy_account_settings_created_cb (GObject *source, return; } + update_account_uri_schemes (settings); + empathy_account_settings_discard_changes (settings); } @@ -1794,3 +1841,21 @@ empathy_account_settings_param_is_supported (EmpathyAccountSettings *self, return tp_protocol_has_param (priv->protocol_obj, param); } + +void +empathy_account_settings_set_uri_scheme_tel (EmpathyAccountSettings *self, + gboolean associate) +{ + EmpathyAccountSettingsPriv *priv = GET_PRIV (self); + + priv->uri_scheme_tel = associate; +} + +gboolean +empathy_account_settings_has_uri_scheme_tel ( + EmpathyAccountSettings *self) +{ + EmpathyAccountSettingsPriv *priv = GET_PRIV (self); + + return priv->uri_scheme_tel; +} diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h index 80c30092e..ea0c5b048 100644 --- a/libempathy/empathy-account-settings.h +++ b/libempathy/empathy-account-settings.h @@ -200,6 +200,12 @@ gboolean empathy_account_settings_param_is_supported ( EmpathyAccountSettings *self, const gchar *param); +void empathy_account_settings_set_uri_scheme_tel (EmpathyAccountSettings *self, + gboolean associate); + +gboolean empathy_account_settings_has_uri_scheme_tel ( + EmpathyAccountSettings *self); + G_END_DECLS #endif /* #ifndef __EMPATHY_ACCOUNT_SETTINGS_H__*/ -- cgit v1.2.3