]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-notify-manager.c
include telepathy-glib.h
[empathy.git] / libempathy-gtk / empathy-notify-manager.c
index 8f7991166044738a8f409ce9b811271dd56334ec..2503542829aaaf33b72d00609270f33984ac5eba 100644 (file)
 #include <libnotify/notification.h>
 #include <libnotify/notify.h>
 
-#include <telepathy-glib/account-manager.h>
+#include <telepathy-glib/telepathy-glib.h>
 
+#include <libempathy/empathy-gsettings.h>
 #include <libempathy/empathy-utils.h>
 
 #include <libempathy-gtk/empathy-ui-utils.h>
-#include <libempathy-gtk/empathy-conf.h>
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include <libempathy/empathy-debug.h>
@@ -42,6 +42,7 @@ typedef struct
   /* owned (gchar *) => TRUE */
   GHashTable *capabilities;
   TpAccountManager *account_manager;
+  GSettings *gsettings_notif;
 } EmpathyNotifyManagerPriv;
 
 G_DEFINE_TYPE (EmpathyNotifyManager, empathy_notify_manager, G_TYPE_OBJECT);
@@ -78,6 +79,8 @@ notify_manager_dispose (GObject *object)
       priv->account_manager = NULL;
     }
 
+  tp_clear_object (&priv->gsettings_notif);
+
   G_OBJECT_CLASS (empathy_notify_manager_parent_class)->dispose (object);
 }
 
@@ -86,7 +89,7 @@ notify_manager_finalize (GObject *object)
 {
   EmpathyNotifyManagerPriv *priv = GET_PRIV (object);
 
-  g_hash_table_destroy (priv->capabilities);
+  g_hash_table_unref (priv->capabilities);
 
   G_OBJECT_CLASS (empathy_notify_manager_parent_class)->finalize (object);
 }
@@ -111,7 +114,7 @@ account_manager_prepared_cb (GObject *source_object,
   TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
   GError *error = NULL;
 
-  if (!tp_account_manager_prepare_finish (account_manager, result, &error))
+  if (!tp_proxy_prepare_finish (account_manager, result, &error))
     {
       DEBUG ("Failed to prepare account manager: %s", error->message);
       g_error_free (error);
@@ -128,6 +131,8 @@ empathy_notify_manager_init (EmpathyNotifyManager *self)
 
   self->priv = priv;
 
+  priv->gsettings_notif = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
+
   priv->capabilities = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
       NULL);
 
@@ -145,7 +150,7 @@ empathy_notify_manager_init (EmpathyNotifyManager *self)
 
   priv->account_manager = tp_account_manager_dup ();
 
-  tp_account_manager_prepare_async (priv->account_manager, NULL,
+  tp_proxy_prepare_async (priv->account_manager, NULL,
       account_manager_prepared_cb, self);
 }
 
@@ -184,16 +189,10 @@ 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;
-
-  empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_ENABLED, &res);
-
-  if (!res)
+  if (!g_settings_get_boolean (priv->gsettings_notif,
+        EMPATHY_PREFS_NOTIFICATIONS_ENABLED))
     return FALSE;
 
   if (!tp_account_manager_is_prepared (priv->account_manager,
@@ -210,10 +209,8 @@ empathy_notify_manager_notification_is_enabled  (EmpathyNotifyManager *self)
   if (presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE &&
       presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
     {
-      empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
-          &res);
-
-      if (res)
+      if (g_settings_get_boolean (priv->gsettings_notif,
+            EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY))
         return FALSE;
     }