+static void
+main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
+ EmpathyContact *contact,
+ McPresence current,
+ McPresence previous,
+ EmpathyMainWindow *window)
+{
+ EmpathyAccountManager *acc_manager;
+ McAccount *account;
+ gboolean should_play;
+
+ acc_manager = empathy_account_manager_new ();
+ account = empathy_contact_get_account (contact);
+ should_play = !empathy_account_manager_is_account_just_connected (acc_manager, account);
+
+ if (!should_play) {
+ goto out;
+ }
+
+ if (previous < MC_PRESENCE_AVAILABLE && current > MC_PRESENCE_OFFLINE) {
+ /* someone is logging in */
+ if (empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN)) {
+ ca_gtk_play_for_widget (GTK_WIDGET (window->window), 0,
+ CA_PROP_EVENT_ID, "service-login",
+ CA_PROP_EVENT_DESCRIPTION, _("Contact logged in"),
+ NULL);
+ }
+ goto out;
+ }
+
+ if (previous > MC_PRESENCE_OFFLINE && current < MC_PRESENCE_AVAILABLE) {
+ /* someone is logging off */
+ if (empathy_sound_pref_is_enabled (EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT)) {
+ ca_gtk_play_for_widget (GTK_WIDGET (window->window), 0,
+ CA_PROP_EVENT_ID, "service-logout",
+ CA_PROP_EVENT_DESCRIPTION, _("Contact logged out"),
+ NULL);
+ }
+ }
+out:
+ g_object_unref (acc_manager);
+}
+