org.fourthline.cling.support.model.DIDLObject Java Examples

The following examples show how to use org.fourthline.cling.support.model.DIDLObject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected void generateRoot(DIDLContent content, Document descriptor, boolean nestedItems) {
    Element rootElement = descriptor.createElementNS(DIDLContent.NAMESPACE_URI, "DIDL-Lite");
    descriptor.appendChild(rootElement);

    // rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:didl", DIDLContent.NAMESPACE_URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:upnp", DIDLObject.Property.UPNP.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:dc", DIDLObject.Property.DC.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:sec", DIDLObject.Property.SEC.NAMESPACE.URI);

    for (Container container : content.getContainers()) {
        if (container == null) continue;
        generateContainer(container, descriptor, rootElement, nestedItems);
    }

    for (Item item : content.getItems()) {
        if (item == null) continue;
        generateItem(item, descriptor, rootElement);
    }

    for (DescMeta descMeta : content.getDescMetadata()) {
        if (descMeta == null) continue;
        generateDescMetadata(descMeta, descriptor, rootElement);
    }
}
 
Example #2
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected void generateRoot(DIDLContent content, Document descriptor, boolean nestedItems) {
    Element rootElement = descriptor.createElementNS(DIDLContent.NAMESPACE_URI, "DIDL-Lite");
    descriptor.appendChild(rootElement);

    // rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:didl", DIDLContent.NAMESPACE_URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:upnp", DIDLObject.Property.UPNP.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:dc", DIDLObject.Property.DC.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:sec", DIDLObject.Property.SEC.NAMESPACE.URI);

    for (Container container : content.getContainers()) {
        if (container == null) continue;
        generateContainer(container, descriptor, rootElement, nestedItems);
    }

    for (Item item : content.getItems()) {
        if (item == null) continue;
        generateItem(item, descriptor, rootElement);
    }

    for (DescMeta descMeta : content.getDescMetadata()) {
        if (descMeta == null) continue;
        generateDescMetadata(descMeta, descriptor, rootElement);
    }
}
 
Example #3
Source File: FolderBasedContentDirectory.java    From subsonic with GNU General Public License v3.0 6 votes vote down vote up
private Item createItem(MediaFile song) throws Exception {
    MediaFile parent = mediaFileService.getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(new PersonWithRole[]{new PersonWithRole(song.getArtist())});
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getAlbumArtUrl(parent)));

    return item;
}
 
Example #4
Source File: MediaFileUpnpProcessor.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
public Item createItem(MediaFile song) {
    MediaFile parent = getMediaFileService().getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(getDispatcher().getAlbumProcessor().getAlbumArtists(song.getArtist()));
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(getDispatcher().createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getDispatcher().getAlbumProcessor().getAlbumArtURI(parent.getId())));

    return item;
}
 
Example #5
Source File: MediaFileUpnpProcessor.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
public Item createItem(MediaFile song) {
    MediaFile parent = getMediaFileService().getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(getDispatcher().getAlbumProcessor().getAlbumArtists(song.getArtist()));
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(getDispatcher().createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getDispatcher().getAlbumProcessor().getAlbumArtURI(parent.getId())));

    return item;
}
 
Example #6
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    super.endElement(uri, localName, qName);

    if (DIDLObject.Property.UPNP.NAMESPACE.URI.equals(uri)) {

        if ("searchClass".equals(localName)) {
            getInstance().getSearchClasses().add(
                    new DIDLObject.Class(
                            getCharacters(),
                            getAttributes().getValue("name"),
                            "true".equals(getAttributes().getValue("includeDerived"))
                    )
            );
        } else if ("createClass".equals(localName)) {
            getInstance().getCreateClasses().add(
                    new DIDLObject.Class(
                            getCharacters(),
                            getAttributes().getValue("name"),
                            "true".equals(getAttributes().getValue("includeDerived"))
                    )
            );
        }
    }
}
 
