Commit 6ae4c72d authored by Alex Merry's avatar Alex Merry Committed by Mirsal Ennaime

dbus: Standardise property getters

There was a lot of repeated code, some of which properly checked return
values and some of which didn't.  This is all replaced and folded into
the GetProperty function of each interface.

A side-effect is that it should be more efficient (we only check the
interface argument once instead of once for each property, and there
should be a smaller overall code size).
Signed-off-by: default avatarMirsal Ennaime <mirsal@videolan.org>
parent 3aa9a4ad
...@@ -39,11 +39,10 @@ ...@@ -39,11 +39,10 @@
#include "dbus_player.h" #include "dbus_player.h"
#include "dbus_common.h" #include "dbus_common.h"
static int MarshalLoopStatus ( intf_thread_t *, DBusMessageIter * );
static int static int
MarshalPosition( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalPosition( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
/* returns position in microseconds */
dbus_int64_t i_pos; dbus_int64_t i_pos;
input_thread_t *p_input; input_thread_t *p_input;
p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist ); p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist );
...@@ -63,23 +62,6 @@ MarshalPosition( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -63,23 +62,6 @@ MarshalPosition( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( Position )
{ /* returns position in microseconds */
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "x", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalPosition( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( SetPosition ) DBUS_METHOD( SetPosition )
{ /* set position in microseconds */ { /* set position in microseconds */
...@@ -189,24 +171,6 @@ MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -189,24 +171,6 @@ MarshalVolume( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( VolumeGet )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "d", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalVolume( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( VolumeSet ) DBUS_METHOD( VolumeSet )
{ {
REPLY_INIT; REPLY_INIT;
...@@ -331,24 +295,6 @@ MarshalCanPlay( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -331,24 +295,6 @@ MarshalCanPlay( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanPlay )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalCanPlay( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -369,24 +315,6 @@ MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -369,24 +315,6 @@ MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanPause )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalCanPause( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalCanControl( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanControl( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -400,25 +328,6 @@ MarshalCanControl( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -400,25 +328,6 @@ MarshalCanControl( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanControl )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT,
"b", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalCanControl( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -439,24 +348,6 @@ MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -439,24 +348,6 @@ MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanSeek )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalCanSeek( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalShuffle( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalShuffle( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -469,24 +360,6 @@ MarshalShuffle( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -469,24 +360,6 @@ MarshalShuffle( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( ShuffleGet )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalShuffle( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( ShuffleSet ) DBUS_METHOD( ShuffleSet )
{ {
REPLY_INIT; REPLY_INIT;
...@@ -533,24 +406,6 @@ MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -533,24 +406,6 @@ MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( PlaybackStatus )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalPlaybackStatus( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -572,24 +427,6 @@ MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -572,24 +427,6 @@ MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( RateGet )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "d", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalRate( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( RateSet ) DBUS_METHOD( RateSet )
{ {
REPLY_INIT; REPLY_INIT;
...@@ -623,24 +460,6 @@ MarshalMinimumRate( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -623,24 +460,6 @@ MarshalMinimumRate( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( MinimumRate )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "d", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalMinimumRate( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalMaximumRate( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalMaximumRate( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -653,24 +472,6 @@ MarshalMaximumRate( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -653,24 +472,6 @@ MarshalMaximumRate( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( MaximumRate )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "d", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalMaximumRate( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -692,24 +493,6 @@ MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -692,24 +493,6 @@ MarshalLoopStatus( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( LoopStatusGet )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalLoopStatus( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( LoopStatusSet ) DBUS_METHOD( LoopStatusSet )
{ {
REPLY_INIT; REPLY_INIT;
...@@ -775,24 +558,6 @@ MarshalMetadata( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -775,24 +558,6 @@ MarshalMetadata( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( Metadata )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT,
"a{sv}", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( MarshalMetadata( p_this, &v ) != VLC_SUCCESS ||
!dbus_message_iter_close_container( &args, &v ) ) {
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
REPLY_SEND;
}
/****************************************************************************** /******************************************************************************
* Seeked: non-linear playback signal * Seeked: non-linear playback signal
...@@ -820,11 +585,22 @@ DBUS_SIGNAL( SeekedSignal ) ...@@ -820,11 +585,22 @@ DBUS_SIGNAL( SeekedSignal )
} }
#define PROPERTY_MAPPING_BEGIN if( 0 ) {} #define PROPERTY_MAPPING_BEGIN if( 0 ) {}
#define PROPERTY_FUNC( interface, property, function ) \ #define PROPERTY_GET_FUNC( prop, signature ) \
else if( !strcmp( psz_interface_name, interface ) && \ else if( !strcmp( psz_property_name, #prop ) ) { \
!strcmp( psz_property_name, property ) ) \ if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, signature, &v ) ) \
return function( p_conn, p_from, p_this ); return DBUS_HANDLER_RESULT_NEED_MEMORY; \
#define PROPERTY_MAPPING_END return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if( VLC_SUCCESS != Marshal##prop( p_this, &v ) ) { \
dbus_message_iter_abandon_container( &args, &v ); \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
} \
if( !dbus_message_iter_close_container( &args, &v ) ) \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
}
#define PROPERTY_SET_FUNC( prop ) \
else if( !strcmp( psz_property_name, #prop ) ) { \
return prop##Set( p_conn, p_from, p_this ); \
}
#define PROPERTY_MAPPING_END else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
DBUS_METHOD( GetProperty ) DBUS_METHOD( GetProperty )
{ {
...@@ -850,21 +626,31 @@ DBUS_METHOD( GetProperty ) ...@@ -850,21 +626,31 @@ DBUS_METHOD( GetProperty )
msg_Dbg( (vlc_object_t*) p_this, "Getting property %s", msg_Dbg( (vlc_object_t*) p_this, "Getting property %s",
psz_property_name ); psz_property_name );
if( strcmp( psz_interface_name, DBUS_MPRIS_PLAYER_INTERFACE ) ) {
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
PROPERTY_MAPPING_BEGIN PROPERTY_MAPPING_BEGIN
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Metadata", Metadata ) PROPERTY_GET_FUNC( Metadata, "a{sv}" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Position", Position ) PROPERTY_GET_FUNC( Position, "x" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "PlaybackStatus", PlaybackStatus ) PROPERTY_GET_FUNC( PlaybackStatus, "s" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "LoopStatus", LoopStatusGet ) PROPERTY_GET_FUNC( LoopStatus, "s" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Shuffle", ShuffleGet ) PROPERTY_GET_FUNC( Shuffle, "b" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Volume", VolumeGet ) PROPERTY_GET_FUNC( Volume, "d" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Rate", RateGet ) PROPERTY_GET_FUNC( Rate, "d" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "MinimumRate", MinimumRate ) PROPERTY_GET_FUNC( MinimumRate, "d" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "MaximumRate", MaximumRate ) PROPERTY_GET_FUNC( MaximumRate, "d" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanControl", CanControl ) PROPERTY_GET_FUNC( CanControl, "b" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanPlay", CanPlay ) PROPERTY_GET_FUNC( CanPlay, "b" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanPause", CanPause ) PROPERTY_GET_FUNC( CanPause, "b" )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "CanSeek", CanSeek ) PROPERTY_GET_FUNC( CanSeek, "b" )
PROPERTY_MAPPING_END PROPERTY_MAPPING_END
REPLY_SEND;
} }
DBUS_METHOD( SetProperty ) DBUS_METHOD( SetProperty )
...@@ -889,15 +675,16 @@ DBUS_METHOD( SetProperty ) ...@@ -889,15 +675,16 @@ DBUS_METHOD( SetProperty )
} }
PROPERTY_MAPPING_BEGIN PROPERTY_MAPPING_BEGIN
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "LoopStatus", LoopStatusSet ) PROPERTY_SET_FUNC( LoopStatus )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Shuffle", ShuffleSet ) PROPERTY_SET_FUNC( Shuffle )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Volume", VolumeSet ) PROPERTY_SET_FUNC( Volume )
PROPERTY_FUNC( DBUS_MPRIS_PLAYER_INTERFACE, "Rate", RateSet ) PROPERTY_SET_FUNC( Rate )
PROPERTY_MAPPING_END PROPERTY_MAPPING_END
} }
#undef PROPERTY_MAPPING_BEGIN #undef PROPERTY_MAPPING_BEGIN
#undef PROPERTY_GET_FUNC #undef PROPERTY_GET_FUNC
#undef PROPERTY_SET_FUNC
#undef PROPERTY_MAPPING_END #undef PROPERTY_MAPPING_END
#define METHOD_FUNC( interface, method, function ) \ #define METHOD_FUNC( interface, method, function ) \
......
...@@ -86,22 +86,6 @@ MarshalIdentity( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -86,22 +86,6 @@ MarshalIdentity( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( Identity )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
MarshalIdentity( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalCanSetFullscreen( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanSetFullscreen( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -127,22 +111,6 @@ MarshalCanSetFullscreen( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -127,22 +111,6 @@ MarshalCanSetFullscreen( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanSetFullscreen )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v );
MarshalCanSetFullscreen( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalFullscreen( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalFullscreen( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -160,24 +128,6 @@ MarshalFullscreen( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -160,24 +128,6 @@ MarshalFullscreen( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( FullscreenGet )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
MarshalFullscreen( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( FullscreenSet ) DBUS_METHOD( FullscreenSet )
{ {
REPLY_INIT; REPLY_INIT;
...@@ -214,22 +164,6 @@ MarshalCanQuit( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -214,22 +164,6 @@ MarshalCanQuit( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanQuit )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v );
MarshalCanQuit( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalCanRaise( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanRaise( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -242,22 +176,6 @@ MarshalCanRaise( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -242,22 +176,6 @@ MarshalCanRaise( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanRaise )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v );
MarshalCanRaise( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalHasTrackList( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalHasTrackList( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -270,22 +188,6 @@ MarshalHasTrackList( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -270,22 +188,6 @@ MarshalHasTrackList( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( HasTrackList )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v );
MarshalHasTrackList( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalDesktopEntry( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalDesktopEntry( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -298,22 +200,6 @@ MarshalDesktopEntry( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -298,22 +200,6 @@ MarshalDesktopEntry( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( DesktopEntry )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
MarshalDesktopEntry( p_this, &v );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalSupportedMimeTypes( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalSupportedMimeTypes( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -343,23 +229,6 @@ MarshalSupportedMimeTypes( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -343,23 +229,6 @@ MarshalSupportedMimeTypes( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( SupportedMimeTypes )
{
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "as", &v );
if( VLC_SUCCESS != MarshalSupportedMimeTypes( p_this, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalSupportedUriSchemes( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalSupportedUriSchemes( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -389,24 +258,6 @@ MarshalSupportedUriSchemes( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -389,24 +258,6 @@ MarshalSupportedUriSchemes( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( SupportedUriSchemes )
{
VLC_UNUSED( p_this );
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "as", &v );
if( VLC_SUCCESS != MarshalSupportedUriSchemes( p_this, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( Quit ) DBUS_METHOD( Quit )
{ /* exits vlc */ { /* exits vlc */
REPLY_INIT; REPLY_INIT;
...@@ -422,11 +273,22 @@ DBUS_METHOD( Raise ) ...@@ -422,11 +273,22 @@ DBUS_METHOD( Raise )
} }
#define PROPERTY_MAPPING_BEGIN if( 0 ) {} #define PROPERTY_MAPPING_BEGIN if( 0 ) {}
#define PROPERTY_FUNC( interface, property, function ) \ #define PROPERTY_GET_FUNC( prop, signature ) \
else if( !strcmp( psz_interface_name, interface ) && \ else if( !strcmp( psz_property_name, #prop ) ) { \
!strcmp( psz_property_name, property ) ) \ if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, signature, &v ) ) \
return function( p_conn, p_from, p_this ); return DBUS_HANDLER_RESULT_NEED_MEMORY; \
#define PROPERTY_MAPPING_END return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if( VLC_SUCCESS != Marshal##prop( p_this, &v ) ) { \
dbus_message_iter_abandon_container( &args, &v ); \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
} \
if( !dbus_message_iter_close_container( &args, &v ) ) \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
}
#define PROPERTY_SET_FUNC( prop ) \
else if( !strcmp( psz_property_name, #prop ) ) { \
return prop##Set( p_conn, p_from, p_this ); \
}
#define PROPERTY_MAPPING_END else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
DBUS_METHOD( GetProperty ) DBUS_METHOD( GetProperty )
{ {
...@@ -452,17 +314,27 @@ DBUS_METHOD( GetProperty ) ...@@ -452,17 +314,27 @@ DBUS_METHOD( GetProperty )
msg_Dbg( (vlc_object_t*) p_this, "Getting property %s", msg_Dbg( (vlc_object_t*) p_this, "Getting property %s",
psz_property_name ); psz_property_name );
if( strcmp( psz_interface_name, DBUS_MPRIS_ROOT_INTERFACE ) ) {
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
PROPERTY_MAPPING_BEGIN PROPERTY_MAPPING_BEGIN
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Identity", Identity ) PROPERTY_GET_FUNC( Identity, "s" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "DesktopEntry", DesktopEntry ) PROPERTY_GET_FUNC( CanSetFullscreen, "b" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "SupportedMimeTypes", SupportedMimeTypes ) PROPERTY_GET_FUNC( Fullscreen, "b" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "SupportedUriSchemes", SupportedUriSchemes ) PROPERTY_GET_FUNC( CanQuit, "b" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "HasTrackList", HasTrackList ) PROPERTY_GET_FUNC( CanRaise, "b" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "CanQuit", CanQuit ) PROPERTY_GET_FUNC( HasTrackList, "b" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "CanSetFullscreen", CanSetFullscreen ) PROPERTY_GET_FUNC( DesktopEntry, "s" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Fullscreen", FullscreenGet ) PROPERTY_GET_FUNC( SupportedMimeTypes, "as" )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "CanRaise", CanRaise ) PROPERTY_GET_FUNC( SupportedUriSchemes, "as" )
PROPERTY_MAPPING_END PROPERTY_MAPPING_END
REPLY_SEND;
} }
DBUS_METHOD( SetProperty ) DBUS_METHOD( SetProperty )
...@@ -487,12 +359,13 @@ DBUS_METHOD( SetProperty ) ...@@ -487,12 +359,13 @@ DBUS_METHOD( SetProperty )
} }
PROPERTY_MAPPING_BEGIN PROPERTY_MAPPING_BEGIN
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Fullscreen", FullscreenSet ) PROPERTY_SET_FUNC( Fullscreen )
PROPERTY_MAPPING_END PROPERTY_MAPPING_END
} }
#undef PROPERTY_MAPPING_BEGIN #undef PROPERTY_MAPPING_BEGIN
#undef PROPERTY_GET_FUNC #undef PROPERTY_GET_FUNC
#undef PROPERTY_SET_FUNC
#undef PROPERTY_MAPPING_END #undef PROPERTY_MAPPING_END
#define ADD_PROPERTY( prop, signature ) \ #define ADD_PROPERTY( prop, signature ) \
......
...@@ -328,28 +328,6 @@ MarshalTracks( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -328,28 +328,6 @@ MarshalTracks( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( Tracks )
{ /* Tracks property */
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "ao", &v );
if( MarshalTracks( p_this, &v ) != VLC_SUCCESS )
{
dbus_message_iter_abandon_container( &args, &v );
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
static int static int
MarshalCanEditTracks( intf_thread_t *p_intf, DBusMessageIter *container ) MarshalCanEditTracks( intf_thread_t *p_intf, DBusMessageIter *container )
{ {
...@@ -362,37 +340,25 @@ MarshalCanEditTracks( intf_thread_t *p_intf, DBusMessageIter *container ) ...@@ -362,37 +340,25 @@ MarshalCanEditTracks( intf_thread_t *p_intf, DBusMessageIter *container )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
DBUS_METHOD( CanEditTracks ) #define PROPERTY_MAPPING_BEGIN if( 0 ) {}
{ /* CanEditTracks property */ #define PROPERTY_GET_FUNC( prop, signature ) \
REPLY_INIT; else if( !strcmp( psz_property_name, #prop ) ) { \
OUT_ARGUMENTS; if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, signature, &v ) ) \
return DBUS_HANDLER_RESULT_NEED_MEMORY; \
DBusMessageIter v; if( VLC_SUCCESS != Marshal##prop( p_this, &v ) ) { \
dbus_message_iter_abandon_container( &args, &v ); \
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "b", &v ) ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \
return DBUS_HANDLER_RESULT_NEED_MEMORY; } \
if( !dbus_message_iter_close_container( &args, &v ) ) \
if( MarshalCanEditTracks( p_this, &v ) != VLC_SUCCESS ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \
{
dbus_message_iter_abandon_container( &args, &v );
return DBUS_HANDLER_RESULT_NEED_MEMORY;
} }
if( !dbus_message_iter_close_container( &args, &v ) ) #define PROPERTY_SET_FUNC( prop ) \
{ else if( !strcmp( psz_property_name, #prop ) ) { \
dbus_message_iter_abandon_container( &args, &v ); return prop##Set( p_conn, p_from, p_this ); \
return DBUS_HANDLER_RESULT_NEED_MEMORY;
} }
#define PROPERTY_MAPPING_END else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
REPLY_SEND;
}
#define PROPERTY_MAPPING_BEGIN if( 0 ) {}
#define PROPERTY_FUNC( interface, property, function ) \
else if( !strcmp( psz_interface_name, interface ) && \
!strcmp( psz_property_name, property ) ) \
return function( p_conn, p_from, p_this );
#define PROPERTY_MAPPING_END return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
DBUS_METHOD( GetProperty ) DBUS_METHOD( GetProperty )
{ {
...@@ -418,15 +384,25 @@ DBUS_METHOD( GetProperty ) ...@@ -418,15 +384,25 @@ DBUS_METHOD( GetProperty )
msg_Dbg( (vlc_object_t*) p_this, "Getting property %s", msg_Dbg( (vlc_object_t*) p_this, "Getting property %s",
psz_property_name ); psz_property_name );
if( strcmp( psz_interface_name, DBUS_MPRIS_TRACKLIST_INTERFACE ) ) {
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
REPLY_INIT;
OUT_ARGUMENTS;
DBusMessageIter v;
PROPERTY_MAPPING_BEGIN PROPERTY_MAPPING_BEGIN
PROPERTY_FUNC( DBUS_MPRIS_TRACKLIST_INTERFACE, "Tracks", Tracks ) PROPERTY_GET_FUNC( Tracks, "ao" )
PROPERTY_FUNC( DBUS_MPRIS_TRACKLIST_INTERFACE, "CanEditTracks", PROPERTY_GET_FUNC( CanEditTracks, "b" )
CanEditTracks )
PROPERTY_MAPPING_END PROPERTY_MAPPING_END
REPLY_SEND;
} }
#undef PROPERTY_MAPPING_BEGIN #undef PROPERTY_MAPPING_BEGIN
#undef PROPERTY_GET_FUNC #undef PROPERTY_GET_FUNC
#undef PROPERTY_SET_FUNC
#undef PROPERTY_MAPPING_END #undef PROPERTY_MAPPING_END
#define METHOD_FUNC( interface, method, function ) \ #define METHOD_FUNC( interface, method, function ) \
......
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