Commit 52903263 authored by Alex Merry's avatar Alex Merry Committed by Mirsal Ennaime

dbus: Standardise property marshalling for PropertiesChanged signal

Re-use the AddProperty method (used in GetAllProperties) and use macros
to reduce repetition of code.  Now all the calls should be
error-checked.
Signed-off-by: default avatarMirsal Ennaime <mirsal@videolan.org>
parent 3ed48e03
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "dbus_player.h" #include "dbus_player.h"
#include "dbus_common.h" #include "dbus_common.h"
static void MarshalLoopStatus ( intf_thread_t *, DBusMessageIter * ); static int MarshalLoopStatus ( intf_thread_t *, DBusMessageIter * );
DBUS_METHOD( Position ) DBUS_METHOD( Position )
{ /* returns position in microseconds */ { /* returns position in microseconds */
...@@ -165,7 +165,7 @@ DBUS_METHOD( Seek ) ...@@ -165,7 +165,7 @@ DBUS_METHOD( Seek )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
float f_vol = playlist_VolumeGet( p_intf->p_sys->p_playlist ); float f_vol = playlist_VolumeGet( p_intf->p_sys->p_playlist );
...@@ -173,7 +173,11 @@ MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -173,7 +173,11 @@ MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container )
f_vol = 1.f; /* ? */ f_vol = 1.f; /* ? */
double d_vol = f_vol; double d_vol = f_vol;
dbus_message_iter_append_basic( container, DBUS_TYPE_DOUBLE, &d_vol );
if( !dbus_message_iter_append_basic( container, DBUS_TYPE_DOUBLE, &d_vol ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( VolumeGet ) DBUS_METHOD( VolumeGet )
...@@ -302,7 +306,7 @@ DBUS_METHOD( OpenUri ) ...@@ -302,7 +306,7 @@ DBUS_METHOD( OpenUri )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalCanPlay( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanPlay( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
playlist_t *p_playlist = p_intf->p_sys->p_playlist; playlist_t *p_playlist = p_intf->p_sys->p_playlist;
...@@ -311,7 +315,11 @@ MarshalCanPlay( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -311,7 +315,11 @@ MarshalCanPlay( intf_thread_t *p_intf, DBusMessageIter *container )
dbus_bool_t b_can_play = playlist_CurrentSize( p_playlist ) > 0; dbus_bool_t b_can_play = playlist_CurrentSize( p_playlist ) > 0;
PL_UNLOCK; PL_UNLOCK;
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_can_play ); if( !dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN,
&b_can_play ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( CanPlay ) DBUS_METHOD( CanPlay )
...@@ -332,7 +340,7 @@ DBUS_METHOD( CanPlay ) ...@@ -332,7 +340,7 @@ DBUS_METHOD( CanPlay )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
dbus_bool_t b_can_pause = FALSE; dbus_bool_t b_can_pause = FALSE;
...@@ -345,8 +353,11 @@ MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -345,8 +353,11 @@ MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container )
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, if( !dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN,
&b_can_pause ); &b_can_pause ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( CanPause ) DBUS_METHOD( CanPause )
...@@ -391,7 +402,7 @@ DBUS_METHOD( CanControl ) ...@@ -391,7 +402,7 @@ DBUS_METHOD( CanControl )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
dbus_bool_t b_can_seek = FALSE; dbus_bool_t b_can_seek = FALSE;
...@@ -404,7 +415,11 @@ MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -404,7 +415,11 @@ MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container )
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_can_seek ); if( !dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN,
&b_can_seek ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( CanSeek ) DBUS_METHOD( CanSeek )
...@@ -425,11 +440,16 @@ DBUS_METHOD( CanSeek ) ...@@ -425,11 +440,16 @@ DBUS_METHOD( CanSeek )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalShuffle( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalShuffle( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
dbus_bool_t b_shuffle = var_GetBool( p_intf->p_sys->p_playlist, "random" ); dbus_bool_t b_shuffle = var_GetBool( p_intf->p_sys->p_playlist, "random" );
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_shuffle );
if( !dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN,
&b_shuffle ))
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( ShuffleGet ) DBUS_METHOD( ShuffleGet )
...@@ -463,7 +483,7 @@ DBUS_METHOD( ShuffleSet ) ...@@ -463,7 +483,7 @@ DBUS_METHOD( ShuffleSet )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
input_thread_t *p_input; input_thread_t *p_input;
...@@ -489,8 +509,11 @@ MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -489,8 +509,11 @@ MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container )
else else
psz_playback_status = PLAYBACK_STATUS_STOPPED; psz_playback_status = PLAYBACK_STATUS_STOPPED;
dbus_message_iter_append_basic( container, DBUS_TYPE_STRING, if( !dbus_message_iter_append_basic( container, DBUS_TYPE_STRING,
&psz_playback_status ); &psz_playback_status ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( PlaybackStatus ) DBUS_METHOD( PlaybackStatus )
...@@ -511,11 +534,12 @@ DBUS_METHOD( PlaybackStatus ) ...@@ -511,11 +534,12 @@ DBUS_METHOD( PlaybackStatus )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
double d_rate; double d_rate;
input_thread_t *p_input; input_thread_t *p_input;
if( ( p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist ) ) ) if( ( p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist ) ) )
{ {
d_rate = var_GetFloat( p_input, "rate" ); d_rate = var_GetFloat( p_input, "rate" );
...@@ -524,7 +548,11 @@ MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -524,7 +548,11 @@ MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container )
else else
d_rate = 1.0; d_rate = 1.0;
dbus_message_iter_append_basic( container, DBUS_TYPE_DOUBLE, &d_rate ); if( !dbus_message_iter_append_basic( container, DBUS_TYPE_DOUBLE,
&d_rate ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( RateGet ) DBUS_METHOD( RateGet )
...@@ -610,7 +638,7 @@ DBUS_METHOD( MaximumRate ) ...@@ -610,7 +638,7 @@ DBUS_METHOD( MaximumRate )
REPLY_SEND; REPLY_SEND;
} }
static void static int
MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
const char *psz_loop_status; const char *psz_loop_status;
...@@ -624,8 +652,11 @@ MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -624,8 +652,11 @@ MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container )
else else
psz_loop_status = LOOP_STATUS_NONE; psz_loop_status = LOOP_STATUS_NONE;
dbus_message_iter_append_basic( container, DBUS_TYPE_STRING, if( !dbus_message_iter_append_basic( container, DBUS_TYPE_STRING,
&psz_loop_status ); &psz_loop_status ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
} }
DBUS_METHOD( LoopStatusGet ) DBUS_METHOD( LoopStatusGet )
...@@ -877,6 +908,16 @@ int SeekedEmit( intf_thread_t * p_intf ) ...@@ -877,6 +908,16 @@ int SeekedEmit( intf_thread_t * p_intf )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
#define PROPERTY_MAPPING_BEGIN if( 0 ) {}
#define PROPERTY_ENTRY( prop, signature ) \
else if( !strcmp( ppsz_properties[i], #prop ) ) \
{ \
if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_intf, \
&changed_properties, #prop, signature, Marshal##prop ) ) \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
}
#define PROPERTY_MAPPING_END else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
/** /**
* PropertiesChangedSignal() synthetizes and sends the * PropertiesChangedSignal() synthetizes and sends the
* org.freedesktop.DBus.Properties.PropertiesChanged signal * org.freedesktop.DBus.Properties.PropertiesChanged signal
...@@ -886,7 +927,7 @@ PropertiesChangedSignal( intf_thread_t *p_intf, ...@@ -886,7 +927,7 @@ PropertiesChangedSignal( intf_thread_t *p_intf,
vlc_dictionary_t *p_changed_properties ) vlc_dictionary_t *p_changed_properties )
{ {
DBusConnection *p_conn = p_intf->p_sys->p_conn; DBusConnection *p_conn = p_intf->p_sys->p_conn;
DBusMessageIter changed_properties, invalidated_properties, entry, variant; DBusMessageIter changed_properties, invalidated_properties;
const char *psz_interface_name = DBUS_MPRIS_PLAYER_INTERFACE; const char *psz_interface_name = DBUS_MPRIS_PLAYER_INTERFACE;
char **ppsz_properties = NULL; char **ppsz_properties = NULL;
int i_properties = 0; int i_properties = 0;
...@@ -897,106 +938,50 @@ PropertiesChangedSignal( intf_thread_t *p_intf, ...@@ -897,106 +938,50 @@ PropertiesChangedSignal( intf_thread_t *p_intf,
OUT_ARGUMENTS; OUT_ARGUMENTS;
ADD_STRING( &psz_interface_name ); ADD_STRING( &psz_interface_name );
dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}",
&changed_properties ); if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}",
&changed_properties ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
i_properties = vlc_dictionary_keys_count( p_changed_properties ); i_properties = vlc_dictionary_keys_count( p_changed_properties );
ppsz_properties = vlc_dictionary_all_keys( p_changed_properties ); ppsz_properties = vlc_dictionary_all_keys( p_changed_properties );
for( int i = 0; i < i_properties; i++ ) for( int i = 0; i < i_properties; i++ )
{ {
dbus_message_iter_open_container( &changed_properties, PROPERTY_MAPPING_BEGIN
DBUS_TYPE_DICT_ENTRY, NULL, PROPERTY_ENTRY( Metadata, "a{sv}" )
&entry ); PROPERTY_ENTRY( PlaybackStatus, "s" )
PROPERTY_ENTRY( LoopStatus, "s" )
PROPERTY_ENTRY( Rate, "d" )
PROPERTY_ENTRY( Shuffle, "b" )
PROPERTY_ENTRY( Volume, "d" )
PROPERTY_ENTRY( CanSeek, "b" )
PROPERTY_ENTRY( CanPlay, "b" )
PROPERTY_ENTRY( CanPause, "b" )
PROPERTY_MAPPING_END
dbus_message_iter_append_basic( &entry, DBUS_TYPE_STRING,
&ppsz_properties[i] );
if( !strcmp( ppsz_properties[i], "Metadata" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "a{sv}",
&variant );
MarshalMetadata( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "PlaybackStatus" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "s",
&variant );
MarshalPlaybackStatus( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "LoopStatus" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "s",
&variant );
MarshalLoopStatus( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "Rate" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "d",
&variant );
MarshalRate( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "Shuffle" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "b",
&variant );
MarshalShuffle( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "Volume" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "d",
&variant );
MarshalVolume( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "CanSeek" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "b",
&variant );
MarshalCanSeek( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "CanPlay" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "b",
&variant );
MarshalCanPlay( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
else if( !strcmp( ppsz_properties[i], "CanPause" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "b",
&variant );
MarshalCanPause( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
dbus_message_iter_close_container( &changed_properties, &entry );
free( ppsz_properties[i] ); free( ppsz_properties[i] );
} }
dbus_message_iter_close_container( &args, &changed_properties ); if( !dbus_message_iter_close_container( &args, &changed_properties ) )
dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s", return DBUS_HANDLER_RESULT_NEED_MEMORY;
&invalidated_properties );
dbus_message_iter_close_container( &args, &invalidated_properties ); if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s",
&invalidated_properties ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_close_container( &args, &invalidated_properties ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
free( ppsz_properties ); free( ppsz_properties );
SIGNAL_SEND; SIGNAL_SEND;
} }
#undef PROPERTY_MAPPING_BEGIN
#undef PROPERTY_ADD
#undef PROPERTY_MAPPING_END
/***************************************************************************** /*****************************************************************************
* PropertiesChangedEmit: Emits the Seeked signal * PropertiesChangedEmit: Emits the Seeked signal
*****************************************************************************/ *****************************************************************************/
......
...@@ -80,7 +80,9 @@ MarshalIdentity( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -80,7 +80,9 @@ MarshalIdentity( intf_thread_t *p_intf, DBusMessageIter *container )
VLC_UNUSED( p_intf ); VLC_UNUSED( p_intf );
const char *psz_id = _("VLC media player"); const char *psz_id = _("VLC media player");
dbus_message_iter_append_basic( container, DBUS_TYPE_STRING, &psz_id ); if (!dbus_message_iter_append_basic( container, DBUS_TYPE_STRING, &psz_id ))
return VLC_ENOMEM;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -119,7 +121,9 @@ MarshalCanSetFullscreen( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -119,7 +121,9 @@ MarshalCanSetFullscreen( intf_thread_t *p_intf, DBusMessageIter *container )
} }
} }
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ); if (!dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ))
return VLC_ENOMEM;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -149,8 +153,10 @@ MarshalFullscreen( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -149,8 +153,10 @@ MarshalFullscreen( intf_thread_t *p_intf, DBusMessageIter *container )
else else
b_fullscreen = FALSE; b_fullscreen = FALSE;
dbus_message_iter_append_basic( container, if (!dbus_message_iter_append_basic( container,
DBUS_TYPE_BOOLEAN, &b_fullscreen ); DBUS_TYPE_BOOLEAN, &b_fullscreen ))
return VLC_ENOMEM;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -202,7 +208,9 @@ MarshalCanQuit( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -202,7 +208,9 @@ MarshalCanQuit( intf_thread_t *p_intf, DBusMessageIter *container )
VLC_UNUSED( p_intf ); VLC_UNUSED( p_intf );
const dbus_bool_t b_ret = TRUE; const dbus_bool_t b_ret = TRUE;
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ); if (!dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ))
return VLC_ENOMEM;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -228,7 +236,9 @@ MarshalCanRaise( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -228,7 +236,9 @@ MarshalCanRaise( intf_thread_t *p_intf, DBusMessageIter *container )
VLC_UNUSED( p_intf ); VLC_UNUSED( p_intf );
const dbus_bool_t b_ret = FALSE; const dbus_bool_t b_ret = FALSE;
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ); if (!dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ))
return VLC_ENOMEM;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -254,7 +264,9 @@ MarshalHasTrackList( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -254,7 +264,9 @@ MarshalHasTrackList( intf_thread_t *p_intf, DBusMessageIter *container )
VLC_UNUSED( p_intf ); VLC_UNUSED( p_intf );
const dbus_bool_t b_ret = FALSE; const dbus_bool_t b_ret = FALSE;
dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ); if (!dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_ret ))
return VLC_ENOMEM;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -280,7 +292,9 @@ MarshalDesktopEntry( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -280,7 +292,9 @@ MarshalDesktopEntry( intf_thread_t *p_intf, DBusMessageIter *container )
VLC_UNUSED( p_intf ); VLC_UNUSED( p_intf );
const char* psz_ret = PACKAGE; const char* psz_ret = PACKAGE;
dbus_message_iter_append_basic( container, DBUS_TYPE_STRING, &psz_ret ); if (!dbus_message_iter_append_basic( container, DBUS_TYPE_STRING, &psz_ret ))
return VLC_ENOMEM;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -555,12 +569,22 @@ handle_root ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this ) ...@@ -555,12 +569,22 @@ handle_root ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
* org.freedesktop.DBus.Properties.PropertiesChanged signal * org.freedesktop.DBus.Properties.PropertiesChanged signal
*/ */
#define PROPERTY_MAPPING_BEGIN if( 0 ) {}
#define PROPERTY_ENTRY( prop, signature ) \
else if( !strcmp( ppsz_properties[i], #prop ) ) \
{ \
if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_intf, \
&changed_properties, #prop, signature, Marshal##prop ) ) \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
}
#define PROPERTY_MAPPING_END else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
static DBusHandlerResult static DBusHandlerResult
PropertiesChangedSignal( intf_thread_t *p_intf, PropertiesChangedSignal( intf_thread_t *p_intf,
vlc_dictionary_t *p_changed_properties ) vlc_dictionary_t *p_changed_properties )
{ {
DBusConnection *p_conn = p_intf->p_sys->p_conn; DBusConnection *p_conn = p_intf->p_sys->p_conn;
DBusMessageIter changed_properties, invalidated_properties, entry, variant; DBusMessageIter changed_properties, invalidated_properties;
const char *psz_interface_name = DBUS_MPRIS_ROOT_INTERFACE; const char *psz_interface_name = DBUS_MPRIS_ROOT_INTERFACE;
char **ppsz_properties = NULL; char **ppsz_properties = NULL;
int i_properties = 0; int i_properties = 0;
...@@ -571,40 +595,33 @@ PropertiesChangedSignal( intf_thread_t *p_intf, ...@@ -571,40 +595,33 @@ PropertiesChangedSignal( intf_thread_t *p_intf,
OUT_ARGUMENTS; OUT_ARGUMENTS;
ADD_STRING( &psz_interface_name ); ADD_STRING( &psz_interface_name );
dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}",
&changed_properties ); if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}",
&changed_properties ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
i_properties = vlc_dictionary_keys_count( p_changed_properties ); i_properties = vlc_dictionary_keys_count( p_changed_properties );
ppsz_properties = vlc_dictionary_all_keys( p_changed_properties ); ppsz_properties = vlc_dictionary_all_keys( p_changed_properties );
for( int i = 0; i < i_properties; i++ ) for( int i = 0; i < i_properties; i++ )
{ {
dbus_message_iter_open_container( &changed_properties, PROPERTY_MAPPING_BEGIN
DBUS_TYPE_DICT_ENTRY, NULL, PROPERTY_ENTRY( Fullscreen, "b" )
&entry ); PROPERTY_MAPPING_END
dbus_message_iter_append_basic( &entry, DBUS_TYPE_STRING,
&ppsz_properties[i] );
if( !strcmp( ppsz_properties[i], "Fullscreen" ) )
{
dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, "b",
&variant );
MarshalFullscreen( p_intf, &variant );
dbus_message_iter_close_container( &entry, &variant );
}
dbus_message_iter_close_container( &changed_properties, &entry );
free( ppsz_properties[i] ); free( ppsz_properties[i] );
} }
dbus_message_iter_close_container( &args, &changed_properties ); if( !dbus_message_iter_close_container( &args, &changed_properties ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s",
&invalidated_properties ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s", if( !dbus_message_iter_close_container( &args, &invalidated_properties ) )
&invalidated_properties ); return DBUS_HANDLER_RESULT_NEED_MEMORY;
dbus_message_iter_close_container( &args, &invalidated_properties );
free( ppsz_properties ); free( ppsz_properties );
SIGNAL_SEND; SIGNAL_SEND;
......
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