mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 15:02:50 +02:00
use xmlinterface in UPNP
Origin commit data
------------------
Branch: ni/coolstream
Commit: 497f05b730
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2015-04-27 (Mon, 27 Apr 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -3,6 +3,8 @@ noinst_LIBRARIES = libtuxbox-upnpclient.a
|
||||
AM_CPPFLAGS = -fno-rtti
|
||||
|
||||
AM_CPPFLAGS += \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/lib/xmltree
|
||||
|
||||
libtuxbox_upnpclient_a_SOURCES = UPNPSocket.cpp UPNPDevice.cpp UPNPService.cpp
|
||||
|
@@ -18,12 +18,15 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
***********************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
#include <xmltree.h>
|
||||
#include <xmlinterface.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -133,7 +136,7 @@ CUPnPDevice::CUPnPDevice(std::string url)
|
||||
std::string result, head, body, charset, urlbase;
|
||||
std::string curl, eurl, name, mimetype, iurl, rcode;
|
||||
std::string::size_type pos;
|
||||
XMLTreeNode *root, *device, *service, *node, *snode, *icon;
|
||||
xmlNodePtr root, device, service, node, snode, icon;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int depth = 0;
|
||||
@@ -165,76 +168,76 @@ CUPnPDevice::CUPnPDevice(std::string url)
|
||||
|
||||
if (rcode != "200")
|
||||
throw std::runtime_error(std::string("description url returned ") + rcode);
|
||||
XMLTreeParser parser(charset.c_str());
|
||||
parser.Parse(body.c_str(), body.size(), 1);
|
||||
root = parser.RootNode();
|
||||
|
||||
xmlDocPtr parser = parseXml(body.c_str(),charset.c_str());
|
||||
root = xmlDocGetRootElement(parser);
|
||||
if (!root)
|
||||
throw std::runtime_error(std::string("XML: no root node"));
|
||||
|
||||
if (strcmp(root->GetType(),"root"))
|
||||
if (strcmp(xmlGetName(root),"root"))
|
||||
throw std::runtime_error(std::string("XML: no root"));
|
||||
|
||||
for (node = root->GetChild(); node; node=node->GetNext())
|
||||
for (node = root->xmlChildrenNode; node; node=node->xmlNextNode)
|
||||
{
|
||||
if (!strcmp(node->GetType(),"URLBase"))
|
||||
if (!strcmp(xmlGetName(node),"URLBase"))
|
||||
{
|
||||
urlbase = std::string(node->GetData());
|
||||
urlbase = std::string(xmlGetData(node));
|
||||
if ((!urlbase.empty() ) && (urlbase[urlbase.length()-1] == '/'))
|
||||
urlbase.erase(urlbase.length()-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
node = root->GetChild();
|
||||
node = root->xmlChildrenNode;
|
||||
if (!node)
|
||||
throw std::runtime_error(std::string("XML: no root child"));
|
||||
|
||||
while (strcmp(node->GetType(),"device"))
|
||||
while (strcmp(xmlGetName(node),"device"))
|
||||
{
|
||||
node = node->GetNext();
|
||||
node = node->xmlNextNode;
|
||||
if (!node)
|
||||
throw std::runtime_error(std::string("XML: no device"));
|
||||
}
|
||||
device = node;
|
||||
|
||||
for (node=device->GetChild(); node; node=node->GetNext())
|
||||
for (node=device->xmlChildrenNode; node; node=node->xmlNextNode)
|
||||
{
|
||||
if (!strcmp(node->GetType(),"deviceType"))
|
||||
devicetype = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"deviceType"))
|
||||
devicetype = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"friendlyName"))
|
||||
friendlyname = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"friendlyName"))
|
||||
friendlyname = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"manufacturer"))
|
||||
manufacturer = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"manufacturer"))
|
||||
manufacturer = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"manufacturerURL"))
|
||||
manufacturerurl = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"manufacturerURL"))
|
||||
manufacturerurl = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"modelDescription"))
|
||||
modeldescription = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"modelDescription"))
|
||||
modeldescription = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"modelName"))
|
||||
modelname = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"modelName"))
|
||||
modelname = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"modelNumber"))
|
||||
modelnumber = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"modelNumber"))
|
||||
modelnumber = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"modelURL"))
|
||||
modelurl = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"modelURL"))
|
||||
modelurl = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"serialNumber"))
|
||||
serialnumber = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"serialNumber"))
|
||||
serialnumber = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"UDN"))
|
||||
udn = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"UDN"))
|
||||
udn = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"UPC"))
|
||||
upc = std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"UPC"))
|
||||
upc = std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
|
||||
if (!strcmp(node->GetType(),"iconList"))
|
||||
if (!strcmp(xmlGetName(node),"iconList"))
|
||||
{
|
||||
for (icon=node->GetChild(); icon; icon=icon->GetNext())
|
||||
for (icon=node->xmlChildrenNode; icon; icon=icon->xmlNextNode)
|
||||
{
|
||||
bool foundm = false;
|
||||
bool foundw = false;
|
||||
@@ -242,33 +245,33 @@ CUPnPDevice::CUPnPDevice(std::string url)
|
||||
bool foundd = false;
|
||||
bool foundu = false;
|
||||
|
||||
if (strcmp(icon->GetType(),"icon"))
|
||||
if (strcmp(xmlGetName(icon),"icon"))
|
||||
throw std::runtime_error(std::string("XML: no icon"));
|
||||
for (snode=icon->GetChild(); snode; snode=snode->GetNext())
|
||||
for (snode=icon->xmlChildrenNode; snode; snode=snode->xmlNextNode)
|
||||
{
|
||||
if (!strcmp(snode->GetType(),"mimetype"))
|
||||
if (!strcmp(xmlGetName(snode),"mimetype"))
|
||||
{
|
||||
mimetype=std::string(snode->GetData()?snode->GetData():"");
|
||||
mimetype=std::string(xmlGetData(snode)?xmlGetData(snode):"");
|
||||
foundm = true;
|
||||
}
|
||||
if (!strcmp(snode->GetType(),"width"))
|
||||
if (!strcmp(xmlGetName(snode),"width"))
|
||||
{
|
||||
width=snode->GetData()?atoi(snode->GetData()):0;
|
||||
width=xmlGetData(snode)?atoi(xmlGetData(snode)):0;
|
||||
foundw = true;
|
||||
}
|
||||
if (!strcmp(snode->GetType(),"height"))
|
||||
if (!strcmp(xmlGetName(snode),"height"))
|
||||
{
|
||||
height=snode->GetData()?atoi(snode->GetData()):0;
|
||||
height=xmlGetData(snode)?atoi(xmlGetData(snode)):0;
|
||||
foundh = true;
|
||||
}
|
||||
if (!strcmp(snode->GetType(),"depth"))
|
||||
if (!strcmp(xmlGetName(snode),"depth"))
|
||||
{
|
||||
depth=snode->GetData()?atoi(snode->GetData()):0;
|
||||
depth=xmlGetData(snode)?atoi(xmlGetData(snode)):0;
|
||||
foundd = true;
|
||||
}
|
||||
if (!strcmp(snode->GetType(),"url"))
|
||||
if (!strcmp(xmlGetName(snode),"url"))
|
||||
{
|
||||
url=std::string(snode->GetData()?snode->GetData():"");
|
||||
url=std::string(xmlGetData(snode)?xmlGetData(snode):"");
|
||||
foundu = true;
|
||||
}
|
||||
}
|
||||
@@ -286,28 +289,27 @@ CUPnPDevice::CUPnPDevice(std::string url)
|
||||
icons.push_back(e);
|
||||
}
|
||||
}
|
||||
if (!strcmp(node->GetType(),"serviceList"))
|
||||
if (!strcmp(xmlGetName(node),"serviceList"))
|
||||
{
|
||||
servicefound = true;
|
||||
for (service=node->GetChild(); service; service=service->GetNext())
|
||||
for (service=node->xmlChildrenNode; service; service=service->xmlNextNode)
|
||||
{
|
||||
bool foundc = false;
|
||||
bool founde = false;
|
||||
bool foundn = false;
|
||||
|
||||
if (strcmp(service->GetType(),"service"))
|
||||
if (strcmp(xmlGetName(service),"service"))
|
||||
throw std::runtime_error(std::string("XML: no service"));
|
||||
for (snode=service->GetChild(); snode; snode=snode->GetNext())
|
||||
for (snode=service->xmlChildrenNode; snode; snode=snode->xmlNextNode)
|
||||
{
|
||||
if (!strcmp(snode->GetType(),"serviceType"))
|
||||
if (!strcmp(xmlGetName(snode),"serviceType"))
|
||||
{
|
||||
name=std::string(snode->GetData()?snode->GetData():"");
|
||||
name=std::string(xmlGetData(snode)?xmlGetData(snode):"");
|
||||
foundn = true;
|
||||
}
|
||||
if (!strcmp(snode->GetType(),"eventSubURL"))
|
||||
if (!strcmp(xmlGetName(snode),"eventSubURL"))
|
||||
{
|
||||
char *p;
|
||||
p = snode->GetData();
|
||||
const char *p = xmlGetData(snode);
|
||||
if (!p)
|
||||
eurl=urlbase + "/";
|
||||
else if (p[0]=='/')
|
||||
@@ -316,10 +318,9 @@ CUPnPDevice::CUPnPDevice(std::string url)
|
||||
eurl=urlbase + "/" + std::string(p);
|
||||
founde = true;
|
||||
}
|
||||
if (!strcmp(snode->GetType(),"controlURL"))
|
||||
if (!strcmp(xmlGetName(snode),"controlURL"))
|
||||
{
|
||||
char *p;
|
||||
p = snode->GetData();
|
||||
const char *p = xmlGetData(snode);
|
||||
if (!p)
|
||||
curl=urlbase + "/";
|
||||
else if (p[0]=='/')
|
||||
@@ -348,6 +349,7 @@ CUPnPDevice::CUPnPDevice(std::string url)
|
||||
}
|
||||
if (!servicefound)
|
||||
throw std::runtime_error(std::string("XML: no service list"));
|
||||
xmlFreeDoc(parser);
|
||||
}
|
||||
|
||||
CUPnPDevice::~CUPnPDevice()
|
||||
|
@@ -18,12 +18,15 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
***********************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
#include <xmltree.h>
|
||||
#include <xmlinterface.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -44,6 +47,7 @@ CUPnPService::CUPnPService(CUPnPDevice* dev, std::string curl, std::string eurl,
|
||||
CUPnPService::~CUPnPService()
|
||||
{
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UPnPAttribute> attribs)
|
||||
{
|
||||
@@ -52,7 +56,7 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
|
||||
std::string result, head, body, charset, envelope, soapbody, soapresponse, rcode;
|
||||
std::list<UPnPAttribute>::iterator i;
|
||||
std::list<UPnPAttribute> results;
|
||||
XMLTreeNode *root, *node, *snode;
|
||||
xmlNodePtr root, node, snode;
|
||||
std::string::size_type pos;
|
||||
|
||||
post << "<?xml version=\"1.0\"?>\r\n"
|
||||
@@ -95,13 +99,12 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
|
||||
if (!device->check_response(head, charset, rcode))
|
||||
throw std::runtime_error(std::string("protocol error"));
|
||||
|
||||
XMLTreeParser parser(charset.c_str());
|
||||
parser.Parse(body.c_str(), body.size(), 1);
|
||||
root = parser.RootNode();
|
||||
xmlDocPtr parser = parseXml(body.c_str(),charset.c_str());
|
||||
root = xmlDocGetRootElement(parser);
|
||||
if (!root)
|
||||
throw std::runtime_error(std::string("XML: no root node"));
|
||||
|
||||
envelope=std::string(root->GetType());
|
||||
envelope=std::string(xmlGetName(root));
|
||||
pos = envelope.find(":");
|
||||
if (pos !=std::string::npos)
|
||||
envelope.erase(0,pos+1);
|
||||
@@ -109,11 +112,11 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
|
||||
if (envelope != "Envelope")
|
||||
throw std::runtime_error(std::string("XML: no envelope"));
|
||||
|
||||
node = root->GetChild();
|
||||
node = root->xmlChildrenNode;
|
||||
if (!node)
|
||||
throw std::runtime_error(std::string("XML: no envelope child"));
|
||||
|
||||
soapbody=std::string(node->GetType());
|
||||
soapbody=std::string(xmlGetName(node));
|
||||
pos = soapbody.find(":");
|
||||
if (pos !=std::string::npos)
|
||||
soapbody.erase(0,pos+1);
|
||||
@@ -121,11 +124,11 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
|
||||
if (soapbody != "Body")
|
||||
throw std::runtime_error(std::string("XML: no soap body"));
|
||||
|
||||
node = node->GetChild();
|
||||
node = node->xmlChildrenNode;
|
||||
if (!node)
|
||||
throw std::runtime_error(std::string("XML: no soap body child"));
|
||||
|
||||
soapresponse=std::string(node->GetType());
|
||||
soapresponse=std::string(xmlGetName(node));
|
||||
pos = soapresponse.find(":");
|
||||
if (pos !=std::string::npos)
|
||||
soapresponse.erase(0,pos+1);
|
||||
@@ -135,27 +138,27 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
|
||||
std::string faultstring, upnpcode, upnpdesc, errstr;
|
||||
if (soapresponse != "Fault")
|
||||
throw std::runtime_error(std::string("XML: http error without soap fault: ")+rcode);
|
||||
for (node=node->GetChild(); node; node=node->GetNext())
|
||||
for (node=node->xmlChildrenNode; node; node=node->xmlNextNode)
|
||||
{
|
||||
if (!strcmp(node->GetType(),"detail"))
|
||||
if (!strcmp(xmlGetName(node),"detail"))
|
||||
{
|
||||
snode=node->GetChild();
|
||||
snode=node->xmlChildrenNode;
|
||||
if (snode)
|
||||
for (snode=snode->GetChild(); snode; snode=snode->GetNext())
|
||||
for (snode=snode->xmlChildrenNode; snode; snode=snode->xmlNextNode)
|
||||
{
|
||||
errstr=snode->GetType();
|
||||
errstr=xmlGetName(snode);
|
||||
pos = errstr.find(":");
|
||||
if (pos !=std::string::npos)
|
||||
errstr.erase(0,pos+1);
|
||||
if (errstr=="errorCode")
|
||||
upnpcode=std::string(snode->GetData()?snode->GetData():"");
|
||||
upnpcode=std::string(xmlGetData(snode)?xmlGetData(snode):"");
|
||||
if (errstr=="errorDescription")
|
||||
upnpdesc=std::string(snode->GetData()?snode->GetData():"");
|
||||
upnpdesc=std::string(xmlGetData(snode)?xmlGetData(snode):"");
|
||||
}
|
||||
|
||||
}
|
||||
if (!strcmp(node->GetType(),"faultstring"))
|
||||
faultstring=std::string(node->GetData()?node->GetData():"");
|
||||
if (!strcmp(xmlGetName(node),"faultstring"))
|
||||
faultstring=std::string(xmlGetData(node)?xmlGetData(node):"");
|
||||
}
|
||||
if (!faultstring.empty())
|
||||
throw std::runtime_error(faultstring + " " + upnpcode + " " + upnpdesc);
|
||||
@@ -165,8 +168,9 @@ std::list<UPnPAttribute> CUPnPService::SendSOAP(std::string action, std::list<UP
|
||||
if (soapresponse != action + "Response")
|
||||
throw std::runtime_error(std::string("XML: no soap response"));
|
||||
|
||||
for (node=node->GetChild(); node; node=node->GetNext())
|
||||
results.push_back(UPnPAttribute(node->GetType(), node->GetData()));
|
||||
for (node=node->xmlChildrenNode; node; node=node->xmlNextNode)
|
||||
results.push_back(UPnPAttribute(xmlGetName(node), xmlGetData(node)));
|
||||
|
||||
xmlFreeDoc(parser);
|
||||
return results;
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
#include <xmltree.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
@@ -176,11 +176,11 @@ xmlDocPtr parseXmlFile(const char * filename, bool warning_by_nonexistence /* =
|
||||
}
|
||||
}
|
||||
#else /* USE_LIBXML */
|
||||
xmlDocPtr parseXml(const char * data)
|
||||
xmlDocPtr parseXml(const char * data,const char *encoding)
|
||||
{
|
||||
XMLTreeParser* tree_parser;
|
||||
|
||||
tree_parser = new XMLTreeParser(NULL);
|
||||
tree_parser = new XMLTreeParser(encoding);
|
||||
|
||||
if (!tree_parser->Parse(data, strlen(data), true))
|
||||
{
|
||||
@@ -201,7 +201,7 @@ xmlDocPtr parseXml(const char * data)
|
||||
return tree_parser;
|
||||
}
|
||||
|
||||
xmlDocPtr parseXmlFile(const char * filename, bool warning_by_nonexistence /* = true */)
|
||||
xmlDocPtr parseXmlFile(const char * filename, bool warning_by_nonexistence /* = true */,const char *encoding)
|
||||
{
|
||||
char buffer[2048];
|
||||
XMLTreeParser* tree_parser;
|
||||
@@ -218,7 +218,7 @@ xmlDocPtr parseXmlFile(const char * filename, bool warning_by_nonexistence /* =
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tree_parser = new XMLTreeParser(NULL);
|
||||
tree_parser = new XMLTreeParser(encoding);
|
||||
|
||||
do
|
||||
{
|
||||
|
@@ -66,7 +66,7 @@ std::string Unicode_Character_to_UTF8(const int character);
|
||||
|
||||
std::string convert_UTF8_To_UTF8_XML(const char *s);
|
||||
|
||||
xmlDocPtr parseXml(const char *data);
|
||||
xmlDocPtr parseXmlFile(const char * filename, bool warning_by_nonexistence = true);
|
||||
xmlDocPtr parseXml(const char *data,const char *encoding = NULL);
|
||||
xmlDocPtr parseXmlFile(const char * filename, bool warning_by_nonexistence = true,const char *encoding = NULL);
|
||||
|
||||
#endif /* __xmlinterface_h__ */
|
||||
|
@@ -39,9 +39,8 @@
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include <xmltree.h>
|
||||
#include <xmlinterface.h>
|
||||
#include <upnpclient.h>
|
||||
|
||||
#include <driver/fontrenderer.h>
|
||||
#include <driver/rcinput.h>
|
||||
#include <driver/audioplay.h>
|
||||
@@ -240,49 +239,47 @@ bool CUpnpBrowserGui::getResults(std::string id, unsigned int start, unsigned in
|
||||
|
||||
std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
|
||||
{
|
||||
XMLTreeParser *parser;
|
||||
XMLTreeNode *root, *node, *snode;
|
||||
xmlNodePtr root, node, snode;
|
||||
std::vector<UPnPEntry> *entries;
|
||||
|
||||
parser = new XMLTreeParser("UTF-8");
|
||||
parser->Parse(result.c_str(), result.size(), 1);
|
||||
root=parser->RootNode();
|
||||
xmlDocPtr parser = parseXml(result.c_str(),"UTF-8");
|
||||
root = xmlDocGetRootElement(parser);
|
||||
if (!root) {
|
||||
delete parser;
|
||||
xmlFreeDoc(parser);
|
||||
return NULL;
|
||||
}
|
||||
entries = new std::vector<UPnPEntry>;
|
||||
|
||||
for (node=root->GetChild(); node; node=node->GetNext())
|
||||
for (node=root->xmlChildrenNode; node; node=node->xmlNextNode)
|
||||
{
|
||||
bool isdir;
|
||||
std::string title, artist = "", album = "", albumArtURI = "", id, children;
|
||||
const char *type, *p;
|
||||
|
||||
if (!strcmp(node->GetType(), "container"))
|
||||
if (!strcmp(xmlGetName(node), "container"))
|
||||
{
|
||||
std::vector<UPnPResource> resources;
|
||||
isdir=true;
|
||||
for (snode=node->GetChild(); snode; snode=snode->GetNext())
|
||||
for (snode=node->xmlChildrenNode; snode; snode=snode->xmlNextNode)
|
||||
{
|
||||
type=snode->GetType();
|
||||
type=xmlGetName(snode);
|
||||
p = strchr(type,':');
|
||||
if (p)
|
||||
type=p+1;
|
||||
if (!strcmp(type,"title"))
|
||||
{
|
||||
p=snode->GetData();
|
||||
p=xmlGetData(snode);
|
||||
if (!p)
|
||||
p = "";
|
||||
title=std::string(p);
|
||||
}
|
||||
}
|
||||
p = node->GetAttributeValue("id");
|
||||
p = xmlGetAttribute(node, "id");
|
||||
if (!p)
|
||||
p = "";
|
||||
id=std::string(p);
|
||||
|
||||
p = node->GetAttributeValue("childCount");
|
||||
p = xmlGetAttribute(node, "childCount");
|
||||
if (!p)
|
||||
p = "";
|
||||
children=std::string(p);
|
||||
@@ -290,65 +287,65 @@ std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
|
||||
UPnPEntry entry={id, isdir, title, artist, album, albumArtURI, children, "", "", resources, -1, CFile::FILE_DIR};
|
||||
entries->push_back(entry);
|
||||
}
|
||||
if (!strcmp(node->GetType(), "item"))
|
||||
if (!strcmp(xmlGetName(node), "item"))
|
||||
{
|
||||
std::vector<UPnPResource> resources;
|
||||
int preferred = -1;
|
||||
std::string protocol, prot, network, mime, additional;
|
||||
CFile::FileType ftype = CFile::FILE_UNKNOWN;
|
||||
isdir=false;
|
||||
for (snode=node->GetChild(); snode; snode=snode->GetNext())
|
||||
for (snode=node->xmlChildrenNode; snode; snode=snode->xmlNextNode)
|
||||
{
|
||||
std::string duration, url, size;
|
||||
unsigned int i;
|
||||
type=snode->GetType();
|
||||
type=xmlGetName(snode);
|
||||
p = strchr(type,':');
|
||||
if (p)
|
||||
type=p+1;
|
||||
|
||||
if (!strcmp(type,"title"))
|
||||
{
|
||||
p=snode->GetData();
|
||||
p=xmlGetData(snode);
|
||||
if (!p)
|
||||
p = "";
|
||||
title=std::string(p);
|
||||
}
|
||||
else if (!strcmp(type,"artist"))
|
||||
{
|
||||
p=snode->GetData();
|
||||
p=xmlGetData(snode);
|
||||
if (!p)
|
||||
p = "";
|
||||
artist=std::string(p);
|
||||
}
|
||||
else if (!strcmp(type,"album"))
|
||||
{
|
||||
p=snode->GetData();
|
||||
p=xmlGetData(snode);
|
||||
if (!p)
|
||||
p = "";
|
||||
album=std::string(p);
|
||||
}
|
||||
else if (!strcmp(type,"albumArtURI"))
|
||||
{
|
||||
p=snode->GetData();
|
||||
p=xmlGetData(snode);
|
||||
if (!p)
|
||||
p = "";
|
||||
albumArtURI=std::string(p);
|
||||
}
|
||||
else if (!strcmp(type,"res"))
|
||||
{
|
||||
p = snode->GetData();
|
||||
p = xmlGetData(snode);
|
||||
if (!p)
|
||||
p = "";
|
||||
url=std::string(p);
|
||||
p = snode->GetAttributeValue("size");
|
||||
p = xmlGetAttribute(snode, "size");
|
||||
if (!p)
|
||||
p = "0";
|
||||
size=std::string(p);
|
||||
p = snode->GetAttributeValue("duration");
|
||||
p = xmlGetAttribute(snode, "duration");
|
||||
if (!p)
|
||||
p = "";
|
||||
duration=std::string(p);
|
||||
p = snode->GetAttributeValue("protocolInfo");
|
||||
p = xmlGetAttribute(snode, "protocolInfo");
|
||||
if (!p)
|
||||
p = "";
|
||||
protocol=std::string(p);
|
||||
@@ -419,12 +416,12 @@ std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
|
||||
}
|
||||
}
|
||||
}
|
||||
p = node->GetAttributeValue("id");
|
||||
p = xmlGetAttribute(node, "id");
|
||||
if (!p)
|
||||
p = "";
|
||||
id=std::string(p);
|
||||
|
||||
p = node->GetAttributeValue("childCount");
|
||||
p = xmlGetAttribute(node, "childCount");
|
||||
if (!p)
|
||||
p = "";
|
||||
children=std::string(p);
|
||||
@@ -433,7 +430,7 @@ std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
|
||||
entries->push_back(entry);
|
||||
}
|
||||
}
|
||||
delete parser;
|
||||
xmlFreeDoc(parser);
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user