[rygel-grilo] Handle ChildCount key
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-grilo] Handle ChildCount key
- Date: Wed, 19 May 2010 11:00:59 +0000 (UTC)
commit 9fda4f0281e289af69bdf9cec4b83ee0a10945c2
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Wed May 19 12:19:08 2010 +0200
Handle ChildCount key
New key in spec.
lib/media-server1-common.h | 1 +
lib/media-server1-introspection.h | 1 +
lib/media-server1-server-table.c | 20 ++++++++++++++++++++
lib/media-server1-server.c | 12 +++++++-----
lib/media-server1-server.h | 4 ++++
src/rygel-grilo.c | 16 ++++++++++++++++
6 files changed, 49 insertions(+), 5 deletions(-)
---
diff --git a/lib/media-server1-common.h b/lib/media-server1-common.h
index f00020b..f762254 100644
--- a/lib/media-server1-common.h
+++ b/lib/media-server1-common.h
@@ -51,6 +51,7 @@
#define MS1_PROP_ALBUM_ART "AlbumArt"
/* MediaContainer1 properties */
+#define MS1_PROP_CHILD_COUNT "ChildCount"
#define MS1_PROP_ITEMS "Items"
#define MS1_PROP_ITEM_COUNT "ItemCount"
#define MS1_PROP_CONTAINERS "Containers"
diff --git a/lib/media-server1-introspection.h b/lib/media-server1-introspection.h
index 8b42167..e69a320 100644
--- a/lib/media-server1-introspection.h
+++ b/lib/media-server1-introspection.h
@@ -64,6 +64,7 @@
#define MEDIACONTAINER1_IFACE \
" <interface name=\"org.gnome.UPnP.MediaContainer1\">" \
+ " <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\"/>" \
diff --git a/lib/media-server1-server-table.c b/lib/media-server1-server-table.c
index b70440f..f622499 100644
--- a/lib/media-server1-server-table.c
+++ b/lib/media-server1-server-table.c
@@ -757,6 +757,26 @@ ms1_server_set_searchable (MS1Server *server,
}
/**
+ * ms1_server_set_child_count:
+ * @server: a #MS1Server
+ * @properties: a #GHashTable
+ * @child_count: how many children have this container
+ *
+ * Sets the "ChildCount" property.
+ **/
+void
+ms1_server_set_child_count (MS1Server *server,
+ GHashTable *properties,
+ guint child_count)
+{
+ g_return_if_fail (properties);
+
+ g_hash_table_insert (properties,
+ MS1_PROP_CHILD_COUNT,
+ uint_to_value (child_count));
+}
+
+/**
* ms1_server_set_items:
* @server: a #MS1Server
* @properties: a #GHashTable
diff --git a/lib/media-server1-server.c b/lib/media-server1-server.c
index 660c303..528af49 100644
--- a/lib/media-server1-server.c
+++ b/lib/media-server1-server.c
@@ -102,7 +102,8 @@ static const gchar *mediaitem1_properties[] = { MS1_PROP_URLS,
MS1_PROP_ALBUM_ART,
NULL };
-static const gchar *mediacontainer1_properties[] = { MS1_PROP_ITEMS,
+static const gchar *mediacontainer1_properties[] = { MS1_PROP_CHILD_COUNT,
+ MS1_PROP_ITEMS,
MS1_PROP_ITEM_COUNT,
MS1_PROP_CONTAINERS,
MS1_PROP_CONTAINER_COUNT,
@@ -235,10 +236,11 @@ properties_lookup_with_default (GHashTable *properties,
}
if (!uint_type_properties) {
- uint_type_properties = g_new (gchar *, 3);
- uint_type_properties[0] = (gchar *) g_intern_static_string (MS1_PROP_ITEM_COUNT);
- uint_type_properties[1] = (gchar *) g_intern_static_string (MS1_PROP_CONTAINER_COUNT);
- uint_type_properties[2] = NULL;
+ uint_type_properties = g_new (gchar *, 4);
+ uint_type_properties[0] = (gchar *) g_intern_static_string (MS1_PROP_CHILD_COUNT);
+ uint_type_properties[1] = (gchar *) g_intern_static_string (MS1_PROP_ITEM_COUNT);
+ uint_type_properties[2] = (gchar *) g_intern_static_string (MS1_PROP_CONTAINER_COUNT);
+ uint_type_properties[3] = NULL;
}
if (!bool_type_properties) {
diff --git a/lib/media-server1-server.h b/lib/media-server1-server.h
index c9eb3c8..5356a05 100644
--- a/lib/media-server1-server.h
+++ b/lib/media-server1-server.h
@@ -217,6 +217,10 @@ void ms1_server_set_searchable (MS1Server *server,
GHashTable *properties,
gboolean searchable);
+void ms1_server_set_child_count (MS1Server *server,
+ GHashTable *properties,
+ guint child_count);
+
void ms1_server_set_items (MS1Server *server,
GHashTable *properties,
GList *items);
diff --git a/src/rygel-grilo.c b/src/rygel-grilo.c
index f2f8554..f7af1f7 100644
--- a/src/rygel-grilo.c
+++ b/src/rygel-grilo.c
@@ -338,6 +338,9 @@ get_grilo_keys (const gchar **ms_keys, GList **other_keys)
} else if (g_strcmp0 (ms_keys[i], MS1_PROP_WIDTH) == 0) {
grl_keys = g_list_prepend (grl_keys,
GRLKEYID_TO_POINTER (GRL_METADATA_KEY_WIDTH));
+ } else if (g_strcmp0 (ms_keys[i], MS1_PROP_CHILD_COUNT) == 0) {
+ grl_keys = g_list_prepend (grl_keys,
+ GRLKEYID_TO_POINTER (GRL_METADATA_KEY_CHILDCOUNT));
} else if (g_strcmp0 (ms_keys[i], MS1_PROP_PARENT) == 0 && other_keys) {
*other_keys = g_list_prepend (*other_keys, (gchar *) ms_keys[i]);
} else if (g_strcmp0 (ms_keys[i], MS1_PROP_TYPE) == 0 && other_keys) {
@@ -369,6 +372,7 @@ fill_properties_table (MS1Server *server,
GrlKeyID key;
gchar *id;
gchar *urls[2] = { 0 };
+ gint childcount;
for (prop = keys; prop; prop = g_list_next (prop)) {
key = POINTER_TO_GRLKEYID (prop->data);
@@ -440,6 +444,18 @@ fill_properties_table (MS1Server *server,
grl_data_get_int (GRL_DATA (media),
GRL_METADATA_KEY_WIDTH));
break;
+ case GRL_METADATA_KEY_CHILDCOUNT:
+ if (GRL_IS_MEDIA_BOX (media)) {
+ childcount = grl_media_box_get_childcount (GRL_MEDIA_BOX (media));
+ } else {
+ childcount = 0;
+ }
+ if (childcount != GRL_METADATA_KEY_CHILDCOUNT_UNKNOWN) {
+ ms1_server_set_child_count (server,
+ properties_table,
+ (guint) childcount);
+ }
+ break;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]