Example #7
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    super.endElement(uri, localName, qName);

    if (DIDLObject.Property.UPNP.NAMESPACE.URI.equals(uri)) {

        if ("searchClass".equals(localName)) {
            getInstance().getSearchClasses().add(
                    new DIDLObject.Class(
                            getCharacters(),
                            getAttributes().getValue("name"),
                            "true".equals(getAttributes().getValue("includeDerived"))
                    )
            );
        } else if ("createClass".equals(localName)) {
            getInstance().getCreateClasses().add(
                    new DIDLObject.Class(
                            getCharacters(),
                            getAttributes().getValue("name"),
                            "true".equals(getAttributes().getValue("includeDerived"))
                    )
            );
        }
    }
}
 
Example #8
Source File: ContentActivity.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
private String getThumbUri(ContentItem contentItem) {
	String thumbUri = null;
	int i = contentItem.getItem().getProperties().size();
	for (int j = 0; j < i; j++) {
		if (null != contentItem.getItem()
				&& null != contentItem.getItem().getProperties()
				&& null != contentItem.getItem().getProperties().get(j)
				&& ((DIDLObject.Property) contentItem.getItem()
						.getProperties().get(j)).getDescriptorName()
						.equals("albumArtURI")) {

			thumbUri = ((DIDLObject.Property) contentItem.getItem()
					.getProperties().get(j)).getValue().toString();
			break;
		}
	}

	return thumbUri;
}
 
Example #9
Source File: GenerateXml.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void generateRoot(ContentItem content, Document descriptor,
		boolean nestedItems) {
	Element rootElement = descriptor.createElementNS(
			DIDLContent.NAMESPACE_URI, "DIDL-Lite");
	descriptor.appendChild(rootElement);

	// rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
	// "xmlns:didl", DIDLContent.NAMESPACE_URI);
	rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
			"xmlns:upnp", DIDLObject.Property.UPNP.NAMESPACE.URI);
	rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:dc",
			DIDLObject.Property.DC.NAMESPACE.URI);
	rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
			"xmlns:dlna", DIDLObject.Property.DLNA.NAMESPACE.URI);
	rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/",
			"xmlns:sec", DIDLObject.Property.SEC.NAMESPACE.URI);

	if (null != content.getContainer()) {
		generateContainer(content.getContainer(), descriptor, rootElement,
				nestedItems);
	}
	if (null != content.getItem()) {
		generateItem(content.getItem(), descriptor, rootElement);
	}
	//
	// for (DescMeta descMeta : content.getContainer().getDescMetadata()) {
	// if (descMeta == null)
	// continue;
	// generateDescMetadata(descMeta, descriptor, rootElement);
	// }
}
 
Example #10
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void appendClass(Document descriptor, Element parent, DIDLObject.Class clazz, String element, boolean appendDerivation) {
    Element classElement = appendNewElementIfNotNull(
            descriptor,
            parent,
            element,
            clazz.getValue(),
            DIDLObject.Property.UPNP.NAMESPACE.URI
    );
    if (clazz.getFriendlyName() != null && clazz.getFriendlyName().length() > 0)
        classElement.setAttribute("name", clazz.getFriendlyName());
    if (appendDerivation)
        classElement.setAttribute("includeDerived", Boolean.toString(clazz.isIncludeDerived()));
}
 
Example #11
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void appendProperties(Document descriptor, Element parent, DIDLObject object, String prefix,
                                Class<? extends DIDLObject.Property.NAMESPACE> namespace,
                                String namespaceURI) {
    for (DIDLObject.Property<Object> property : object.getPropertiesByNamespace(namespace)) {
        Element el = descriptor.createElementNS(namespaceURI, prefix + ":" + property.getDescriptorName());
        parent.appendChild(el);
        property.setOnElement(el);
    }
}
 
Example #12
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void appendProperties(Document descriptor, Element parent, DIDLObject object, String prefix,
                                Class<? extends DIDLObject.Property.NAMESPACE> namespace,
                                String namespaceURI) {
    for (DIDLObject.Property<Object> property : object.getPropertiesByNamespace(namespace)) {
        Element el = descriptor.createElementNS(namespaceURI, prefix + ":" + property.getDescriptorName());
        parent.appendChild(el);
        property.setOnElement(el);
    }
}
 
