Commit 119aa810 authored by Alex Merry's avatar Alex Merry Committed by Mirsal Ennaime

Move helpers for GetAllProperties into dbus.c

This is in preparation for implementing GetAllProperties for the player
and tracklist interfaces.
Signed-off-by: default avatarMirsal Ennaime <mirsal@videolan.org>
parent 317f1e9c
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
* Copyright © 2006-2008 Rafaël Carré * Copyright © 2006-2008 Rafaël Carré
* Copyright © 2007-2012 Mirsal Ennaime * Copyright © 2007-2012 Mirsal Ennaime
* Copyright © 2009-2012 The VideoLAN team * Copyright © 2009-2012 The VideoLAN team
* Copyright © 2013 Alex Merry
* $Id$ * $Id$
* *
* Authors: Rafaël Carré <funman at videolanorg> * Authors: Rafaël Carré <funman at videolanorg>
* Mirsal Ennaime <mirsal at mirsal fr> * Mirsal Ennaime <mirsal at mirsal fr>
* Alex Merry <dev at randomguy3 me uk>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -1210,6 +1212,41 @@ int GetInputMeta( input_item_t* p_input, ...@@ -1210,6 +1212,41 @@ int GetInputMeta( input_item_t* p_input,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
int AddProperty( intf_thread_t *p_intf,
DBusMessageIter *p_container,
const char* psz_property_name,
const char* psz_signature,
int (*pf_marshaller) (intf_thread_t*, DBusMessageIter*) )
{
DBusMessageIter entry, v;
if( !dbus_message_iter_open_container( p_container,
DBUS_TYPE_DICT_ENTRY, NULL,
&entry ) )
return VLC_ENOMEM;
if( !dbus_message_iter_append_basic( &entry,
DBUS_TYPE_STRING,
&psz_property_name ) )
return VLC_ENOMEM;
if( !dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, psz_signature,
&v ) )
return VLC_ENOMEM;
if( VLC_SUCCESS != pf_marshaller( p_intf, &v ) )
return VLC_ENOMEM;
if( !dbus_message_iter_close_container( &entry, &v) )
return VLC_ENOMEM;
if( !dbus_message_iter_close_container( p_container, &entry ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
}
#undef ADD_META #undef ADD_META
#undef ADD_VLC_META_STRING #undef ADD_VLC_META_STRING
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
* Copyright © 2006-2008 Rafaël Carré * Copyright © 2006-2008 Rafaël Carré
* Copyright © 2007-2010 Mirsal Ennaime * Copyright © 2007-2010 Mirsal Ennaime
* Copyright © 2009-2010 The VideoLAN team * Copyright © 2009-2010 The VideoLAN team
* Copyright © 2013 Alex Merry
* $Id$ * $Id$
* *
* Authors: Mirsal Ennaime <mirsal dot ennaime at gmailcom> * Authors: Mirsal Ennaime <mirsal dot ennaime at gmailcom>
* Rafaël Carré <funman at videolanorg> * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -138,5 +140,10 @@ enum ...@@ -138,5 +140,10 @@ enum
int DemarshalSetPropertyValue( DBusMessage *p_msg, void *p_arg ); int DemarshalSetPropertyValue( DBusMessage *p_msg, void *p_arg );
int GetInputMeta ( input_item_t* p_input, DBusMessageIter *args ); int GetInputMeta ( input_item_t* p_input, DBusMessageIter *args );
int AddProperty ( intf_thread_t *p_intf,
DBusMessageIter *p_container,
const char* psz_property_name,
const char* psz_signature,
int (*pf_marshaller) (intf_thread_t*, DBusMessageIter*) );
#endif //dbus-common.h #endif //dbus-common.h
...@@ -478,42 +478,6 @@ DBUS_METHOD( SetProperty ) ...@@ -478,42 +478,6 @@ DBUS_METHOD( SetProperty )
#undef PROPERTY_GET_FUNC #undef PROPERTY_GET_FUNC
#undef PROPERTY_MAPPING_END #undef PROPERTY_MAPPING_END
static int
AddProperty( intf_thread_t *p_intf,
DBusMessageIter *p_container,
const char* psz_property_name,
const char* psz_signature,
int (*pf_marshaller) (intf_thread_t*, DBusMessageIter*) )
{
DBusMessageIter entry, v;
if( !dbus_message_iter_open_container( p_container,
DBUS_TYPE_DICT_ENTRY, NULL,
&entry ) )
return VLC_ENOMEM;
if( !dbus_message_iter_append_basic( &entry,
DBUS_TYPE_STRING,
&psz_property_name ) )
return VLC_ENOMEM;
if( !dbus_message_iter_open_container( &entry,
DBUS_TYPE_VARIANT, psz_signature,
&v ) )
return VLC_ENOMEM;
if( VLC_SUCCESS != pf_marshaller( p_intf, &v ) )
return VLC_ENOMEM;
if( !dbus_message_iter_close_container( &entry, &v) )
return VLC_ENOMEM;
if( !dbus_message_iter_close_container( p_container, &entry ) )
return VLC_ENOMEM;
return VLC_SUCCESS;
}
#define ADD_PROPERTY( prop, signature ) \ #define ADD_PROPERTY( prop, signature ) \
if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \ if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \
&dict, #prop, signature, Marshal##prop ) ) \ &dict, #prop, signature, Marshal##prop ) ) \
......
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