aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2009-10-24 22:26:09 +0800
committerJonny Lamb <jonnylamb@gnome.org>2009-10-24 22:26:09 +0800
commitd133b3b80a6a7fd4911905a077be21dabe0ef4bb (patch)
treebd02215e32691ccfb74ac875c83821a34c048b8c
parentbb173d8e042303ab7a0d9ec15c7a07f752cde200 (diff)
downloadgsoc2013-empathy-d133b3b80a6a7fd4911905a077be21dabe0ef4bb.tar
gsoc2013-empathy-d133b3b80a6a7fd4911905a077be21dabe0ef4bb.tar.gz
gsoc2013-empathy-d133b3b80a6a7fd4911905a077be21dabe0ef4bb.tar.bz2
gsoc2013-empathy-d133b3b80a6a7fd4911905a077be21dabe0ef4bb.tar.lz
gsoc2013-empathy-d133b3b80a6a7fd4911905a077be21dabe0ef4bb.tar.xz
gsoc2013-empathy-d133b3b80a6a7fd4911905a077be21dabe0ef4bb.tar.zst
gsoc2013-empathy-d133b3b80a6a7fd4911905a077be21dabe0ef4bb.zip
idle: port to new tp-glib account API
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
-rw-r--r--libempathy/empathy-idle.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index 8def5ba12..481ae5ea6 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -26,10 +26,10 @@
#include <glib/gi18n-lib.h>
#include <dbus/dbus-glib.h>
+#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
-#include "empathy-account-manager.h"
#include "empathy-idle.h"
#include "empathy-utils.h"
#include "empathy-connectivity.h"
@@ -58,7 +58,7 @@ typedef struct {
gboolean is_idle;
guint ext_away_timeout;
- EmpathyAccountManager *manager;
+ TpAccountManager *manager;
TpConnectionPresenceType requested_presence_type;
gchar *requested_status_message;
@@ -98,7 +98,7 @@ static const gchar *presence_type_to_status[NUM_TP_CONNECTION_PRESENCE_TYPES] =
};
static void
-idle_presence_changed_cb (EmpathyAccountManager *manager,
+idle_presence_changed_cb (TpAccountManager *manager,
TpConnectionPresenceType state,
gchar *status,
gchar *status_message,
@@ -438,17 +438,21 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
}
static void
-account_manager_ready_cb (EmpathyAccountManager *account_manager,
- GParamSpec *pspec,
- EmpathyIdle *idle)
+account_manager_ready_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- EmpathyIdlePriv *priv;
+ EmpathyIdle *idle = EMPATHY_IDLE (user_data);
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
TpConnectionPresenceType state;
gchar *status, *status_message;
- priv = GET_PRIV (idle);
+ if (!tp_account_manager_prepare_finish (account_manager, result, NULL)) {
+ return;
+ }
- state = empathy_account_manager_get_global_presence (priv->manager,
+ state = tp_account_manager_get_most_available_presence (priv->manager,
&status, &status_message);
idle_presence_changed_cb (account_manager, state, status,
@@ -467,18 +471,12 @@ empathy_idle_init (EmpathyIdle *idle)
idle->priv = priv;
priv->is_idle = FALSE;
- priv->manager = empathy_account_manager_dup_singleton ();
-
- if (empathy_account_manager_is_ready (priv->manager)) {
- priv->state = empathy_account_manager_get_global_presence (priv->manager,
- NULL, &priv->status);
- } else {
- g_signal_connect (priv->manager, "notify::ready",
- G_CALLBACK (account_manager_ready_cb), idle);
- }
+ priv->manager = tp_account_manager_dup ();
+ tp_account_manager_prepare_async (priv->manager, NULL,
+ account_manager_ready_cb, idle);
- g_signal_connect (priv->manager, "global-presence-changed",
+ g_signal_connect (priv->manager, "most-available-presence-changed",
G_CALLBACK (idle_presence_changed_cb), idle);
priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
@@ -592,7 +590,11 @@ empathy_idle_do_set_presence (EmpathyIdle *idle,
g_return_if_fail (status != NULL);
- empathy_account_manager_request_global_presence (priv->manager,
+ /* FIXME: Should be sure that the account manager is prepared, but
+ * sometimes this isn't possible, like when exiting. In other words,
+ * we need a callback to empathy_idle_set_presence to be sure the
+ * presence is set on all accounts successfully. */
+ tp_account_manager_set_all_requested_presences (priv->manager,
status_type, status, status_message);
}