Example #13
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void appendClass(Document descriptor, Element parent, DIDLObject.Class clazz, String element, boolean appendDerivation) {
    Element classElement = appendNewElementIfNotNull(
            descriptor,
            parent,
            element,
            clazz.getValue(),
            DIDLObject.Property.UPNP.NAMESPACE.URI
    );
    if (clazz.getFriendlyName() != null && clazz.getFriendlyName().length() > 0)
        classElement.setAttribute("name", clazz.getFriendlyName());
    if (appendDerivation)
        classElement.setAttribute("includeDerived", Boolean.toString(clazz.isIncludeDerived()));
}
 
Example #14
Source File: GenerateXml.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void appendClass(Document descriptor, Element parent,
		DIDLObject.Class clazz, String element, boolean appendDerivation) {
	Element classElement = appendNewElementIfNotNull(descriptor, parent,
			element, clazz.getValue(),
			DIDLObject.Property.UPNP.NAMESPACE.URI);
	if (clazz.getFriendlyName() != null
			&& clazz.getFriendlyName().length() > 0)
		classElement.setAttribute("name", clazz.getFriendlyName());
	if (appendDerivation)
		classElement.setAttribute("includeDerived",
				Boolean.toString(clazz.isIncludeDerived()));
}
 
Example #15
Source File: GenerateXml.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void appendProperties(Document descriptor, Element parent,
		DIDLObject object, String prefix,
		Class<? extends DIDLObject.Property.NAMESPACE> namespace,
		String namespaceURI) {
	for (DIDLObject.Property<Object> property : object
			.getPropertiesByNamespace(namespace)) {
		Element el = descriptor.createElementNS(namespaceURI, prefix + ":"
				+ property.getDescriptorName());
		parent.appendChild(el);
		property.setOnElement(el);
	}
}
 
Example #16
Source File: Container.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Container(String id, Container parent, String title, String creator, DIDLObject.Class clazz, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    this(id, parent.getId(), title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, searchable, createClasses, searchClasses, items);
}
 
Example #17
Source File: Container.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Container(String id, Container parent, String title, String creator, DIDLObject.Class clazz, Integer childCount) {
    this(id, parent.getId(), title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, false, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example #18
Source File: Container.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Container(String id, String parentID, String title, String creator, DIDLObject.Class clazz, Integer childCount) {
    this(id, parentID, title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, false, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example #19
Source File: ContentContainerActivity.java    From BeyondUPnP with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null)
        convertView = mLayoutInflater.inflate(R.layout.listview_items, null);

    final DIDLObject item = getItem(position);
    if (item == null) {
        return convertView;
    }

    //Init container icon
    if (item instanceof Container){
        ImageView imageView = (ImageView)convertView.findViewById(R.id.listview_item_image);
        imageView.setBackgroundResource(R.drawable.ic_action_dock);
    }else if (item instanceof Item){
        ImageView moreBtn = (ImageView)convertView.findViewById(R.id.listview_item_popup_menu);
        moreBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Init popup menu.
                PopupMenu popupMenu = new PopupMenu(ContentContainerActivity.this, v);
                popupMenu.inflate(R.menu.menu_item_actions);
                popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem menuItem) {
                        switch (menuItem.getItemId()){
                            case R.id.action_play :
                                playItem((Item)item);
                                break;
                            case R.id.action_add_to_playlist :
                                addToPlaylist((Item)item);
                                break;
                            default:
                                break;
                        }

                        return true;
                    }
                });
                popupMenu.show();
            }
        });
        moreBtn.setVisibility(View.VISIBLE);
    }

    TextView titleView = (TextView)convertView.findViewById(R.id.listview_item_line_one);
    titleView.setText(item.getTitle());

    TextView creatorView = (TextView)convertView.findViewById(R.id.listview_item_line_two);
    creatorView.setText(item.getCreator());

    return convertView;
}
 
