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

Add Properties.GetAll support to all D-Bus interfaces

Signed-off-by: default avatarMirsal Ennaime <mirsal@videolan.org>
parent 6ae4c72d
......@@ -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"
......
......@@ -687,6 +687,63 @@ DBUS_METHOD( SetProperty )
#undef PROPERTY_SET_FUNC
#undef PROPERTY_MAPPING_END
#define ADD_PROPERTY( prop, signature ) \
if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \
&dict, #prop, signature, Marshal##prop ) ) { \
dbus_message_iter_abandon_container( &args, &dict ); \
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" );
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}", &dict ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
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" );
if( !dbus_message_iter_close_container( &args, &dict ))
return DBUS_HANDLER_RESULT_NEED_MEMORY;
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 )
......@@ -697,7 +754,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 */
......
......@@ -370,8 +370,10 @@ DBUS_METHOD( SetProperty )
#define ADD_PROPERTY( prop, signature ) \
if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \
&dict, #prop, signature, Marshal##prop ) ) \
return VLC_ENOMEM;
&dict, #prop, signature, Marshal##prop ) ) { \
dbus_message_iter_abandon_container( &args, &dict ); \
return VLC_ENOMEM; \
}
DBUS_METHOD( GetAllProperties )
{
......@@ -398,7 +400,8 @@ DBUS_METHOD( GetAllProperties )
msg_Dbg( (vlc_object_t*) p_this, "Getting All properties" );
dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}", &dict );
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}", &dict ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
ADD_PROPERTY( Identity, "s" );
ADD_PROPERTY( DesktopEntry, "s" );
......@@ -410,7 +413,9 @@ DBUS_METHOD( GetAllProperties )
ADD_PROPERTY( Fullscreen, "b" );
ADD_PROPERTY( CanRaise, "b" );
dbus_message_iter_close_container( &args, &dict );
if( !dbus_message_iter_close_container( &args, &dict ))
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
......
......@@ -405,6 +405,52 @@ DBUS_METHOD( GetProperty )
#undef PROPERTY_SET_FUNC
#undef PROPERTY_MAPPING_END
#define ADD_PROPERTY( prop, signature ) \
if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \
&dict, #prop, signature, Marshal##prop ) ) { \
dbus_message_iter_abandon_container( &args, &dict ); \
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" );
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}", &dict ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
ADD_PROPERTY ( Tracks, "ao" )
ADD_PROPERTY ( CanEditTracks, "b" )
if( !dbus_message_iter_close_container( &args, &dict ))
return DBUS_HANDLER_RESULT_NEED_MEMORY;
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 )
......@@ -415,6 +461,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 */
......
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