[vlc-devel] [PATCH 5/8] Add Properties.GetAll support to all D-Bus interfaces
Mirsal Ennaime
mirsal at videolan.org
Mon Jan 28 16:25:45 CET 2013
Hello Alex,
Looks good to me.
On Mon, 2013-01-28 at 11:54 +0000, Alex Merry wrote:
> ---
> modules/control/dbus/dbus_introspect.h | 6 ++++
> modules/control/dbus/dbus_player.c | 54 +++++++++++++++++++++++++++++++++-
> modules/control/dbus/dbus_tracklist.c | 42 ++++++++++++++++++++++++++
> 3 files changed, 101 insertions(+), 1 deletion(-)
>
> diff --git a/modules/control/dbus/dbus_introspect.h b/modules/control/dbus/dbus_introspect.h
> index 31f4c9b..0b69167 100644
> --- a/modules/control/dbus/dbus_introspect.h
> +++ b/modules/control/dbus/dbus_introspect.h
> @@ -4,10 +4,12 @@
> * Copyright © 2006-2011 Rafaël Carré
> * Copyright © 2007-2011 Mirsal Ennaime
> * Copyright © 2009-2011 The VideoLAN team
> + * Copyright © 2013 Alex Merry
> * $Id$
> *
> * Authors: Mirsal Ennaime <mirsal at mirsal fr>
> * Rafaël Carré <funman at videolanorg>
> + * Alex Merry <dev at randomguy3 me uk>
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> @@ -50,6 +52,10 @@ static const char* psz_introspection_xml =
> " <arg direction=\"in\" type=\"s\"/>\n"
> " <arg direction=\"in\" type=\"v\"/>\n"
> " </method>\n"
> +" <method name=\"GetAll\">\n"
> +" <arg direction=\"in\" type=\"s\"/>\n"
> +" <arg direction=\"out\" type=\"a{sv}\"/>\n"
> +" </method>\n"
> " <signal name=\"PropertiesChanged\">\n"
> " <arg type=\"s\"/>\n"
> " <arg type=\"a{sv}\"/>\n"
> diff --git a/modules/control/dbus/dbus_player.c b/modules/control/dbus/dbus_player.c
> index e73b543..2ac46bd 100644
> --- a/modules/control/dbus/dbus_player.c
> +++ b/modules/control/dbus/dbus_player.c
> @@ -862,6 +862,58 @@ DBUS_METHOD( SetProperty )
> #undef PROPERTY_GET_FUNC
> #undef PROPERTY_MAPPING_END
>
> +#define ADD_PROPERTY( prop, signature ) \
> + if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \
> + &dict, #prop, signature, Marshal##prop ) ) \
> + return VLC_ENOMEM;
> +
> +DBUS_METHOD( GetAllProperties )
> +{
> + REPLY_INIT;
> + OUT_ARGUMENTS;
> +
> + DBusError error;
> + DBusMessageIter dict;
> +
> + char *const psz_interface_name = NULL;
> +
> + dbus_error_init( &error );
> + dbus_message_get_args( p_from, &error,
> + DBUS_TYPE_STRING, &psz_interface_name,
> + DBUS_TYPE_INVALID );
> +
> + if( dbus_error_is_set( &error ) )
> + {
> + msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s",
> + error.message );
> + dbus_error_free( &error );
> + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
> + }
> +
> + msg_Dbg( (vlc_object_t*) p_this, "Getting All properties" );
> +
> + dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}", &dict );
> +
> + ADD_PROPERTY ( Metadata, "a{sv}" );
> + ADD_PROPERTY ( Position, "x" );
> + ADD_PROPERTY ( PlaybackStatus, "s" );
> + ADD_PROPERTY ( LoopStatus, "s" );
> + ADD_PROPERTY ( Shuffle, "b" );
> + ADD_PROPERTY ( Volume, "d" );
> + ADD_PROPERTY ( Rate, "d" );
> + ADD_PROPERTY ( MinimumRate, "d" );
> + ADD_PROPERTY ( MaximumRate, "d" );
> + ADD_PROPERTY ( CanControl, "b" );
> + ADD_PROPERTY ( CanPlay, "b" );
> + ADD_PROPERTY ( CanPause, "b" );
> + ADD_PROPERTY ( CanSeek, "b" );
> +
> + dbus_message_iter_close_container( &args, &dict );
> + REPLY_SEND;
> +}
> +
> +#undef ADD_PROPERTY
> +
> #define METHOD_FUNC( interface, method, function ) \
> else if( dbus_message_is_method_call( p_from, interface, method ) )\
> return function( p_conn, p_from, p_this )
> @@ -872,7 +924,7 @@ handle_player ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
> if(0);
> METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Get", GetProperty );
> METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Set", SetProperty );
> -/* METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "GetAll", GetAllProperties );*/
> + METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "GetAll", GetAllProperties );
>
> /* here D-Bus method names are associated to an handler */
>
> diff --git a/modules/control/dbus/dbus_tracklist.c b/modules/control/dbus/dbus_tracklist.c
> index 49b33d1..e863cb2 100644
> --- a/modules/control/dbus/dbus_tracklist.c
> +++ b/modules/control/dbus/dbus_tracklist.c
> @@ -428,6 +428,47 @@ DBUS_METHOD( GetProperty )
> #undef PROPERTY_GET_FUNC
> #undef PROPERTY_MAPPING_END
>
> +#define ADD_PROPERTY( prop, signature ) \
> + if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \
> + &dict, #prop, signature, Marshal##prop ) ) \
> + return VLC_ENOMEM;
> +
> +DBUS_METHOD( GetAllProperties )
> +{
> + REPLY_INIT;
> + OUT_ARGUMENTS;
> +
> + DBusError error;
> + DBusMessageIter dict;
> +
> + char *const psz_interface_name = NULL;
> +
> + dbus_error_init( &error );
> + dbus_message_get_args( p_from, &error,
> + DBUS_TYPE_STRING, &psz_interface_name,
> + DBUS_TYPE_INVALID );
> +
> + if( dbus_error_is_set( &error ) )
> + {
> + msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s",
> + error.message );
> + dbus_error_free( &error );
> + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
> + }
> +
> + msg_Dbg( (vlc_object_t*) p_this, "Getting All properties" );
> +
> + dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}", &dict );
> +
> + ADD_PROPERTY ( Tracks, "ao" )
> + ADD_PROPERTY ( CanEditTracks, "b" )
> +
> + dbus_message_iter_close_container( &args, &dict );
> + REPLY_SEND;
> +}
> +
> +#undef ADD_PROPERTY
> +
> #define METHOD_FUNC( interface, method, function ) \
> else if( dbus_message_is_method_call( p_from, interface, method ) )\
> return function( p_conn, p_from, p_this )
> @@ -438,6 +479,7 @@ handle_tracklist ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
> if(0);
>
> METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Get", GetProperty );
> + METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "GetAll", GetAllProperties );
>
> /* here D-Bus method names are associated to an handler */
>
--
mirsal
-------------- 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/9f2de3ae/attachment.sig>
More information about the vlc-devel
mailing list