Commit ac092194 authored by Mirsal Ennaime's avatar Mirsal Ennaime
Browse files

dbus: Implement the TrackList interface's PropertiesChanged signal

parent 393d7e42
......@@ -545,8 +545,9 @@ static void ProcessEvents( intf_thread_t *p_intf,
playlist_t *p_playlist = p_intf->p_sys->p_playlist;
bool b_can_play = p_intf->p_sys->b_can_play;
vlc_dictionary_t player_properties;
vlc_dictionary_init( &player_properties, 0 );
vlc_dictionary_t player_properties, tracklist_properties;
vlc_dictionary_init( &player_properties, 0 );
vlc_dictionary_init( &tracklist_properties, 0 );
for( int i = 0; i < i_events; i++ )
{
......@@ -562,11 +563,14 @@ static void ProcessEvents( intf_thread_t *p_intf,
PL_LOCK;
b_can_play = playlist_CurrentSize( p_playlist ) > 0;
PL_UNLOCK;
if( b_can_play != p_intf->p_sys->b_can_play )
{
p_intf->p_sys->b_can_play = b_can_play;
vlc_dictionary_insert( &player_properties, "CanPlay", NULL );
}
vlc_dictionary_insert( &tracklist_properties, "Tracks", NULL );
break;
case SIGNAL_VOLUME_MUTED:
case SIGNAL_VOLUME_CHANGE:
......@@ -630,7 +634,11 @@ static void ProcessEvents( intf_thread_t *p_intf,
if( vlc_dictionary_keys_count( &player_properties ) )
PlayerPropertiesChangedEmit( p_intf, &player_properties );
vlc_dictionary_clear( &player_properties, NULL, NULL );
if( vlc_dictionary_keys_count( &tracklist_properties ) )
TrackListPropertiesChangedEmit( p_intf, &player_properties );
vlc_dictionary_clear( &player_properties, NULL, NULL );
vlc_dictionary_clear( &tracklist_properties, NULL, NULL );
}
/**
......
......@@ -229,7 +229,7 @@ DBUS_METHOD( Tracks )
input_item_t *p_input = NULL;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "ao", &v );
dbus_message_iter_open_container( &v, DBUS_TYPE_ARRAY, "o", &tracks );
dbus_message_iter_open_container( &v, DBUS_TYPE_ARRAY, "o", &tracks );
PL_LOCK;
......@@ -405,3 +405,57 @@ int TrackListChangeEmit( intf_thread_t *p_intf, int signal, int i_node )
}
#undef METHOD_FUNC
/**
* PropertiesChangedSignal: synthetizes and sends the
* org.freedesktop.DBus.Properties.PropertiesChanged signal
*/
static DBusHandlerResult
PropertiesChangedSignal( intf_thread_t *p_intf,
vlc_dictionary_t *p_changed_properties )
{
DBusConnection *p_conn = p_intf->p_sys->p_conn;
DBusMessageIter changed_properties, invalidated_properties, entry, variant;
const char *psz_interface_name = DBUS_MPRIS_TRACKLIST_INTERFACE;
char **ppsz_properties = NULL;
int i_properties = 0;
SIGNAL_INIT( DBUS_INTERFACE_PROPERTIES,
DBUS_MPRIS_OBJECT_PATH,
"PropertiesChanged" );
OUT_ARGUMENTS;
ADD_STRING( &psz_interface_name );
dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}",
&changed_properties );
dbus_message_iter_close_container( &args, &changed_properties );
dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s",
&invalidated_properties );
i_properties = vlc_dictionary_keys_count( p_changed_properties );
ppsz_properties = vlc_dictionary_all_keys( p_changed_properties );
for( int i = 0; i < i_properties; i++ )
if( !strcmp( ppsz_properties[i], "Tracks" ) )
dbus_message_iter_append_basic( &entry, DBUS_TYPE_STRING,
&ppsz_properties[i] );
dbus_message_iter_close_container( &args, &invalidated_properties );
SIGNAL_SEND;
}
/**
* TrackListPropertiesChangedEmit: Emits the
* org.freedesktop.DBus.Properties.PropertiesChanged signal
*/
int TrackListPropertiesChangedEmit( intf_thread_t * p_intf,
vlc_dictionary_t * p_changed_properties )
{
if( p_intf->p_sys->b_dead )
return VLC_SUCCESS;
PropertiesChangedSignal( p_intf, p_changed_properties );
return VLC_SUCCESS;
}
......@@ -45,5 +45,6 @@ static const DBusObjectPathVTable dbus_mpris_tracklist_vtable = {
};
int TrackListChangeEmit( intf_thread_t *, int, int );
int TrackListPropertiesChangedEmit( intf_thread_t *, vlc_dictionary_t * );
#endif //dbus_tracklist.h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment