This repository was archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdlnaservice.cpp
72 lines (61 loc) · 2.13 KB
/
dlnaservice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "dlnaservice.h"
#include "dlnaexception.h"
DLNAService::DLNAService(QString cntrlURL, QString scpdURL, QString evntsubURL, QString sType, QString sID)
{
this->controlURL = cntrlURL;
this->Scpdurl = scpdURL;
this->EventSubURL = evntsubURL;
this->ServiceType = sType;
this->ServiceID = sID;
}
QString DLNAService::getServiceID() const
{
return ServiceID;
}
QString DLNAService::getControlURL() const
{
return controlURL;
}
QMap<QString, DLNAService> ReadService(QString HTML)
{
QMap<QString, DLNAService> Dic;
QXmlStreamReader xml(HTML);
while(!xml.atEnd() && !xml.hasError())
{
QXmlStreamReader::TokenType token = xml.readNext();
if(token == QXmlStreamReader::StartDocument)
continue;
if(token == QXmlStreamReader::StartElement) {
QString name = xml.name().toString();
if(name == "service")
{
QString sType, sID, scpdURL, cntrlURL, evntsubURL;
qDebug() << "Found Service";
do {
xml.readNextStartElement();
name = xml.name().toString();
qDebug() << "element name: '" << name << "'"
<< ", text: '" << xml.readElementText()
<< "'" << endl;
if(name == "serviceType") { sType = xml.readElementText(); }
else if(name == "serviceId") { sID = xml.readElementText(); }
else if(name == "SCPDURL") { scpdURL = xml.readElementText(); }
else if(name == "controlURL") { cntrlURL = xml.readElementText(); }
else if(name == "eventSubURL") { evntsubURL = xml.readElementText();}
} while (name != "service");
DLNAService s(cntrlURL,scpdURL,evntsubURL,sType,sID);
Dic.insert(s.getServiceID(),s);
}
continue;
}
}
if (xml.hasError())
{
qDebug() << "XML error: " << xml.errorString() << endl;
}
else if (xml.atEnd())
{
qDebug() << "Reached end, done" << endl;
}
return Dic;
}