aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-01-13 21:56:41 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-01-13 22:14:25 +0800
commit2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc (patch)
tree5f52a4950e1864ecc824808f692a816ee697c642
parentddb4928052ff303f024ea9b69e10064fade790a3 (diff)
downloadgsoc2013-empathy-2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc.tar
gsoc2013-empathy-2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc.tar.gz
gsoc2013-empathy-2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc.tar.bz2
gsoc2013-empathy-2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc.tar.lz
gsoc2013-empathy-2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc.tar.xz
gsoc2013-empathy-2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc.tar.zst
gsoc2013-empathy-2a7fa12bcf9c0ee5a9ff506bc88af2194990dabc.zip
account-settings: allow to change the service
https://bugzilla.gnome.org/show_bug.cgi?id=667791
-rw-r--r--libempathy/empathy-account-settings.c44
-rw-r--r--libempathy/empathy-account-settings.h3
2 files changed, 47 insertions, 0 deletions
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index 78d609685..cf269bdc8 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -103,6 +103,8 @@ struct _EmpathyAccountSettingsPriv
/* If TRUE, the account should have 'tel' in its
* Account.Interface.Addressing.URISchemes property. */
gboolean uri_scheme_tel;
+ /* If TRUE, Service property needs to be updated when applying changes */
+ gboolean update_service;
GSimpleAsyncResult *apply_result;
};
@@ -743,6 +745,21 @@ empathy_account_settings_get_service (EmpathyAccountSettings *settings)
return priv->service;
}
+void
+empathy_account_settings_set_service (EmpathyAccountSettings *settings,
+ const gchar *service)
+{
+ EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
+
+ if (!tp_strdiff (priv->service, service))
+ return;
+
+ g_free (priv->service);
+ priv->service = g_strdup (service);
+ g_object_notify (G_OBJECT (settings), "service");
+ priv->update_service = TRUE;
+}
+
gchar *
empathy_account_settings_get_icon_name (EmpathyAccountSettings *settings)
{
@@ -1446,6 +1463,32 @@ update_account_uri_schemes (EmpathyAccountSettings *self)
}
static void
+set_service_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!tp_account_set_service_finish (TP_ACCOUNT (source), result, &error))
+ {
+ DEBUG ("Failed to set Account.Service: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+update_account_service (EmpathyAccountSettings *self)
+{
+ EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
+
+ if (!priv->update_service)
+ return;
+
+ tp_account_set_service_async (priv->account,
+ priv->service != NULL ? priv->service : "", set_service_cb, self);
+}
+
+static void
empathy_account_settings_account_updated (GObject *source,
GAsyncResult *result,
gpointer user_data)
@@ -1486,6 +1529,7 @@ empathy_account_settings_account_updated (GObject *source,
}
update_account_uri_schemes (settings);
+ update_account_service (settings);
g_simple_async_result_set_op_res_gboolean (priv->apply_result,
g_strv_length (reconnect_required) > 0);
diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h
index ea0c5b048..10ed3684f 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -78,6 +78,9 @@ const gchar *empathy_account_settings_get_protocol (
const gchar *empathy_account_settings_get_service (
EmpathyAccountSettings *settings);
+void empathy_account_settings_set_service (EmpathyAccountSettings *settings,
+ const gchar *service);
+
TpAccount *empathy_account_settings_get_account (
EmpathyAccountSettings *settings);