Esempio n. 1
0
bool ContentNode::hasContainerNodes()
{
	int nContentNodes = getNContentNodes();
	for (int n=0; n<nContentNodes; n++) {
		ContentNode *cnode = getContentNode(n);
		if (cnode->isContainerNode() == true)
			return true;
	}
	return false;
}
Esempio n. 2
0
int MediaPlayer::getContentDirectory(ContentNode *parentNode, Device *dev, const char *objectID)
{
	if (objectID == NULL)
		return 0;

	CyberXML::Node *resultNode = browseDirectChildren(dev, objectID, "*", 0, 0, "");
	if (resultNode == NULL)
		return 0;

	BrowseResult browseResult(resultNode);
	//cout << browseResult.getNContentNodes() << endl;
	int nResultNode = 0;
	int nContents = browseResult.getNContentNodes();
	for (int n=0; n<nContents; n++) {
		Node *xmlNode = browseResult.getContentNode(n);
		ContentNode *contentNode = NULL;
		if (ContainerNode::isContainerNode(xmlNode) == true) {
			contentNode = new ContainerNode();
		}
		if (ItemNode::isItemNode(xmlNode) == true)
			contentNode = new BrowseResultNode();
		if (contentNode == NULL)
			continue;
		contentNode->set(xmlNode);
		parentNode->addContentNode(contentNode);
		nResultNode++;
		// Add Child Nodes
		if (contentNode->isContainerNode() == true) {
			ContainerNode *containerNode = (ContainerNode*)contentNode;
			int childCnt = containerNode->getChildCount();
			if (0 < childCnt) {
				const char *objid = containerNode->getID();
				getContentDirectory(contentNode, dev, objid);
			}
		}
	}
	delete resultNode;

	return nResultNode;
}