[vlc-devel] [PATCH 8/8] Add CanGoNext/Previous to D-Bus interface
Mirsal Ennaime
mirsal at videolan.org
Mon Jan 28 18:40:19 CET 2013
Hey Alex,
On Mon, 2013-01-28 at 11:54 +0000, Alex Merry wrote:
> These are required by the spec. We just set them to true, to match the
> fact that the buttons on the main interface are never disabled.
> ---
> modules/control/dbus/dbus_player.c | 62 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 62 insertions(+)
Please add checks for memory allocation failure on calls to
dbus_message_iter_append_basic and to the marshaller functions.
Patch looks good to me otherwise.
> diff --git a/modules/control/dbus/dbus_player.c b/modules/control/dbus/dbus_player.c
> index 23f1554..005110f 100644
> --- a/modules/control/dbus/dbus_player.c
> +++ b/modules/control/dbus/dbus_player.c
> @@ -312,6 +312,64 @@ DBUS_METHOD( OpenUri )
> }
>
> static int
> +MarshalCanGoNext( intf_thread_t *p_intf, DBusMessageIter *container )
> +{
> + VLC_UNUSED( p_intf );
> +
> + dbus_bool_t b_can_go_next = TRUE;
> +
> + dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_can_go_next );
> + return VLC_SUCCESS;
> +}
> +
> +DBUS_METHOD( CanGoNext )
> +{
> + REPLY_INIT;
> + OUT_ARGUMENTS;
> +
> + DBusMessageIter v;
> +
> + if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) )
> + return DBUS_HANDLER_RESULT_NEED_MEMORY;
> +
> + MarshalCanGoNext( p_this, &v );
> +
> + if( !dbus_message_iter_close_container( &args, &v ) )
> + return DBUS_HANDLER_RESULT_NEED_MEMORY;
> +
> + REPLY_SEND;
> +}
> +
> +static int
> +MarshalCanGoPrevious( intf_thread_t *p_intf, DBusMessageIter *container )
> +{
> + VLC_UNUSED( p_intf );
> +
> + dbus_bool_t b_can_go_previous = TRUE;
> +
> + dbus_message_iter_append_basic( container, DBUS_TYPE_BOOLEAN, &b_can_go_previous );
> + return VLC_SUCCESS;
> +}
> +
> +DBUS_METHOD( CanGoPrevious )
> +{
> + REPLY_INIT;
> + OUT_ARGUMENTS;
> +
> + DBusMessageIter v;
> +
> + if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) )
> + return DBUS_HANDLER_RESULT_NEED_MEMORY;
> +
> + MarshalCanGoPrevious( p_this, &v );
> +
> + if( !dbus_message_iter_close_container( &args, &v ) )
> + return DBUS_HANDLER_RESULT_NEED_MEMORY;
> +
> + REPLY_SEND;
> +}
> +
> +static int
> MarshalCanPlay( intf_thread_t *p_intf, DBusMessageIter *container )
> {
> playlist_t *p_playlist = p_intf->p_sys->p_playlist;
> @@ -824,6 +882,8 @@ DBUS_METHOD( GetProperty )
> PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "MaximumRate", MaximumRate )
> PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanControl", CanControl )
> PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanPlay", CanPlay )
> + PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanGoNext", CanGoNext )
> + PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanGoPrevious", CanGoPrevious )
> PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanPause", CanPause )
> PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanSeek", CanSeek )
> PROPERTY_MAPPING_END
> @@ -905,6 +965,8 @@ DBUS_METHOD( GetAllProperties )
> ADD_PROPERTY ( MaximumRate, "d" );
> ADD_PROPERTY ( CanControl, "b" );
> ADD_PROPERTY ( CanPlay, "b" );
> + ADD_PROPERTY ( CanGoNext, "b" );
> + ADD_PROPERTY ( CanGoPrevious, "b" );
> ADD_PROPERTY ( CanPause, "b" );
> ADD_PROPERTY ( CanSeek, "b" );
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130128/61204e65/attachment.sig>
More information about the vlc-devel
mailing list