]> git.0d.be Git - empathy.git/commitdiff
Play sound for contact connected/disconnected from EmpathyEventManager instead of...
authorXavier Claessens <xclaesse@gmail.com>
Sun, 23 May 2010 10:57:31 +0000 (12:57 +0200)
committerXavier Claessens <xclaesse@gmail.com>
Wed, 26 May 2010 09:34:59 +0000 (11:34 +0200)
src/empathy-event-manager.c
src/empathy-main-window.c

index 025eec564ddf693cd393f2d26fc94f3545d8062d..932164c1018ce00518711ebdd0d4062fd7f7e7d6 100644 (file)
@@ -864,33 +864,45 @@ event_manager_presence_changed_cb (EmpathyContactMonitor *monitor,
      TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
     {
       /* contact was online */
-      empathy_conf_get_bool (empathy_conf_get (),
-                      EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT, &preference);
-      if (preference && tp_connection_presence_type_cmp_availability (current,
+      if (tp_connection_presence_type_cmp_availability (current,
           TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0)
         {
           /* someone is logging off */
-          header = g_strdup_printf (_("%s is now offline."),
-            empathy_contact_get_name (contact));
+          empathy_sound_play (empathy_main_window_get (),
+              EMPATHY_SOUND_CONTACT_DISCONNECTED);
+
+          empathy_conf_get_bool (empathy_conf_get (),
+              EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT, &preference);
+          if (preference)
+            {
+              header = g_strdup_printf (_("%s is now offline."),
+                  empathy_contact_get_name (contact));
 
-          event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE,
-              EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL);
+              event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE,
+                  EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL);
+            }
         }
     }
   else
     {
       /* contact was offline */
-      empathy_conf_get_bool (empathy_conf_get (),
-                      EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN, &preference);
       if (preference && tp_connection_presence_type_cmp_availability (current,
           TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
         {
           /* someone is logging in */
-          header = g_strdup_printf (_("%s is now online."),
-            empathy_contact_get_name (contact));
+          empathy_sound_play (empathy_main_window_get (),
+              EMPATHY_SOUND_CONTACT_CONNECTED);
 
-          event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE,
-              EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL);
+          empathy_conf_get_bool (empathy_conf_get (),
+              EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN, &preference);
+          if (preference)
+            {
+              header = g_strdup_printf (_("%s is now online."),
+                  empathy_contact_get_name (contact));
+
+              event_manager_add (manager, contact, EMPATHY_EVENT_TYPE_PRESENCE,
+                  EMPATHY_IMAGE_AVATAR_DEFAULT, header, NULL, NULL, NULL, NULL);
+            }
         }
     }
   g_free (header);
index 787743f6740d43ab5da310f628bceaef11f5459a..ae1667622c2a2e988f17e7f88499c7758dc47bd5 100644 (file)
@@ -555,49 +555,6 @@ main_window_connection_changed_cb (TpAccount  *account,
        }
 }
 
-static void
-main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
-                                        EmpathyContact *contact,
-                                        TpConnectionPresenceType current,
-                                        TpConnectionPresenceType previous,
-                                        EmpathyMainWindow *window)
-{
-  TpAccount *account;
-  gboolean should_play = FALSE;
-  EmpathyIdle *idle;
-
-  account = empathy_contact_get_account (contact);
-  idle = empathy_idle_dup_singleton ();
-
-  should_play = !empathy_idle_account_is_just_connected (idle, account);
-
-  if (!should_play)
-    goto out;
-
-  if (tp_connection_presence_type_cmp_availability (previous,
-     TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
-    {
-      /* contact was online */
-      if (tp_connection_presence_type_cmp_availability (current,
-          TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0)
-        /* someone is logging off */
-        empathy_sound_play (GTK_WIDGET (window->window),
-          EMPATHY_SOUND_CONTACT_DISCONNECTED);
-    }
-  else
-    {
-      /* contact was offline */
-      if (tp_connection_presence_type_cmp_availability (current,
-          TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
-        /* someone is logging in */
-        empathy_sound_play (GTK_WIDGET (window->window),
-          EMPATHY_SOUND_CONTACT_CONNECTED);
-    }
-
-out:
-  g_object_unref (idle);
-}
-
 static void
 main_window_accels_load (void)
 {
@@ -1325,7 +1282,6 @@ empathy_main_window_show (void)
 {
        EmpathyMainWindow        *window;
        EmpathyContactList       *list_iface;
-       EmpathyContactMonitor    *monitor;
        GtkBuilder               *gui;
        EmpathyConf              *conf;
        GtkWidget                *sw;
@@ -1458,13 +1414,10 @@ empathy_main_window_show (void)
        window->throbber_tool_item = GTK_WIDGET (item);
 
        list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ());
-       monitor = empathy_contact_list_get_monitor (list_iface);
        window->list_store = empathy_contact_list_store_new (list_iface);
        window->list_view = empathy_contact_list_view_new (window->list_store,
                                                           EMPATHY_CONTACT_LIST_FEATURE_ALL,
                                                           EMPATHY_CONTACT_FEATURE_ALL);
-       g_signal_connect (monitor, "contact-presence-changed",
-                         G_CALLBACK (main_window_contact_presence_changed_cb), window);
        window->butterfly_log_migration_members_changed_id = g_signal_connect (
                list_iface, "members-changed",
                G_CALLBACK (main_window_members_changed_cb), window);