[vlc-devel] [PATCH 2/8] Move helpers for GetAllProperties into dbus.c

Alex Merry dev at randomguy3.me.uk
Mon Jan 28 12:54:11 CET 2013


This is in preparation for implementing GetAllProperties for the player
and tracklist interfaces.
---
 modules/control/dbus/dbus.c        | 37 +++++++++++++++++++++++++++++++++++++
 modules/control/dbus/dbus_common.h |  7 +++++++
 modules/control/dbus/dbus_root.c   | 36 ------------------------------------
 3 files changed, 44 insertions(+), 36 deletions(-)

diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index a52bb74..e9dd35b 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -4,10 +4,12 @@
  * Copyright © 2006-2008 Rafaël Carré
  * Copyright © 2007-2012 Mirsal Ennaime
  * Copyright © 2009-2012 The VideoLAN team
+ * Copyright © 2013      Alex Merry
  * $Id$
  *
  * Authors:    Rafaël Carré <funman at videolanorg>
  *             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
  * it under the terms of the GNU General Public License as published by
@@ -1210,6 +1212,41 @@ int GetInputMeta( input_item_t* p_input,
     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_VLC_META_STRING
 
diff --git a/modules/control/dbus/dbus_common.h b/modules/control/dbus/dbus_common.h
index 2e1c5b9..9579c3f 100644
--- a/modules/control/dbus/dbus_common.h
+++ b/modules/control/dbus/dbus_common.h
@@ -4,10 +4,12 @@
  * Copyright © 2006-2008 Rafaël Carré
  * Copyright © 2007-2010 Mirsal Ennaime
  * Copyright © 2009-2010 The VideoLAN team
+ * Copyright © 2013      Alex Merry
  * $Id$
  *
  * Authors:    Mirsal Ennaime <mirsal dot ennaime at gmailcom>
  *             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
@@ -138,5 +140,10 @@ enum
 
 int DemarshalSetPropertyValue( DBusMessage *p_msg, void *p_arg );
 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
diff --git a/modules/control/dbus/dbus_root.c b/modules/control/dbus/dbus_root.c
index 1b6b962..19f34e0 100644
--- a/modules/control/dbus/dbus_root.c
+++ b/modules/control/dbus/dbus_root.c
@@ -478,42 +478,6 @@ DBUS_METHOD( SetProperty )
 #undef PROPERTY_GET_FUNC
 #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 ) \
     if( VLC_SUCCESS != AddProperty( (intf_thread_t*) p_this, \
                 &dict, #prop, signature, Marshal##prop ) ) \
-- 
1.8.1.1




More information about the vlc-devel mailing list