[rygel-grilo] Get rid of Items and Containers properties
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-grilo] Get rid of Items and Containers properties
- Date: Thu, 1 Jul 2010 17:55:09 +0000 (UTC)
commit 05f1c140bf2cded176c875951590082d3f687e30
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Wed Jun 30 16:19:18 2010 +0200
Get rid of Items and Containers properties
A new change in MediaServer2 spec has replaced these properties by methods.
lib/media-server2-client.c | 67 --------------------------------
lib/media-server2-client.h | 4 --
lib/media-server2-common.h | 1 -
lib/media-server2-introspection.h | 14 ++++++-
lib/media-server2-server-table.c | 70 ---------------------------------
lib/media-server2-server.c | 10 +----
lib/media-server2-server.h | 8 ----
src/rygel-grilo.c | 77 +++++++------------------------------
src/test-client.c | 8 ----
9 files changed, 28 insertions(+), 231 deletions(-)
---
diff --git a/lib/media-server2-client.c b/lib/media-server2-client.c
index 5d1e02c..7cf4da1 100644
--- a/lib/media-server2-client.c
+++ b/lib/media-server2-client.c
@@ -148,9 +148,7 @@ split_properties_by_interface (gchar **properties)
g_strcmp0 (*property, MS2_PROP_TYPE) == 0) {
split[IMEDIAOBJECT2_INDEX][mo_index++] = *property;
} else if (g_strcmp0 (*property, MS2_PROP_CHILD_COUNT) == 0 ||
- g_strcmp0 (*property, MS2_PROP_ITEMS) == 0 ||
g_strcmp0 (*property, MS2_PROP_ITEM_COUNT) == 0 ||
- g_strcmp0 (*property, MS2_PROP_CONTAINERS) == 0 ||
g_strcmp0 (*property, MS2_PROP_CONTAINER_COUNT) == 0 ||
g_strcmp0 (*property, MS2_PROP_SEARCHABLE) == 0) {
split[IMEDIACONTAINER2_INDEX][mc_index++] = *property;
@@ -180,23 +178,6 @@ gptrarray_to_glist (GPtrArray *result)
return g_list_reverse (list);
}
-/* Converts GPtrArray in a NULL-terminated array */
-static gchar **
-gptrarray_to_strv (GPtrArray *result)
-{
- gchar **strv;
- gint i;
-
- strv = g_new (gchar *, result->len + 1);
- for (i = 0; i < result->len; i++) {
- strv[i] = g_strdup (g_ptr_array_index (result, i));
- }
-
- strv[i] = NULL;
-
- return strv;
-}
-
/* Callback invoked when ListenChildren reply is received */
static void
list_children_reply (DBusGProxy *proxy,
@@ -1662,30 +1643,6 @@ ms2_client_get_child_count (GHashTable *properties)
}
/**
- * ms2_client_get_items:
- * @properties: a #GHashTable
- *
- * Returns "Items" property value.
- *
- * Returns: a new @NULL-terminated array of strings or @NULL if it is not
- * available
- **/
-gchar **
-ms2_client_get_items (GHashTable *properties)
-{
- GValue *val;
-
- g_return_val_if_fail (properties, NULL);
-
- val = g_hash_table_lookup (properties, MS2_PROP_ITEMS);
- if (!val || !G_VALUE_HOLDS_BOXED (val)) {
- return NULL;
- }
-
- return gptrarray_to_strv (g_value_get_boxed (val));
-}
-
-/**
* ms2_client_get_item_count:
* @properties: a #GHashTable
*
@@ -1709,30 +1666,6 @@ ms2_client_get_item_count (GHashTable *properties)
}
/**
- * ms2_client_get_containers:
- * @properties: a #GHashTable
- *
- * Returns "Containers" property value.
- *
- * Returns: a new @NULL-terminated array of strings or @NULL if it is not
- * available
- **/
-gchar **
-ms2_client_get_containers (GHashTable *properties)
-{
- GValue *val;
-
- g_return_val_if_fail (properties, NULL);
-
- val = g_hash_table_lookup (properties, MS2_PROP_CONTAINERS);
- if (!val || !G_VALUE_HOLDS_BOXED (val)) {
- return NULL;
- }
-
- return gptrarray_to_strv (g_value_get_boxed (val));
-}
-
-/**
* ms2_client_get_container_count:
* @properties: a #GHhashTable
*
diff --git a/lib/media-server2-client.h b/lib/media-server2-client.h
index fb2a4f9..6529b72 100644
--- a/lib/media-server2-client.h
+++ b/lib/media-server2-client.h
@@ -195,12 +195,8 @@ gboolean ms2_client_get_searchable (GHashTable *properties);
guint ms2_client_get_child_count (GHashTable *properties);
-gchar **ms2_client_get_items (GHashTable *properties);
-
guint ms2_client_get_item_count (GHashTable *properties);
-gchar **ms2_client_get_containers (GHashTable *properties);
-
guint ms2_client_get_container_count (GHashTable *properties);
#endif /* _MEDIA_SERVER2_CLIENT_H_ */
diff --git a/lib/media-server2-common.h b/lib/media-server2-common.h
index 0fcb6b8..7bd5b1a 100644
--- a/lib/media-server2-common.h
+++ b/lib/media-server2-common.h
@@ -52,7 +52,6 @@
/* MediaContainer2 properties */
#define MS2_PROP_CHILD_COUNT "ChildCount"
-#define MS2_PROP_ITEMS "Items"
#define MS2_PROP_ITEM_COUNT "ItemCount"
#define MS2_PROP_CONTAINERS "Containers"
#define MS2_PROP_CONTAINER_COUNT "ContainerCount"
diff --git a/lib/media-server2-introspection.h b/lib/media-server2-introspection.h
index 5b4a515..0119b92 100644
--- a/lib/media-server2-introspection.h
+++ b/lib/media-server2-introspection.h
@@ -65,9 +65,7 @@
#define MEDIACONTAINER2_IFACE \
" <interface name=\"org.gnome.UPnP.MediaContainer2\">" \
" <property name=\"ChildCount\" type=\"u\" access=\"read\"/>" \
- " <property name=\"Items\" type=\"ao\" access=\"read\"/>" \
" <property name=\"ItemCount\" type=\"u\" access=\"read\"/>" \
- " <property name=\"Containers\" type=\"ao\" access=\"read\"/>" \
" <property name=\"ContainerCount\" type=\"u\" access=\"read\"/>" \
" <property name=\"Searchable\" type=\"b\" access=\"read\"/>" \
" <method name=\"ListChildren\">" \
@@ -76,6 +74,18 @@
" <arg name=\"filter\" direction=\"in\" type=\"as\"/>" \
" <arg name=\"objects\" direction=\"out\" type=\"a(a{sv})\"/>" \
" </method>" \
+ " <method name=\"ListContainers\">" \
+ " <arg name=\"offset\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"max\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"filter\" direction=\"in\" type=\"as\"/>" \
+ " <arg name=\"objects\" direction=\"out\" type=\"a(a{sv})\"/>" \
+ " </method>" \
+ " <method name=\"ListItems\">" \
+ " <arg name=\"offset\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"max\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"filter\" direction=\"in\" type=\"as\"/>" \
+ " <arg name=\"objects\" direction=\"out\" type=\"a(a{sv})\"/>" \
+ " </method>" \
" <method name=\"SearchObjects\">" \
" <arg name=\"query\" direction=\"in\" type=\"s\"/>" \
" <arg name=\"offset\" direction=\"in\" type=\"u\"/>" \
diff --git a/lib/media-server2-server-table.c b/lib/media-server2-server-table.c
index bc669c6..feffa4a 100644
--- a/lib/media-server2-server-table.c
+++ b/lib/media-server2-server-table.c
@@ -133,26 +133,6 @@ id_to_object_path (MS2Server *server,
return object_path;
}
-/* Returns a GPtrArray of object_paths obtained from list of hashtable
- properties */
-static GPtrArray *
-get_object_paths (GList *items)
-{
- GList *item;
- GPtrArray *op;
- gchar *path;
-
- op = g_ptr_array_sized_new (g_list_length (items));
- for (item = items; item; item = g_list_next (item)) {
- path = g_strdup (ms2_client_get_path (item->data));
- if (path) {
- g_ptr_array_add (op, path);
- }
- }
-
- return op;
-}
-
/********************* PUBLIC API *********************/
/**
@@ -777,31 +757,6 @@ ms2_server_set_child_count (MS2Server *server,
}
/**
- * ms2_server_set_items:
- * @server: a #MS2Server
- * @properties: a #GHashTable
- * @items: a list of children
- *
- * Sets the "Items" property.
- **/
-void
-ms2_server_set_items (MS2Server *server,
- GHashTable *properties,
- GList *items)
-{
- GPtrArray *object_paths;
-
- g_return_if_fail (properties);
-
- if (items) {
- object_paths = get_object_paths (items);
- g_hash_table_insert (properties,
- MS2_PROP_ITEMS,
- ptrarray_to_value (object_paths));
- }
-}
-
-/**
* ms2_server_set_item_count:
* @server: a #MS2Server
* @properties: a #GHashTable
@@ -822,31 +777,6 @@ ms2_server_set_item_count (MS2Server *server,
}
/**
- * ms2_server_set_containers:
- * @server: a #MS2Server
- * @properties: a #GHashTable
- * @containers: a list of children
- *
- * Sets the "Containers" property.
- **/
-void
-ms2_server_set_containers (MS2Server *server,
- GHashTable *properties,
- GList *containers)
-{
- GPtrArray *object_paths;
-
- g_return_if_fail (properties);
-
- if (containers) {
- object_paths = get_object_paths (containers);
- g_hash_table_insert (properties,
- MS2_PROP_CONTAINERS,
- ptrarray_to_value (object_paths));
- }
-}
-
-/**
* ms2_server_set_container_count:
* @server: a #MS2Server
* @properties: a #GHashTable
diff --git a/lib/media-server2-server.c b/lib/media-server2-server.c
index c4d5454..417d43a 100644
--- a/lib/media-server2-server.c
+++ b/lib/media-server2-server.c
@@ -100,9 +100,7 @@ static const gchar *mediaitem2_properties[] = { MS2_PROP_URLS,
NULL };
static const gchar *mediacontainer2_properties[] = { MS2_PROP_CHILD_COUNT,
- MS2_PROP_ITEMS,
MS2_PROP_ITEM_COUNT,
- MS2_PROP_CONTAINERS,
MS2_PROP_CONTAINER_COUNT,
MS2_PROP_SEARCHABLE,
NULL };
@@ -131,9 +129,7 @@ static const gchar *all_properties[] = { MS2_PROP_PARENT,
MS2_PROP_THUMBNAIL,
MS2_PROP_ALBUM_ART,
MS2_PROP_CHILD_COUNT,
- MS2_PROP_ITEMS,
MS2_PROP_ITEM_COUNT,
- MS2_PROP_CONTAINERS,
MS2_PROP_CONTAINER_COUNT,
MS2_PROP_SEARCHABLE,
NULL };
@@ -278,11 +274,9 @@ properties_lookup_with_default (GHashTable *properties,
}
if (!gptrarray_type_properties) {
- gptrarray_type_properties = g_new (gchar *, 4);
+ gptrarray_type_properties = g_new (gchar *, 2);
gptrarray_type_properties[0] = (gchar *) g_intern_static_string (MS2_PROP_URLS);
- gptrarray_type_properties[1] = (gchar *) g_intern_static_string (MS2_PROP_ITEMS);
- gptrarray_type_properties[2] = (gchar *) g_intern_static_string (MS2_PROP_CONTAINERS);
- gptrarray_type_properties[3] = NULL;
+ gptrarray_type_properties[1] = NULL;
}
if (properties) {
diff --git a/lib/media-server2-server.h b/lib/media-server2-server.h
index 5fc098d..af2c000 100644
--- a/lib/media-server2-server.h
+++ b/lib/media-server2-server.h
@@ -221,18 +221,10 @@ void ms2_server_set_child_count (MS2Server *server,
GHashTable *properties,
guint child_count);
-void ms2_server_set_items (MS2Server *server,
- GHashTable *properties,
- GList *items);
-
void ms2_server_set_item_count (MS2Server *server,
GHashTable *properties,
guint item_count);
-void ms2_server_set_containers (MS2Server *server,
- GHashTable *properties,
- GList *containers);
-
void ms2_server_set_container_count (MS2Server *server,
GHashTable *properties,
guint container_count);
diff --git a/src/rygel-grilo.c b/src/rygel-grilo.c
index 7ccd1d2..22844ff 100644
--- a/src/rygel-grilo.c
+++ b/src/rygel-grilo.c
@@ -185,14 +185,12 @@ unserialize_media (GrlMetadataSource *source, const gchar *serial)
}
static void
-get_items_and_containers (MS2Server *server,
- GrlMediaSource *source,
- const gchar *container_id,
- guint *child_count,
- GList **items,
- guint *item_count,
- GList **containers,
- guint *container_count)
+get_item_and_container_count (MS2Server *server,
+ GrlMediaSource *source,
+ const gchar *container_id,
+ guint *child_count,
+ guint *item_count,
+ guint *container_count)
{
const gchar *properties[] = { MS2_PROP_PATH, MS2_PROP_TYPE, NULL };
GList *children;
@@ -204,18 +202,10 @@ get_items_and_containers (MS2Server *server,
*child_count = 0;
}
- if (items) {
- *items = NULL;
- }
-
if (item_count) {
*item_count = 0;
}
- if (containers) {
- *containers = NULL;
- }
-
if (container_count) {
*container_count = 0;
}
@@ -233,25 +223,12 @@ get_items_and_containers (MS2Server *server,
if (container_count) {
(*container_count)++;
}
- if (containers) {
- *containers = g_list_prepend (*containers, child->data);
- } else {
- g_hash_table_unref (child->data);
- }
} else {
if (item_count) {
(*item_count)++;
}
- if (items) {
- *items = g_list_prepend (*items, child->data);
- }
}
- }
- if (containers) {
- *containers = g_list_reverse (*containers);
- }
- if (items) {
- *items = g_list_reverse (*items);
+ g_hash_table_unref (child->data);
}
g_list_free (children);
}
@@ -270,9 +247,7 @@ get_grilo_keys (const gchar **ms_keys, GList **other_keys)
if (other_keys) {
*other_keys = g_list_prepend (*other_keys, MS2_PROP_CHILD_COUNT);
*other_keys = g_list_prepend (*other_keys, MS2_PROP_TYPE);
- *other_keys = g_list_prepend (*other_keys, MS2_PROP_ITEMS);
*other_keys = g_list_prepend (*other_keys, MS2_PROP_ITEM_COUNT);
- *other_keys = g_list_prepend (*other_keys, MS2_PROP_CONTAINERS);
*other_keys = g_list_prepend (*other_keys, MS2_PROP_CONTAINER_COUNT);
*other_keys = g_list_prepend (*other_keys, MS2_PROP_SEARCHABLE);
}
@@ -314,12 +289,8 @@ get_grilo_keys (const gchar **ms_keys, GList **other_keys)
grl_keys = g_list_prepend (grl_keys, GRL_METADATA_KEY_RYGEL_GRILO_PARENT);
} else if (g_strcmp0 (ms_keys[i], MS2_PROP_TYPE) == 0 && other_keys) {
*other_keys = g_list_prepend (*other_keys, (gchar *) ms_keys[i]);
- } else if (g_strcmp0 (ms_keys[i], MS2_PROP_ITEMS) == 0 && other_keys) {
- *other_keys = g_list_prepend (*other_keys, (gchar *) ms_keys[i]);
} else if (g_strcmp0 (ms_keys[i], MS2_PROP_ITEM_COUNT) == 0 && other_keys) {
*other_keys = g_list_prepend (*other_keys, (gchar *) ms_keys[i]);
- } else if (g_strcmp0 (ms_keys[i], MS2_PROP_CONTAINERS) == 0 && other_keys) {
- *other_keys = g_list_prepend (*other_keys, (gchar *) ms_keys[i]);
} else if (g_strcmp0 (ms_keys[i], MS2_PROP_CONTAINER_COUNT) == 0 && other_keys) {
*other_keys = g_list_prepend (*other_keys, (gchar *) ms_keys[i]);
} else if (g_strcmp0 (ms_keys[i], MS2_PROP_SEARCHABLE) == 0 && other_keys) {
@@ -433,10 +404,6 @@ fill_other_properties_table (MS2Server *server,
GList *keys,
GrlMedia *media)
{
- GList **containers = NULL;
- GList **items = NULL;
- GList *_containers;
- GList *_items;
GList *key;
gchar *id;
guint *child_count = NULL;
@@ -476,13 +443,9 @@ fill_other_properties_table (MS2Server *server,
grl_media_box_get_childcount (GRL_MEDIA_BOX (media)) == GRL_METADATA_KEY_CHILDCOUNT_UNKNOWN) {
child_count = &_child_count;
}
- } else if (g_strcmp0 (key->data, MS2_PROP_ITEMS) == 0) {
- items = &_items;
} else if (g_strcmp0 (key->data, MS2_PROP_ITEM_COUNT) == 0 &&
count_items_containers) {
item_count = &_item_count;
- } else if (g_strcmp0 (key->data, MS2_PROP_CONTAINERS) == 0) {
- containers = &_containers;
} else if (g_strcmp0 (key->data, MS2_PROP_CONTAINER_COUNT) == 0 &&
count_items_containers) {
container_count = &_container_count;
@@ -501,35 +464,23 @@ fill_other_properties_table (MS2Server *server,
}
}
- if (child_count || items || item_count || containers || container_count) {
+ if (child_count || item_count || container_count) {
id = serialize_media (media);
if (id) {
- get_items_and_containers (server,
- source,
- id,
- child_count,
- items,
- item_count,
- containers,
- container_count);
+ get_item_and_container_count (server,
+ source,
+ id,
+ child_count,
+ item_count,
+ container_count);
g_free (id);
}
if (child_count) {
ms2_server_set_child_count (server, properties_table, *child_count);
}
- if (items) {
- ms2_server_set_items (server, properties_table, *items);
- g_list_foreach (*items, (GFunc) g_hash_table_unref, NULL);
- g_list_free (*items);
- }
if (item_count) {
ms2_server_set_item_count (server, properties_table, *item_count);
}
- if (containers) {
- ms2_server_set_containers (server, properties_table, *containers);
- g_list_foreach (*containers, (GFunc) g_hash_table_unref, NULL);
- g_list_free (*containers);
- }
if (container_count) {
ms2_server_set_container_count (server, properties_table, *container_count);
}
diff --git a/src/test-client.c b/src/test-client.c
index ae1c7e7..58362b7 100644
--- a/src/test-client.c
+++ b/src/test-client.c
@@ -7,8 +7,6 @@ static gchar *properties[] = { MS2_PROP_PATH,
MS2_PROP_DISPLAY_NAME,
MS2_PROP_PARENT,
MS2_PROP_CHILD_COUNT,
- MS2_PROP_CONTAINERS,
- MS2_PROP_ITEMS,
MS2_PROP_URLS,
MS2_PROP_ARTIST,
NULL };
@@ -53,12 +51,6 @@ test_properties ()
gchar **urls = ms2_client_get_urls (result);
g_print ("We got %d urls\n", urls? g_strv_length (urls): 0);
- gchar **items = ms2_client_get_items (result);
- g_print ("We got %d items\n", items? g_strv_length (items): 0);
-
- gchar **containers = ms2_client_get_containers (result);
- g_print ("We got %d containers\n", containers? g_strv_length (containers): 0);
-
for (p = properties; *p; p++) {
v = g_hash_table_lookup (result, *p);
if (v && G_VALUE_HOLDS_INT (v)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]