[rygel-grilo] Update server-side for latest changes in MediaServer2 spec
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-grilo] Update server-side for latest changes in MediaServer2 spec
- Date: Thu, 15 Apr 2010 18:56:53 +0000 (UTC)
commit c75ad0f9a4287c0bd057a991a0d955222baf44c2
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Thu Apr 15 18:16:35 2010 +0200
Update server-side for latest changes in MediaServer2 spec
Latest changes affects get_children() return values: instead returning a
hashtable of pairs <child_id, {properties array}>, now it returns just an array
of {properties array}. If use wants to know the id, then it must be specified
among the filter properties.
data/media-server2.xml | 2 +-
lib/media-server2-client-glue.h | 10 ++--
lib/media-server2-client.c | 8 +++-
lib/media-server2-server-glue.h | 8 ++--
lib/media-server2-server.c | 87 ++++++++------------------------------
src/rygel-grilo.c | 2 +-
6 files changed, 37 insertions(+), 80 deletions(-)
---
diff --git a/data/media-server2.xml b/data/media-server2.xml
index c57882c..e03a253 100644
--- a/data/media-server2.xml
+++ b/data/media-server2.xml
@@ -11,7 +11,7 @@
<arg name="offset" direction="in" type="u"/>
<arg name="max_count" direction="in" type="i"/>
<arg name="filter" direction="in" type="as"/>
- <arg name="children" direction="out" type="a{sav}"/>
+ <arg name="children" direction="out" type="aav"/>
</method>
<method name="GetProperties">
diff --git a/lib/media-server2-client-glue.h b/lib/media-server2-client-glue.h
index 9f1891d..af45b5c 100644
--- a/lib/media-server2-client-glue.h
+++ b/lib/media-server2-client-glue.h
@@ -26,21 +26,21 @@ static
inline
#endif
gboolean
-org_gnome_UPnP_MediaServer2_get_children (DBusGProxy *proxy, const char * IN_id, const guint IN_offset, const gint IN_max_count, const char ** IN_filter, GHashTable** OUT_children, GError **error)
+org_gnome_UPnP_MediaServer2_get_children (DBusGProxy *proxy, const char * IN_id, const guint IN_offset, const gint IN_max_count, const char ** IN_filter, GPtrArray** OUT_children, GError **error)
{
- return dbus_g_proxy_call (proxy, "GetChildren", error, G_TYPE_STRING, IN_id, G_TYPE_UINT, IN_offset, G_TYPE_INT, IN_max_count, G_TYPE_STRV, IN_filter, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE)), OUT_children, G_TYPE_INVALID);
+ return dbus_g_proxy_call (proxy, "GetChildren", error, G_TYPE_STRING, IN_id, G_TYPE_UINT, IN_offset, G_TYPE_INT, IN_max_count, G_TYPE_STRV, IN_filter, G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE)), OUT_children, G_TYPE_INVALID);
}
-typedef void (*org_gnome_UPnP_MediaServer2_get_children_reply) (DBusGProxy *proxy, GHashTable *OUT_children, GError *error, gpointer userdata);
+typedef void (*org_gnome_UPnP_MediaServer2_get_children_reply) (DBusGProxy *proxy, GPtrArray *OUT_children, GError *error, gpointer userdata);
static void
org_gnome_UPnP_MediaServer2_get_children_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
- GHashTable* OUT_children;
- dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE)), &OUT_children, G_TYPE_INVALID);
+ GPtrArray* OUT_children;
+ dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE)), &OUT_children, G_TYPE_INVALID);
(*(org_gnome_UPnP_MediaServer2_get_children_reply)data->cb) (proxy, OUT_children, error, data->userdata);
return;
}
diff --git a/lib/media-server2-client.c b/lib/media-server2-client.c
index 7a886db..aef3168 100644
--- a/lib/media-server2-client.c
+++ b/lib/media-server2-client.c
@@ -180,6 +180,7 @@ get_properties_async_reply (DBusGProxy *proxy,
g_object_unref (res);
}
+#if 0
/* Callback invoked by dbus as answer to get_children_async() */
static void
get_children_async_reply (DBusGProxy *proxy,
@@ -200,6 +201,7 @@ get_children_async_reply (DBusGProxy *proxy,
g_simple_async_result_complete (res);
g_object_unref (res);
}
+#endif
/* Class init function */
static void
@@ -396,11 +398,12 @@ ms2_client_get_children (MS2Client *client,
const gchar **properties,
GError **error)
{
- GHashTable *result;
+ GHashTable *result = NULL;
GList *children = NULL;
g_return_val_if_fail (MS2_IS_CLIENT (client), NULL);
+#if 0
if (!org_gnome_UPnP_MediaServer2_get_children (client->priv->proxy_provider,
id,
offset,
@@ -410,6 +413,7 @@ ms2_client_get_children (MS2Client *client,
error)) {
return NULL;
}
+#endif
children = get_children_list (result, properties);
@@ -446,6 +450,7 @@ void ms2_client_get_children_async (MS2Client *client,
adata,
(GDestroyNotify) free_async_data);
+#if 0
org_gnome_UPnP_MediaServer2_get_children_async (client->priv->proxy_provider,
id,
offset,
@@ -453,6 +458,7 @@ void ms2_client_get_children_async (MS2Client *client,
properties,
get_children_async_reply,
res);
+#endif
}
GList *
diff --git a/lib/media-server2-server-glue.h b/lib/media-server2-server-glue.h
index 58f9a58..cf409aa 100644
--- a/lib/media-server2-server-glue.h
+++ b/lib/media-server2-server-glue.h
@@ -53,7 +53,7 @@ G_BEGIN_DECLS
#endif /* !G_ENABLE_DEBUG */
-/* NONE:STRING,UINT,INT,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.O4F0AV:1) */
+/* NONE:STRING,UINT,INT,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.SI92AV:1) */
extern void dbus_glib_marshal_ms2_server_VOID__STRING_UINT_INT_BOXED_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -103,7 +103,7 @@ dbus_glib_marshal_ms2_server_VOID__STRING_UINT_INT_BOXED_POINTER (GClosure *
}
#define dbus_glib_marshal_ms2_server_NONE__STRING_UINT_INT_BOXED_POINTER dbus_glib_marshal_ms2_server_VOID__STRING_UINT_INT_BOXED_POINTER
-/* NONE:STRING,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.O4F0AV:2) */
+/* NONE:STRING,BOXED,POINTER (/tmp/dbus-binding-tool-c-marshallers.SI92AV:2) */
extern void dbus_glib_marshal_ms2_server_VOID__STRING_BOXED_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -156,14 +156,14 @@ G_END_DECLS
#include <dbus/dbus-glib.h>
static const DBusGMethodInfo dbus_glib_ms2_server_methods[] = {
{ (GCallback) ms2_server_get_children, dbus_glib_marshal_ms2_server_NONE__STRING_UINT_INT_BOXED_POINTER, 0 },
- { (GCallback) ms2_server_get_properties, dbus_glib_marshal_ms2_server_NONE__STRING_BOXED_POINTER, 109 },
+ { (GCallback) ms2_server_get_properties, dbus_glib_marshal_ms2_server_NONE__STRING_BOXED_POINTER, 106 },
};
const DBusGObjectInfo dbus_glib_ms2_server_object_info = {
0,
dbus_glib_ms2_server_methods,
2,
-"org.gnome.UPnP.MediaServer2\0GetChildren\0A\0id\0I\0s\0offset\0I\0u\0max_count\0I\0i\0filter\0I\0as\0children\0O\0F\0N\0a{sav}\0\0org.gnome.UPnP.MediaServer2\0GetProperties\0A\0id\0I\0s\0filter\0I\0as\0properties\0O\0F\0N\0av\0\0\0",
+"org.gnome.UPnP.MediaServer2\0GetChildren\0A\0id\0I\0s\0offset\0I\0u\0max_count\0I\0i\0filter\0I\0as\0children\0O\0F\0N\0aav\0\0org.gnome.UPnP.MediaServer2\0GetProperties\0A\0id\0I\0s\0filter\0I\0as\0properties\0O\0F\0N\0av\0\0\0",
"\0",
"\0"
};
diff --git a/lib/media-server2-server.c b/lib/media-server2-server.c
index f28f53f..166d50a 100644
--- a/lib/media-server2-server.c
+++ b/lib/media-server2-server.c
@@ -61,13 +61,6 @@ free_value (GValue *value)
g_free (value);
}
-/* Free a GPtrArray */
-static void
-free_ptr_array (GPtrArray *array)
-{
- g_ptr_array_free (array, TRUE);
-}
-
/* Puts a string in a gvalue */
static GValue *
str_to_value (const gchar *str)
@@ -141,9 +134,8 @@ get_unknown_value (const gchar *property)
/* Returns an array of properties values suitable to send as dbus reply */
static GPtrArray *
-get_array_properties (const gchar *id,
- const gchar **filter,
- GHashTable *properties)
+get_array_properties (GHashTable *properties,
+ const gchar **filter)
{
GPtrArray *prop_array;
gint i;
@@ -169,36 +161,23 @@ get_array_properties (const gchar *id,
return prop_array;
}
-/* Returns a hashtable with children and properties suitable to send as dbus
- reply */
-static GHashTable *
-get_hash_children (GList *children,
- const gchar **filter)
+/* Returns an array of children, which consist of arrays of properties, suitable
+ to send as dbus reply */
+static GPtrArray *
+get_array_children (GList *children,
+ const gchar **filter)
{
- GHashTable *children_hash;
GList *child;
GPtrArray *prop_array;
- GValue *val_id;
- gchar *id;;
-
- children_hash = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) free_ptr_array);
+ GPtrArray *children_array;
+ children_array = g_ptr_array_sized_new (g_list_length (children));
for (child = children; child; child = g_list_next (child)) {
- val_id = g_hash_table_lookup (child->data, MS2_PROP_ID);
- if (val_id && G_VALUE_HOLDS_STRING (val_id)) {
- id = g_value_dup_string (val_id);
- }
-
- if (id) {
- prop_array = get_array_properties (id, filter, child->data);
- g_hash_table_insert (children_hash, id, prop_array);
- }
+ prop_array = get_array_properties (child->data, filter);
+ g_ptr_array_add (children_array, prop_array);
}
- return children_hash;
+ return children_array;
}
/* Registers the MS2Server object in dbus */
@@ -276,7 +255,6 @@ ms2_server_get_properties (MS2Server *server,
DBusGMethodInvocation *context,
GError **error)
{
- GError *prop_error = NULL;
GHashTable *properties = NULL;
GPtrArray *prop_array = NULL;
@@ -284,23 +262,10 @@ ms2_server_get_properties (MS2Server *server,
properties = server->priv->get_properties (id,
filter,
server->priv->data,
- &prop_error);
-
- if (prop_error) {
- if (error) {
- *error = g_error_new_literal (MS2_ERROR,
- MS2_ERROR_GENERAL,
- prop_error->message);
- dbus_g_method_return_error (context, *error);
- }
-
- g_error_free (prop_error);
-
- return FALSE;
- }
+ NULL);
}
- prop_array = get_array_properties (id, filter, properties);
+ prop_array = get_array_properties (properties, filter);
dbus_g_method_return (context, prop_array);
/* Free content */
@@ -323,8 +288,7 @@ ms2_server_get_children (MS2Server *server,
DBusGMethodInvocation *context,
GError **error)
{
- GError *child_error = NULL;
- GHashTable *children_hash = NULL;
+ GPtrArray *children_array = NULL;
GList *children = NULL;
if (server->priv->get_children) {
@@ -333,27 +297,14 @@ ms2_server_get_children (MS2Server *server,
max_count < 0? G_MAXINT: max_count,
filter,
server->priv->data,
- &child_error);
-
- if (child_error) {
- if (error) {
- *error = g_error_new_literal (MS2_ERROR,
- MS2_ERROR_GENERAL,
- child_error->message);
- dbus_g_method_return_error (context, *error);
- }
-
- g_error_free (child_error);
-
- return FALSE;
- }
+ NULL);
}
- children_hash = get_hash_children (children, filter);
- dbus_g_method_return (context, children_hash);
+ children_array = get_array_children (children, filter);
+ dbus_g_method_return (context, children_array);
/* Free content */
- g_hash_table_unref (children_hash);
+ g_ptr_array_free (children_array, TRUE);
g_list_foreach (children, (GFunc) g_hash_table_unref, NULL);
g_list_free (children);
diff --git a/src/rygel-grilo.c b/src/rygel-grilo.c
index fe86865..a771010 100644
--- a/src/rygel-grilo.c
+++ b/src/rygel-grilo.c
@@ -377,7 +377,7 @@ get_properties_cb (const gchar *id,
gpointer data,
GError **error)
{
- GHashTable *properties_table;
+ GHashTable *properties_table = NULL;
GrlMedia *media;
RygelGriloData *rgdata;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]