Example #20
Source File: Container.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Container(String id, String parentID, String title, String creator, DIDLObject.Class clazz, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    this(id, parentID, title, creator, true, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), childCount, searchable, createClasses, searchClasses, items);
}
 
Example #21
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateContainer(Container container, Document descriptor, Element parent, boolean nestedItems) {

        if (container.getClazz() == null) {
            throw new RuntimeException("Missing 'upnp:class' element for container: " + container.getId());
        }

        Element containerElement = appendNewElement(descriptor, parent, "container");

        if (container.getId() == null)
            throw new NullPointerException("Missing id on container: " + container);
        containerElement.setAttribute("id", container.getId());

        if (container.getParentID() == null)
            throw new NullPointerException("Missing parent id on container: " + container);
        containerElement.setAttribute("parentID", container.getParentID());

        if (container.getChildCount() != null) {
            containerElement.setAttribute("childCount", Integer.toString(container.getChildCount()));
        }

        containerElement.setAttribute("restricted", booleanToInt(container.isRestricted()));
        containerElement.setAttribute("searchable", booleanToInt(container.isSearchable()));

        String title = container.getTitle();
           if (title == null) {
           	log.warning("Missing 'dc:title' element for container: " + container.getId());
           	title = UNKNOWN_TITLE;
           }

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "dc:title",
                title,
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "dc:creator",
                container.getCreator(),
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "upnp:writeStatus",
                container.getWriteStatus(),
                DIDLObject.Property.UPNP.NAMESPACE.URI
        );

        appendClass(descriptor, containerElement, container.getClazz(), "upnp:class", false);

        for (DIDLObject.Class searchClass : container.getSearchClasses()) {
            appendClass(descriptor, containerElement, searchClass, "upnp:searchClass", true);
        }

        for (DIDLObject.Class createClass : container.getCreateClasses()) {
            appendClass(descriptor, containerElement, createClass, "upnp:createClass", true);
        }

        appendProperties(descriptor, containerElement, container, "upnp", DIDLObject.Property.UPNP.NAMESPACE.class, DIDLObject.Property.UPNP.NAMESPACE.URI);
        appendProperties(descriptor, containerElement, container, "dc", DIDLObject.Property.DC.NAMESPACE.class, DIDLObject.Property.DC.NAMESPACE.URI);

        if (nestedItems) {
            for (Item item : container.getItems()) {
                if (item == null) continue;
                generateItem(item, descriptor, containerElement);
            }
        }

        for (Res resource : container.getResources()) {
            if (resource == null) continue;
            generateResource(resource, descriptor, containerElement);
        }

        for (DescMeta descMeta : container.getDescMetadata()) {
            if (descMeta == null) continue;
            generateDescMetadata(descMeta, descriptor, containerElement);
        }
    }
 
Example #22
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateItem(Item item, Document descriptor, Element parent) {

        if (item.getClazz() == null) {
            throw new RuntimeException("Missing 'upnp:class' element for item: " + item.getId());
        }

        Element itemElement = appendNewElement(descriptor, parent, "item");

        if (item.getId() == null)
            throw new NullPointerException("Missing id on item: " + item);
        itemElement.setAttribute("id", item.getId());

        if (item.getParentID() == null)
            throw new NullPointerException("Missing parent id on item: " + item);
        itemElement.setAttribute("parentID", item.getParentID());

        if (item.getRefID() != null)
            itemElement.setAttribute("refID", item.getRefID());
        itemElement.setAttribute("restricted", booleanToInt(item.isRestricted()));

        String title = item.getTitle();
        if (title == null) {
            log.warning("Missing 'dc:title' element for item: " + item.getId());
            title = UNKNOWN_TITLE;
        }

        appendNewElementIfNotNull(
                descriptor,
                itemElement,
                "dc:title",
                title,
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                itemElement,
                "dc:creator",
                item.getCreator(),
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                itemElement,
                "upnp:writeStatus",
                item.getWriteStatus(),
                DIDLObject.Property.UPNP.NAMESPACE.URI
        );

        appendClass(descriptor, itemElement, item.getClazz(), "upnp:class", false);

        appendProperties(descriptor, itemElement, item, "upnp", DIDLObject.Property.UPNP.NAMESPACE.class, DIDLObject.Property.UPNP.NAMESPACE.URI);
        appendProperties(descriptor, itemElement, item, "dc", DIDLObject.Property.DC.NAMESPACE.class, DIDLObject.Property.DC.NAMESPACE.URI);
        appendProperties(descriptor, itemElement, item, "sec", DIDLObject.Property.SEC.NAMESPACE.class, DIDLObject.Property.SEC.NAMESPACE.URI);

        for (Res resource : item.getResources()) {
            if (resource == null) continue;
            generateResource(resource, descriptor, itemElement);
        }

        for (DescMeta descMeta : item.getDescMetadata()) {
            if (descMeta == null) continue;
            generateDescMetadata(descMeta, descriptor, itemElement);
        }
    }
 
