]> git.sesse.net Git - vlc/blobdiff - modules/misc/notify/telepathy.c
Fix compilation: too short delay.
[vlc] / modules / misc / notify / telepathy.c
index 3c2e3d40ace7d35b6599d2599f7c27c2e7d27fc0..c89c58792e96a998ac2a69e467ea80f67fd227e5 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * telepathy.c : changes Telepathy Presence information using MissionControl
  *****************************************************************************
- * Copyright © 2007 the VideoLAN team
+ * Copyright © 2007-2009 the VideoLAN team
  * $Id$
  *
  * Author: Rafaël Carré <funman@videoanorg>
@@ -32,9 +32,9 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_interface.h>
-#include <vlc_meta.h>
 #include <vlc_playlist.h>
 #include <vlc_strings.h>
+
 #include <dbus/dbus.h>
 
 /*****************************************************************************
@@ -94,7 +94,6 @@ static int Open( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
     playlist_t *p_playlist;
-    DBusConnection  *p_conn;
     DBusError       error;
 
     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
@@ -103,8 +102,8 @@ static int Open( vlc_object_t *p_this )
 
     /* connect to the session bus */
     dbus_error_init( &error );
-    p_conn = dbus_bus_get( DBUS_BUS_SESSION, &error );
-    if( !p_conn )
+    p_intf->p_sys->p_conn = dbus_bus_get( DBUS_BUS_SESSION, &error );
+    if( !p_intf->p_sys->p_conn )
     {
         msg_Err( p_this, "Failed to connect to the DBus session daemon: %s",
                 error.message );
@@ -112,7 +111,6 @@ static int Open( vlc_object_t *p_this )
         free( p_intf->p_sys );
         return VLC_EGENERIC;
     }
-    p_intf->p_sys->p_conn = p_conn;
 
     p_intf->p_sys->psz_format = config_GetPsz( p_intf, "telepathy-format" );
     if( !p_intf->p_sys->psz_format )
@@ -126,7 +124,7 @@ static int Open( vlc_object_t *p_this )
 
     p_playlist = pl_Hold( p_intf );
     var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );
-    var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
+    var_AddCallback( p_playlist, "item-current", ItemChange, p_intf );
     pl_Release( p_intf );
 
     return VLC_SUCCESS;
@@ -142,7 +140,7 @@ static void Close( vlc_object_t *p_this )
     input_thread_t *p_input = NULL;
 
     var_DelCallback( p_playlist, "item-change", ItemChange, p_intf );
-    var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf );
+    var_DelCallback( p_playlist, "item-current", ItemChange, p_intf );
     if( (p_input = playlist_CurrentInput( p_playlist )) )
     {
         var_DelCallback( p_input, "state", StateChange, p_intf );
@@ -175,16 +173,19 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     playlist_t* p_playlist = (playlist_t*) p_this;
     char *psz_buf = NULL;
     input_thread_t *p_input;
+    input_item_t *p_item = newval.p_address;
+    bool b_is_item_current = !strcmp( "item-current", psz_var );
 
     /* Don't update Telepathy presence each time an item has been preparsed */
-    if( !strncmp( "playlist-current", psz_var, 16 ) )
+    if( b_is_item_current )
     { /* stores the current input item id */
-        p_intf->p_sys->i_id = newval.i_int;
+        p_intf->p_sys->i_id = p_item->i_id;
         p_intf->p_sys->i_item_changes = 0;
     }
     else
     {
-        if( newval.i_int != p_intf->p_sys->i_id ) /* "item-change" */
+
+        if( p_item->i_id != p_intf->p_sys->i_id ) /* "item-change" */
             return VLC_SUCCESS;
         /* Some variable bitrate inputs call "item-change callbacks each time
          * their length is updated, that is several times per second.
@@ -211,7 +212,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
         }
     }
 
-    if( !strncmp( "playlist-current", psz_var, 16 ) )
+    if( b_is_item_current )
         var_AddCallback( p_input, "state", StateChange, p_intf );
 
     /* We format the string to be displayed */