aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2013-07-18 18:49:16 +0800
committerXavier Claessens <xavier.claessens@collabora.co.uk>2013-07-18 19:02:17 +0800
commit2873368e36050e4969c3f91775b92fda27b9fcb5 (patch)
treeb1550f83df7e115e1e362b48037d6671fa50b033 /libempathy-gtk
parenteaa91c2dea8e630e113025764d678c823761e1e6 (diff)
downloadgsoc2013-empathy-2873368e36050e4969c3f91775b92fda27b9fcb5.tar
gsoc2013-empathy-2873368e36050e4969c3f91775b92fda27b9fcb5.tar.gz
gsoc2013-empathy-2873368e36050e4969c3f91775b92fda27b9fcb5.tar.bz2
gsoc2013-empathy-2873368e36050e4969c3f91775b92fda27b9fcb5.tar.lz
gsoc2013-empathy-2873368e36050e4969c3f91775b92fda27b9fcb5.tar.xz
gsoc2013-empathy-2873368e36050e4969c3f91775b92fda27b9fcb5.tar.zst
gsoc2013-empathy-2873368e36050e4969c3f91775b92fda27b9fcb5.zip
EmpathySoundManager: Fix playing sound when account goes online.
We need to use the requested presence instead of the current presence to check if we should play sound, because in the case of an account that just got connected, its current presence may still be OFFLINE. https://bugzilla.gnome.org/show_bug.cgi?id=704454
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-sound-manager.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/libempathy-gtk/empathy-sound-manager.c b/libempathy-gtk/empathy-sound-manager.c
index 4f69c62db..3453e8f2c 100644
--- a/libempathy-gtk/empathy-sound-manager.c
+++ b/libempathy-gtk/empathy-sound-manager.c
@@ -165,15 +165,37 @@ empathy_sound_manager_dup_singleton (void)
static gboolean
empathy_check_available_state (void)
{
- TpConnectionPresenceType presence;
- EmpathyPresenceManager *presence_mgr;
+ 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);
+ }
- presence_mgr = empathy_presence_manager_dup_singleton ();
- presence = empathy_presence_manager_get_state (presence_mgr);
- g_object_unref (presence_mgr);
+ g_object_unref (am);
- if (presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE &&
- presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
+ if (most_available_requested_presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE &&
+ most_available_requested_presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
return FALSE;
return TRUE;