diff options
-rw-r--r-- | doc/server/dbus/API.txt | 9 | ||||
-rw-r--r-- | libdleyna/server/props.c | 131 | ||||
-rw-r--r-- | libdleyna/server/server.c | 19 | ||||
-rw-r--r-- | test/dbus/mediaconsole.py | 4 |
4 files changed, 102 insertions, 61 deletions
diff --git a/doc/server/dbus/API.txt b/doc/server/dbus/API.txt index fbac2f9..66533d4 100644 --- a/doc/server/dbus/API.txt +++ b/doc/server/dbus/API.txt @@ -565,11 +565,14 @@ Additional properties unsupported by org.gnome.MediaContainer2 | | | | deleted from a container object | | | | | since the last initialization | |---------------------------------------------------------------------------| +| Resources |aa{sv}| o | Returns the set of resources | +| | | | associated with a container | +|---------------------------------------------------------------------------| New Methods: ------------ -Seven new methods have been added. These methods are: +Eight new methods have been added. These methods are: ListChildrenEx(u Offset, u Max, as Filter, s SortBy) -> aa{sv} @@ -586,6 +589,8 @@ CreateContainer(s DisplayName, s Type, as ChildTypes) -> o ObjectPath CreatePlayList(s Title, s Creator, s Genre, s Desc, ao PlaylistItems ) -> (u UploadId, o ObjectPath) +GetCompatibleResources(s protocol_info, as filter) -> a{sv} + The first four methods are identical in function and behaviour to existing the MediaServer2Spec functions ListChildren, ListItems, ListContainers, and SearchObjects, with the exception that they take @@ -664,6 +669,8 @@ container into which the Playlist is to be uploaded whereas CreatePlaylistInAnyContainer leaves it up to the server to determine the most suitable location for the file. +The GetCompatibleResources method: see description in MediaItem2. + Recommended Usage: ------------------ diff --git a/libdleyna/server/props.c b/libdleyna/server/props.c index 947aac6..c8b7388 100644 --- a/libdleyna/server/props.c +++ b/libdleyna/server/props.c @@ -1178,6 +1178,56 @@ static GVariant *prv_props_get_dlna_managed_dict(GUPnPOCMFlags flags) return g_variant_builder_end(&builder); } +static GVariant *prv_compute_resources(GUPnPDIDLLiteObject *object, + dls_upnp_prop_mask filter_mask) +{ + GUPnPDIDLLiteResource *res = NULL; + GList *resources; + GList *ptr; + GVariantBuilder *res_array_vb; + GVariantBuilder *res_vb; + const char *str_val; + GVariant *retval; + + res_array_vb = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); + + resources = gupnp_didl_lite_object_get_resources(object); + ptr = resources; + + while (ptr) { + res = ptr->data; + res_vb = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + if (filter_mask & DLS_UPNP_MASK_PROP_URL) { + str_val = gupnp_didl_lite_resource_get_uri(res); + prv_add_string_prop(res_vb, DLS_INTERFACE_PROP_URL, + str_val); + } + prv_parse_resources(res_vb, res, filter_mask); + g_variant_builder_add(res_array_vb, "@a{sv}", + g_variant_builder_end(res_vb)); + g_variant_builder_unref(res_vb); + g_object_unref(ptr->data); + ptr = g_list_next(ptr); + } + retval = g_variant_builder_end(res_array_vb); + g_variant_builder_unref(res_array_vb); + + g_list_free(resources); + + return retval; +} + +static void prv_add_resources(GVariantBuilder *item_vb, + GUPnPDIDLLiteObject *object, + dls_upnp_prop_mask filter_mask) +{ + GVariant *val; + + val = prv_compute_resources(object, filter_mask); + g_variant_builder_add(item_vb, "{sv}", DLS_INTERFACE_PROP_RESOURCES, + val); +} + gboolean dls_props_add_object(GVariantBuilder *item_vb, GUPnPDIDLLiteObject *object, const char *root_path, @@ -1300,56 +1350,9 @@ void dls_props_add_container(GVariantBuilder *item_vb, DLS_INTERFACE_PROP_TOTAL_DELETED_CHILD_COUNT, uint_val); } -} -static GVariant *prv_compute_resources(GUPnPDIDLLiteObject *object, - dls_upnp_prop_mask filter_mask) -{ - GUPnPDIDLLiteResource *res = NULL; - GList *resources; - GList *ptr; - GVariantBuilder *res_array_vb; - GVariantBuilder *res_vb; - const char *str_val; - GVariant *retval; - - res_array_vb = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}")); - - resources = gupnp_didl_lite_object_get_resources(object); - ptr = resources; - - while (ptr) { - res = ptr->data; - res_vb = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); - if (filter_mask & DLS_UPNP_MASK_PROP_URL) { - str_val = gupnp_didl_lite_resource_get_uri(res); - prv_add_string_prop(res_vb, DLS_INTERFACE_PROP_URL, - str_val); - } - prv_parse_resources(res_vb, res, filter_mask); - g_variant_builder_add(res_array_vb, "@a{sv}", - g_variant_builder_end(res_vb)); - g_variant_builder_unref(res_vb); - g_object_unref(ptr->data); - ptr = g_list_next(ptr); - } - retval = g_variant_builder_end(res_array_vb); - g_variant_builder_unref(res_array_vb); - - g_list_free(resources); - - return retval; -} - -static void prv_add_resources(GVariantBuilder *item_vb, - GUPnPDIDLLiteObject *object, - dls_upnp_prop_mask filter_mask) -{ - GVariant *val; - - val = prv_compute_resources(object, filter_mask); - g_variant_builder_add(item_vb, "{sv}", DLS_INTERFACE_PROP_RESOURCES, - val); + if (filter_mask & DLS_UPNP_MASK_PROP_RESOURCES) + prv_add_resources(item_vb, GUPNP_DIDL_LITE_OBJECT(object), filter_mask); } void dls_props_add_item(GVariantBuilder *item_vb, @@ -1626,6 +1629,9 @@ GVariant *dls_props_get_item_prop(const gchar *prop, const gchar *root_path, GUPnPDIDLLiteResource *res; GVariant *retval = NULL; GList *list; +#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG + gchar *prop_str; +#endif if (GUPNP_IS_DIDL_LITE_CONTAINER(object)) goto on_error; @@ -1647,9 +1653,9 @@ GVariant *dls_props_get_item_prop(const gchar *prop, const gchar *root_path, g_list_free_full(list, g_object_unref); #if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG - path = g_variant_print(retval, FALSE); - DLEYNA_LOG_DEBUG("Prop %s = %s", prop, path); - g_free(path); + prop_str = g_variant_print(retval, FALSE); + DLEYNA_LOG_DEBUG("Prop %s = %s", prop, prop_str); + g_free(prop_str); #endif } else if (!strcmp(prop, DLS_INTERFACE_PROP_ALBUM)) { str = gupnp_didl_lite_object_get_album(object); @@ -1706,6 +1712,11 @@ GVariant *dls_props_get_item_prop(const gchar *prop, const gchar *root_path, } else if (!strcmp(prop, DLS_INTERFACE_PROP_RESOURCES)) { retval = g_variant_ref_sink( prv_compute_resources(object, DLS_UPNP_MASK_ALL_PROPS)); +#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG + prop_str = g_variant_print(retval, FALSE); + DLEYNA_LOG_DEBUG("Prop %s = %s", prop, prop_str); + g_free(prop_str); +#endif } else { res = prv_get_matching_resource(object, protocol_info); if (!res) @@ -1730,7 +1741,7 @@ GVariant *dls_props_get_container_prop(const gchar *prop, GVariant *retval = NULL; guint uint_val; #if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG - gchar *create_classes; + gchar *prop_str; #endif if (!GUPNP_IS_DIDL_LITE_CONTAINER(object)) goto on_error; @@ -1758,9 +1769,9 @@ GVariant *dls_props_get_container_prop(const gchar *prop, retval = g_variant_ref_sink( prv_compute_create_classes(container)); #if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG - create_classes = g_variant_print(retval, FALSE); - DLEYNA_LOG_DEBUG("Prop %s = %s", prop, create_classes); - g_free(create_classes); + prop_str = g_variant_print(retval, FALSE); + DLEYNA_LOG_DEBUG("Prop %s = %s", prop, prop_str); + g_free(prop_str); #endif } else if (!strcmp(prop, DLS_INTERFACE_PROP_CONTAINER_UPDATE_ID)) { uint_val = gupnp_didl_lite_container_get_container_update_id( @@ -1778,6 +1789,14 @@ GVariant *dls_props_get_container_prop(const gchar *prop, DLEYNA_LOG_DEBUG("Prop %s = %u", prop, uint_val); retval = g_variant_ref_sink(g_variant_new_uint32(uint_val)); + } else if (!strcmp(prop, DLS_INTERFACE_PROP_RESOURCES)) { + retval = g_variant_ref_sink( + prv_compute_resources(object, DLS_UPNP_MASK_ALL_PROPS)); +#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG + prop_str = g_variant_print(retval, FALSE); + DLEYNA_LOG_DEBUG("Prop %s = %s", prop, prop_str); + g_free(prop_str); +#endif } on_error: diff --git a/libdleyna/server/server.c b/libdleyna/server/server.c index 4fbbc7e..e1d1c22 100644 --- a/libdleyna/server/server.c +++ b/libdleyna/server/server.c @@ -274,19 +274,27 @@ static const gchar g_server_introspection[] = " <arg type='o' name='"DLS_INTERFACE_PATH"'" " direction='out'/>" " </method>" + " <method name='"DLS_INTERFACE_GET_COMPATIBLE_RESOURCE"'>" + " <arg type='s' name='"DLS_INTERFACE_PROTOCOL_INFO"'" + " direction='in'/>" + " <arg type='as' name='"DLS_INTERFACE_FILTER"'" + " direction='in'/>" + " <arg type='a{sv}' name='"DLS_INTERFACE_PROPERTIES_VALUE"'" + " direction='out'/>" + " </method>" " <property type='u' name='"DLS_INTERFACE_PROP_CHILD_COUNT"'" " access='read'/>" " <property type='b' name='"DLS_INTERFACE_PROP_SEARCHABLE"'" " access='read'/>" - " <property type='a(sb)' name='" - DLS_INTERFACE_PROP_CREATE_CLASSES"'" + " <property type='a(sb)' name='"DLS_INTERFACE_PROP_CREATE_CLASSES"'" " access='read'/>" - " <property type='u' name='" - DLS_INTERFACE_PROP_CONTAINER_UPDATE_ID"'" + " <property type='u' name='"DLS_INTERFACE_PROP_CONTAINER_UPDATE_ID"'" " access='read'/>" " <property type='u' name='" DLS_INTERFACE_PROP_TOTAL_DELETED_CHILD_COUNT"'" " access='read'/>" + " <property type='aa{sv}' name='"DLS_INTERFACE_PROP_RESOURCES"'" + " access='read'/>" " </interface>" " <interface name='"DLS_INTERFACE_MEDIA_ITEM"'>" " <method name='"DLS_INTERFACE_GET_COMPATIBLE_RESOURCE"'>" @@ -951,6 +959,9 @@ static void prv_con_method_call(dleyna_connector_id_t conn, task = dls_task_create_playlist_new(invocation, DLS_TASK_CREATE_PLAYLIST, object, parameters, &error); + else if (!strcmp(method, DLS_INTERFACE_GET_COMPATIBLE_RESOURCE)) + task = dls_task_get_resource_new(invocation, object, + parameters, &error); else goto finished; diff --git a/test/dbus/mediaconsole.py b/test/dbus/mediaconsole.py index d0a2bd5..8d06434 100644 --- a/test/dbus/mediaconsole.py +++ b/test/dbus/mediaconsole.py @@ -145,6 +145,10 @@ class Container(MediaObject): print "Transfer ID: " + str(tid) print u"Path: " + path + def print_compatible_resource(self, protocol_info, fltr): + print_properties(self._containerIF.GetCompatibleResource(protocol_info, + fltr)) + class Device(Container): def __init__(self, path): |