Example #23
Source File: GenerateXml.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateContainer(Container container, Document descriptor,
		Element parent, boolean nestedItems) {

	if (container.getClazz() == null) {
		throw new RuntimeException(
				"Missing 'upnp:class' element for container: "
						+ container.getId());
	}

	Element containerElement = appendNewElement(descriptor, parent,
			"container");

	if (container.getId() == null)
		throw new NullPointerException("Missing id on container: "
				+ container);
	containerElement.setAttribute("id", container.getId());

	if (container.getParentID() == null)
		throw new NullPointerException("Missing parent id on container: "
				+ container);
	containerElement.setAttribute("parentID", container.getParentID());

	if (container.getChildCount() != null) {
		containerElement.setAttribute("childCount",
				Integer.toString(container.getChildCount()));
	}

	containerElement.setAttribute("restricted",
			booleanToInt(container.isRestricted()));
	containerElement.setAttribute("searchable",
			booleanToInt(container.isSearchable()));

	String title = container.getTitle();
	if (title == null) {
		title = UNKNOWN_TITLE;
	}

	appendNewElementIfNotNull(descriptor, containerElement, "dc:title",
			title, DIDLObject.Property.DC.NAMESPACE.URI);

	appendNewElementIfNotNull(descriptor, containerElement, "dc:creator",
			container.getCreator(), DIDLObject.Property.DC.NAMESPACE.URI);

	appendNewElementIfNotNull(descriptor, containerElement,
			"upnp:writeStatus", container.getWriteStatus(),
			DIDLObject.Property.UPNP.NAMESPACE.URI);

	appendClass(descriptor, containerElement, container.getClazz(),
			"upnp:class", false);

	for (DIDLObject.Class searchClass : container.getSearchClasses()) {
		appendClass(descriptor, containerElement, searchClass,
				"upnp:searchClass", true);
	}

	for (DIDLObject.Class createClass : container.getCreateClasses()) {
		appendClass(descriptor, containerElement, createClass,
				"upnp:createClass", true);
	}

	appendProperties(descriptor, containerElement, container, "upnp",
			DIDLObject.Property.UPNP.NAMESPACE.class,
			DIDLObject.Property.UPNP.NAMESPACE.URI);
	appendProperties(descriptor, containerElement, container, "dc",
			DIDLObject.Property.DC.NAMESPACE.class,
			DIDLObject.Property.DC.NAMESPACE.URI);

	if (nestedItems) {
		for (Item item : container.getItems()) {
			if (item == null)
				continue;
			generateItem(item, descriptor, containerElement);
		}
	}

	for (Res resource : container.getResources()) {
		if (resource == null)
			continue;
		generateResource(resource, descriptor, containerElement);
	}

	for (DescMeta descMeta : container.getDescMetadata()) {
		if (descMeta == null)
			continue;
		generateDescMetadata(descMeta, descriptor, containerElement);
	}
}
 
