[empathy/mc5] Make the set_enabled API async
- From: Sjoerd Simons <sjoerds src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy/mc5] Make the set_enabled API async
- Date: Sat, 22 Aug 2009 18:53:08 +0000 (UTC)
commit 23d4544855656cfdc9cf65ed94801191002e86ce
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Aug 6 21:13:09 2009 +0200
Make the set_enabled API async
libempathy/empathy-account.c | 57 +++++++++++++++++++++++++++++++----------
libempathy/empathy-account.h | 7 +++-
2 files changed, 48 insertions(+), 16 deletions(-)
---
diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c
index 5a6b31f..2dd6628 100644
--- a/libempathy/empathy-account.c
+++ b/libempathy/empathy-account.c
@@ -132,7 +132,8 @@ empathy_account_set_property (GObject *object,
switch (prop_id)
{
case PROP_ENABLED:
- empathy_account_set_enabled (account, g_value_get_boolean (value));
+ empathy_account_set_enabled_async (account,
+ g_value_get_boolean (value), NULL, NULL);
break;
case PROP_UNIQUE_NAME:
priv->unique_name = g_value_dup_string (value);
@@ -915,30 +916,58 @@ _empathy_account_set_connection (EmpathyAccount *account,
g_object_notify (G_OBJECT (account), "connection");
}
+static void
+account_enabled_set_cb (TpProxy *proxy,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ GSimpleAsyncResult *result = user_data;
+
+ if (error != NULL)
+ g_simple_async_result_set_from_error (result, (GError *) error);
+
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+}
+
+gboolean
+empathy_account_set_enabled_finish (EmpathyAccount *account,
+ GAsyncResult *result,
+ GError **error)
+{
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
+ error) ||
+ !g_simple_async_result_is_valid (result, G_OBJECT (account),
+ empathy_account_set_enabled_finish))
+ return FALSE;
+
+ return TRUE;
+}
+
void
-empathy_account_set_enabled (EmpathyAccount *account,
- gboolean enabled)
+empathy_account_set_enabled_async (EmpathyAccount *account,
+ gboolean enabled,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
EmpathyAccountPriv *priv = GET_PRIV (account);
GValue value = {0, };
+ GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (account),
+ callback, user_data, empathy_account_set_enabled_finish);
if (priv->enabled == enabled)
- return;
+ {
+ g_simple_async_result_complete_in_idle (result);
+ return;
+ }
g_value_init (&value, G_TYPE_BOOLEAN);
g_value_set_boolean (&value, enabled);
tp_cli_dbus_properties_call_set (TP_PROXY (priv->account),
- -1,
- TP_IFACE_ACCOUNT,
- "Enabled",
- &value,
- NULL,
- NULL,
- NULL,
- NULL);
-
- g_value_unset (&value);
+ -1, TP_IFACE_ACCOUNT, "Enabled", &value,
+ account_enabled_set_cb, result, NULL, G_OBJECT (account));
}
static void
diff --git a/libempathy/empathy-account.h b/libempathy/empathy-account.h
index 6351c93..f88ac43 100644
--- a/libempathy/empathy-account.h
+++ b/libempathy/empathy-account.h
@@ -67,8 +67,11 @@ const gchar *empathy_account_get_connection_manager (EmpathyAccount *account);
const gchar *empathy_account_get_protocol (EmpathyAccount *account);
const gchar *empathy_account_get_icon_name (EmpathyAccount *account);
-void empathy_account_set_enabled (EmpathyAccount *account,
- gboolean enabled);
+void empathy_account_set_enabled_async (EmpathyAccount *account,
+ gboolean enabled, GAsyncReadyCallback callback, gpointer user_data);
+gboolean empathy_account_set_enabled_finish (EmpathyAccount *account,
+ GAsyncResult *result, GError **error);
+
gboolean empathy_account_is_enabled (EmpathyAccount *account);
gboolean empathy_account_is_valid (EmpathyAccount *account);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]