aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-18 01:09:22 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-19 07:12:11 +0800
commit31e4f59e7c16016d0279070a711147fb6b460af1 (patch)
tree3d4def515213312926948709dc27d97a02e20184
parent0a24fbcba90ec2b36ede035ec6d9a9915a740e1a (diff)
downloadgsoc2013-empathy-31e4f59e7c16016d0279070a711147fb6b460af1.tar
gsoc2013-empathy-31e4f59e7c16016d0279070a711147fb6b460af1.tar.gz
gsoc2013-empathy-31e4f59e7c16016d0279070a711147fb6b460af1.tar.bz2
gsoc2013-empathy-31e4f59e7c16016d0279070a711147fb6b460af1.tar.lz
gsoc2013-empathy-31e4f59e7c16016d0279070a711147fb6b460af1.tar.xz
gsoc2013-empathy-31e4f59e7c16016d0279070a711147fb6b460af1.tar.zst
gsoc2013-empathy-31e4f59e7c16016d0279070a711147fb6b460af1.zip
notify-manager: use the account mgr directly instead of empathy_check_available_state
-rw-r--r--libempathy-gtk/empathy-notify-manager.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-notify-manager.c b/libempathy-gtk/empathy-notify-manager.c
index b87bb4965..67e39ef1b 100644
--- a/libempathy-gtk/empathy-notify-manager.c
+++ b/libempathy-gtk/empathy-notify-manager.c
@@ -23,6 +23,8 @@
#include <libnotify/notification.h>
#include <libnotify/notify.h>
+#include <telepathy-glib/account-manager.h>
+
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-ui-utils.h>
@@ -39,6 +41,7 @@ typedef struct
{
/* owned (gchar *) => TRUE */
GHashTable *capabilities;
+ TpAccountManager *account_manager;
} EmpathyNotifyManagerPriv;
G_DEFINE_TYPE (EmpathyNotifyManager, empathy_notify_manager, G_TYPE_OBJECT);
@@ -86,6 +89,22 @@ empathy_notify_manager_class_init (EmpathyNotifyManagerClass *klass)
}
static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ GError *error = NULL;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, &error))
+ {
+ DEBUG ("Failed to prepare account manager: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+}
+
+static void
empathy_notify_manager_init (EmpathyNotifyManager *self)
{
EmpathyNotifyManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
@@ -108,6 +127,11 @@ empathy_notify_manager_init (EmpathyNotifyManager *self)
g_hash_table_insert (priv->capabilities, cap, GUINT_TO_POINTER (TRUE));
}
g_list_free (list);
+
+ priv->account_manager = tp_account_manager_dup ();
+
+ tp_account_manager_prepare_async (priv->account_manager, NULL,
+ account_manager_prepared_cb, self);
}
EmpathyNotifyManager *
@@ -144,8 +168,10 @@ empathy_notify_manager_get_pixbuf_for_notification (EmpathyNotifyManager *self,
gboolean
empathy_notify_manager_notification_is_enabled (EmpathyNotifyManager *self)
{
+ EmpathyNotifyManagerPriv *priv = GET_PRIV (self);
EmpathyConf *conf;
gboolean res;
+ TpConnectionPresenceType presence;
conf = empathy_conf_get ();
res = FALSE;
@@ -155,7 +181,19 @@ empathy_notify_manager_notification_is_enabled (EmpathyNotifyManager *self)
if (!res)
return FALSE;
- if (!empathy_check_available_state ())
+ if (!tp_account_manager_is_prepared (priv->account_manager,
+ TP_ACCOUNT_MANAGER_FEATURE_CORE))
+ {
+ DEBUG ("account manager is not ready yet; display the notification");
+ return TRUE;
+ }
+
+ presence = tp_account_manager_get_most_available_presence (
+ priv->account_manager,
+ NULL, NULL);
+
+ if (presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE &&
+ presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
{
empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
&res);