]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-sound-manager.c
Change Finnish translation team web page to l10n.gnome.org
[empathy.git] / libempathy-gtk / empathy-sound-manager.c
index 3291a9a92838ea51d810304a3a020d49bd9802d4..3453e8f2cd176218185b27a33f4e9f15ca2365ac 100644 (file)
  */
 
 #include "config.h"
-
 #include "empathy-sound-manager.h"
 
 #include <glib/gi18n-lib.h>
 
+#include "empathy-gsettings.h"
+#include "empathy-presence-manager.h"
+#include "empathy-utils.h"
+
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-utils.h>
+#include "empathy-debug.h"
 
 typedef struct {
   EmpathySound sound_id;
@@ -161,6 +162,45 @@ empathy_sound_manager_dup_singleton (void)
   return manager;
 }
 
+static gboolean
+empathy_check_available_state (void)
+{
+  TpConnectionPresenceType most_available_requested_presence;
+  TpAccountManager *am;
+  GList *accounts;
+
+  /* We cannot use tp_account_manager_get_most_available_presence() or
+   * empathy_presence_manager_get_state() because it is the requested presence
+   * that matters, not the current presence.
+   * See https://bugzilla.gnome.org/show_bug.cgi?id=704454 */
+  most_available_requested_presence = TP_CONNECTION_PRESENCE_TYPE_UNSET;
+  am = tp_account_manager_dup ();
+  accounts = tp_account_manager_dup_valid_accounts (am);
+  while (accounts != NULL)
+    {
+      TpAccount *account = accounts->data;
+      TpConnectionPresenceType requested_presence;
+
+      requested_presence = tp_account_get_requested_presence (account,
+          NULL, NULL);
+
+      if (tp_connection_presence_type_cmp_availability (requested_presence,
+              most_available_requested_presence) > 0)
+        most_available_requested_presence = requested_presence;
+
+      g_object_unref (account);
+      accounts = g_list_delete_link (accounts, accounts);
+    }
+
+  g_object_unref (am);
+
+  if (most_available_requested_presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE &&
+    most_available_requested_presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
+    return FALSE;
+
+  return TRUE;
+}
+
 static gboolean
 empathy_sound_pref_is_enabled (EmpathySoundManager *self,
     EmpathySound sound_id)