Example #24
Source File: GenerateXml.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateItem(Item item, Document descriptor, Element parent) {

		if (item.getClazz() == null) {
			throw new RuntimeException(
					"Missing 'upnp:class' element for item: " + item.getId());
		}

		Element itemElement = appendNewElement(descriptor, parent, "item");

		if (item.getId() == null)
			throw new NullPointerException("Missing id on item: " + item);
		itemElement.setAttribute("id", item.getId());

		if (item.getParentID() == null)
			throw new NullPointerException("Missing parent id on item: " + item);
		itemElement.setAttribute("parentID", item.getParentID());

		if (item.getRefID() != null)
			itemElement.setAttribute("refID", item.getRefID());
		itemElement.setAttribute("restricted",
				booleanToInt(item.isRestricted()));

		String title = item.getTitle();
		if (title == null) {
			log.warning("Missing 'dc:title' element for item: " + item.getId());
			title = UNKNOWN_TITLE;
		}

		appendNewElementIfNotNull(descriptor, itemElement, "dc:title", title,
				DIDLObject.Property.DC.NAMESPACE.URI);

		appendNewElementIfNotNull(descriptor, itemElement, "dc:creator",
				item.getCreator(), DIDLObject.Property.DC.NAMESPACE.URI);

		appendNewElementIfNotNull(descriptor, itemElement, "upnp:writeStatus",
				item.getWriteStatus(), DIDLObject.Property.UPNP.NAMESPACE.URI);

		appendClass(descriptor, itemElement, item.getClazz(), "upnp:class",
				false);

		appendProperties(descriptor, itemElement, item, "upnp",
				DIDLObject.Property.UPNP.NAMESPACE.class,
				DIDLObject.Property.UPNP.NAMESPACE.URI);
		appendProperties(descriptor, itemElement, item, "dc",
				DIDLObject.Property.DC.NAMESPACE.class,
				DIDLObject.Property.DC.NAMESPACE.URI);
		appendProperties(descriptor, itemElement, item, "sec",
				DIDLObject.Property.SEC.NAMESPACE.class,
				DIDLObject.Property.SEC.NAMESPACE.URI);

		for (Res resource : item.getResources()) {
			if (resource == null)
				continue;
			generateResource(resource, descriptor, itemElement);
		}

		for (DescMeta descMeta : item.getDescMetadata()) {
			if (descMeta == null)
				continue;
			generateDescMetadata(descMeta, descriptor, itemElement);
		}
	}
 
Example #25
Source File: ContentActivity.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public View getView(int paramInt, View paramView,
		ViewGroup paramViewGroup) {
	final ContentHolder localHolder;
	if (paramView == null) {
		paramView = this.mInflater.inflate(R.layout.content_item, null);
		localHolder = new ContentHolder();
		localHolder.filename = (TextView) paramView
				.findViewById(R.id.content_title_tv);
		localHolder.folder = (ImageView) paramView
				.findViewById(R.id.icon_folder);
		localHolder.arrow = (ImageView) paramView
				.findViewById(R.id.icon_arrow);
		paramView.setTag(localHolder);
	} else {
		localHolder = (ContentHolder) paramView.getTag();
	}
	ContentItem contentItem = (ContentItem) this.mDeviceItems
			.get(paramInt);

	localHolder.filename.setText(contentItem.toString());

	if (!contentItem.isContainer()) {
		String imageUrl = null;
		if (null != contentItem.getItem().getResources().get(0)
				.getProtocolInfo().getContentFormatMimeType()) {
			String type = contentItem.getItem().getResources().get(0)
					.getProtocolInfo().getContentFormatMimeType()
					.getType();
			if (type.equals("image")) {
				localHolder.folder.setImageBitmap(imageIcon);
				// if is image, display it
				imageUrl = contentItem.getItem().getFirstResource()
						.getValue();
			} else if (type.equals("video")) {
				localHolder.folder.setImageBitmap(videoIcon);
			} else if (type.equals("audio")) {
				localHolder.folder.setImageBitmap(audioIcon);
			}

		}

		int i = contentItem.getItem().getProperties().size();
		for (int j = 0; j < i; j++) {
			if (null != contentItem.getItem()
					&& null != contentItem.getItem().getProperties()
					&& null != contentItem.getItem().getProperties()
							.get(j)
					&& ((DIDLObject.Property) contentItem.getItem()
							.getProperties().get(j))
							.getDescriptorName().equals("albumArtURI")) {

				imageUrl = ((DIDLObject.Property) contentItem.getItem()
						.getProperties().get(j)).getValue().toString();
				break;
			}
		}
		imageLoader.displayImage(imageUrl, localHolder.folder, options,
				animateFirstListener);
		localHolder.arrow.setVisibility(View.GONE);
	} else {
		localHolder.folder.setImageBitmap(folderIcon);
		localHolder.arrow.setVisibility(View.VISIBLE);

	}
	return paramView;
}
 
