+
+// Get all the callbacks
+static int AllCallback( vlc_object_t *p_this, const char *psz_var,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ (void)p_this;
+ (void)oldval;
+ intf_thread_t *p_intf = (intf_thread_t*)p_data;
+
+ callback_info_t *info = malloc( sizeof( callback_info_t ) );
+ if( !info )
+ return VLC_ENOMEM;
+
+ // Wich event is it ?
+ if( !strcmp( "item-current", psz_var ) )
+ info->signal = SIGNAL_ITEM_CURRENT;
+ else if( !strcmp( "intf-change", psz_var ) )
+ info->signal = SIGNAL_INTF_CHANGE;
+ else if( !strcmp( "playlist-item-append", psz_var ) )
+ {
+ info->signal = SIGNAL_PLAYLIST_ITEM_APPEND;
+ info->i_node = ((playlist_add_t*)newval.p_address)->i_node;
+ }
+ else if( !strcmp( "playlist-item-deleted", psz_var ) )
+ info->signal = SIGNAL_PLAYLIST_ITEM_DELETED;
+ else if( !strcmp( "random", psz_var ) )
+ info->signal = SIGNAL_RANDOM;
+ else if( !strcmp( "repeat", psz_var ) )
+ info->signal = SIGNAL_REPEAT;
+ else if( !strcmp( "loop", psz_var ) )
+ info->signal = SIGNAL_LOOP;
+ else if( !strcmp( "state", psz_var ) )
+ {
+ info->signal = SIGNAL_STATE;
+ info->i_input_state = newval.i_int;
+ }
+ else
+ assert(0);
+
+ // Append the event
+ vlc_mutex_lock( &p_intf->p_sys->lock );
+ vlc_array_append( p_intf->p_sys->p_events, info );
+ vlc_mutex_unlock( &p_intf->p_sys->lock );
+ return VLC_SUCCESS;
+}
+
+/******************************************************************************
+ * CapsChange: player capabilities change signal
+ *****************************************************************************/
+DBUS_SIGNAL( CapsChangeSignal )
+{
+ SIGNAL_INIT( "CapsChange" );
+ OUT_ARGUMENTS;
+
+ ADD_INT32( &((intf_thread_t*)p_data)->p_sys->i_caps );
+ SIGNAL_SEND;
+}
+
+/******************************************************************************
+ * TrackListChange: tracklist order / length change signal
+ *****************************************************************************/
+DBUS_SIGNAL( TrackListChangeSignal )
+{ /* emit the new tracklist lengh */
+ SIGNAL_INIT("TrackListChange");
+ OUT_ARGUMENTS;
+
+ playlist_t *p_playlist = pl_Hold( (vlc_object_t*) p_data );
+ dbus_int32_t i_elements = p_playlist->current.i_size;
+ pl_Release( (vlc_object_t*) p_data );
+
+ ADD_INT32( &i_elements );
+ SIGNAL_SEND;
+}
+
+/*****************************************************************************
+ * TrackListChangeEmit: Emits the TrackListChange signal
+ *****************************************************************************/
+/* FIXME: It is not called on tracklist reordering */
+static int TrackListChangeEmit( intf_thread_t *p_intf, int signal, int i_node )
+{
+ // "playlist-item-append"
+ if( signal == SIGNAL_PLAYLIST_ITEM_APPEND )
+ {
+ /* don't signal when items are added/removed in p_category */
+ playlist_t *p_playlist = pl_Hold( p_intf );
+ PL_LOCK;
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_node );
+ assert( p_item );
+ while( p_item->p_parent )
+ p_item = p_item->p_parent;
+ if( p_item == p_playlist->p_root_category )
+ {
+ PL_UNLOCK;
+ pl_Release( p_intf );
+ return VLC_SUCCESS;
+ }
+ PL_UNLOCK;
+ pl_Release( p_intf );
+ }
+
+ if( p_intf->p_sys->b_dead )
+ return VLC_SUCCESS;
+
+ UpdateCaps( p_intf );
+ TrackListChangeSignal( p_intf->p_sys->p_conn, p_intf );
+ return VLC_SUCCESS;
+}