コード例 #1
0
/**
 * gupnp_didl_lite_item_get_ref_id:
 * @item: #GUPnPDIDLLiteItem
 *
 * Get the ref ID of the @item.
 *
 * Return value: The ref ID of the @item, or %NULL.
 **/
const char *
gupnp_didl_lite_item_get_ref_id (GUPnPDIDLLiteItem *item)
{
        xmlNode *xml_node;

        g_return_val_if_fail (item != NULL, 0);
        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_ITEM (item), NULL);

        xml_node = gupnp_didl_lite_object_get_xml_node
                                        (GUPNP_DIDL_LITE_OBJECT (item));

        return xml_util_get_attribute_content (xml_node, "refID");
}
コード例 #2
0
ファイル: browsemodel_p.cpp プロジェクト: phako/Helium
static QString generateMetaData(GUPnPDIDLLiteObject *object)
{
    GList *resources, *it;

    if (GUPNP_IS_DIDL_LITE_CONTAINER(object)) {
        return QString();
    }

    // produce minimal DIDL
    auto writer = wrap(gupnp_didl_lite_writer_new (NULL));
    GUPnPDIDLLiteObject *item = GUPNP_DIDL_LITE_OBJECT(gupnp_didl_lite_writer_add_item(writer));
    const char *title = gupnp_didl_lite_object_get_title(object);

    // maximum title length is 256 bytes
    if (strlen(title) > 256) {
        char *tmp = 0;
        const char *end_ptr = 0;

        g_utf8_validate(title, 256, &end_ptr);
        tmp = g_strndup(title, end_ptr - title);
        gupnp_didl_lite_object_set_title(item, tmp);
        g_free(tmp);
    } else {
        gupnp_didl_lite_object_set_title(item, title);
    }

    gupnp_didl_lite_object_set_upnp_class(item, gupnp_didl_lite_object_get_upnp_class(object));
    gupnp_didl_lite_object_set_parent_id(item, gupnp_didl_lite_object_get_parent_id(object));
    gupnp_didl_lite_object_set_id(item, gupnp_didl_lite_object_get_id(object));
    gupnp_didl_lite_object_set_restricted(item, gupnp_didl_lite_object_get_restricted(object));
    it = resources = gupnp_didl_lite_object_get_resources(object);
    while (it != 0) {
        GUPnPDIDLLiteResource *orig_resource = GUPNP_DIDL_LITE_RESOURCE(it->data);
        GUPnPDIDLLiteResource *resource = gupnp_didl_lite_object_add_resource(item);
        gupnp_didl_lite_resource_set_uri(resource,
                                         gupnp_didl_lite_resource_get_uri (orig_resource));
        gupnp_didl_lite_resource_set_protocol_info(resource,
                                                   gupnp_didl_lite_resource_get_protocol_info(orig_resource));

        it = it->next;
    }
    g_list_free_full(resources, (GDestroyNotify)g_object_unref);

    return QString::fromUtf8(gupnp_didl_lite_writer_get_string(writer));
}
コード例 #3
0
static char *
create_didl_for_file (const char *file_path,
                      const char *title,
                      const char *parent_id)
{
        GUPnPDIDLLiteWriter *writer;
        GUPnPDIDLLiteObject *item;
        char *didl;
        char *new_title;
        const char *upnp_class;

        writer = gupnp_didl_lite_writer_new (NULL);

        item = GUPNP_DIDL_LITE_OBJECT
                        (gupnp_didl_lite_writer_add_item (writer));
        gupnp_didl_lite_object_set_parent_id (item, parent_id);
        gupnp_didl_lite_object_set_id (item, "");
        gupnp_didl_lite_object_set_restricted (item, FALSE);

        if (title == NULL) {
                new_title = g_path_get_basename (file_path);
        } else {
                new_title = g_strdup (title);
        }
        gupnp_didl_lite_object_set_title (item, new_title);
        g_free (new_title);

        upnp_class = create_res_for_file (file_path, item);
        if (upnp_class == NULL) {
                g_critical ("Failed to guess UPnP class for file '%s'",
                            file_path);

                g_object_unref (writer);

                return NULL;
        } else
                gupnp_didl_lite_object_set_upnp_class (item, upnp_class);

        didl = gupnp_didl_lite_writer_get_string (writer);

        g_object_unref (item);
        g_object_unref (writer);

        return didl;
}
コード例 #4
0
/**
 * gupnp_didl_lite_item_set_ref_id:
 * @item: #GUPnPDIDLLiteItem
 * @refid: The ref ID
 *
 * Set the ref ID of the @item.
 **/
void
gupnp_didl_lite_item_set_ref_id (GUPnPDIDLLiteItem *item,
                                 const char        *ref_id)
{
        xmlNode *xml_node;

        g_return_if_fail (item != NULL);
        g_return_if_fail (GUPNP_IS_DIDL_LITE_ITEM (item));

        xml_node = gupnp_didl_lite_object_get_xml_node
                                (GUPNP_DIDL_LITE_OBJECT (item));

        xmlSetProp (xml_node,
                    (unsigned char *) "refID",
                    (unsigned char *) ref_id);

        g_object_notify (G_OBJECT (item), "ref-id");
}