Example #26
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected void generateContainer(Container container, Document descriptor, Element parent, boolean nestedItems) {

        if (container.getClazz() == null) {
            throw new RuntimeException("Missing 'upnp:class' element for container: " + container.getId());
        }

        Element containerElement = appendNewElement(descriptor, parent, "container");

        if (container.getId() == null)
            throw new NullPointerException("Missing id on container: " + container);
        containerElement.setAttribute("id", container.getId());

        if (container.getParentID() == null)
            throw new NullPointerException("Missing parent id on container: " + container);
        containerElement.setAttribute("parentID", container.getParentID());

        if (container.getChildCount() != null) {
            containerElement.setAttribute("childCount", Integer.toString(container.getChildCount()));
        }

        containerElement.setAttribute("restricted", booleanToInt(container.isRestricted()));
        containerElement.setAttribute("searchable", booleanToInt(container.isSearchable()));

        String title = container.getTitle();
           if (title == null) {
           	log.warning("Missing 'dc:title' element for container: " + container.getId());
           	title = UNKNOWN_TITLE;
           }

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "dc:title",
                title,
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "dc:creator",
                container.getCreator(),
                DIDLObject.Property.DC.NAMESPACE.URI
        );

        appendNewElementIfNotNull(
                descriptor,
                containerElement,
                "upnp:writeStatus",
                container.getWriteStatus(),
                DIDLObject.Property.UPNP.NAMESPACE.URI
        );

        appendClass(descriptor, containerElement, container.getClazz(), "upnp:class", false);

        for (DIDLObject.Class searchClass : container.getSearchClasses()) {
            appendClass(descriptor, containerElement, searchClass, "upnp:searchClass", true);
        }

        for (DIDLObject.Class createClass : container.getCreateClasses()) {
            appendClass(descriptor, containerElement, createClass, "upnp:createClass", true);
        }

        appendProperties(descriptor, containerElement, container, "upnp", DIDLObject.Property.UPNP.NAMESPACE.class, DIDLObject.Property.UPNP.NAMESPACE.URI);
        appendProperties(descriptor, containerElement, container, "dc", DIDLObject.Property.DC.NAMESPACE.class, DIDLObject.Property.DC.NAMESPACE.URI);

        if (nestedItems) {
            for (Item item : container.getItems()) {
                if (item == null) continue;
                generateItem(item, descriptor, containerElement);
            }
        }

        for (Res resource : container.getResources()) {
            if (resource == null) continue;
            generateResource(resource, descriptor, containerElement);
        }

        for (DescMeta descMeta : container.getDescMetadata()) {
            if (descMeta == null) continue;
            generateDescMetadata(descMeta, descriptor, containerElement);
        }
    }
 
Example #27
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, Container parent, String title, String creator, DIDLObject.Class clazz) {
    this(id, parent.getId(), title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example #28
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, Container parent, String title, String creator, DIDLObject.Class clazz, String refID) {
    this(id, parent.getId(), title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), refID);
}
 
Example #29
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, String parentID, String title, String creator, DIDLObject.Class clazz) {
    this(id, parentID, title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList());
}
 
Example #30
Source File: Item.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public Item(String id, String parentID, String title, String creator, DIDLObject.Class clazz, String refID) {
    this(id, parentID, title, creator, false, null, clazz, new ArrayList(), new ArrayList(), new ArrayList(), refID);
}