-
Notifications
You must be signed in to change notification settings - Fork 18
/
xmlhandler.cpp
74 lines (62 loc) · 2.01 KB
/
xmlhandler.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
73
74
#include "xmlhandler.h"
#include <QDebug>
bool xmlHandler::startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &atts)
{
if (qName == "media:content") {
if (atts.value("type") == "application/x-gzip; charset=binary") {
QString url = atts.value("url");
// Filter out rasplexdev builds
if (!url.contains("release") && !url.contains("experimental")) {
return true;
}
// Work around bug in sourceforge data
url.replace("/project/", "/projects/");
info.url = url;
info.filesize = atts.value("filesize").toUInt();
}
if (atts.value("type") == "text/plain; charset=us-ascii") {
QString url = atts.value("url");
// Work around bug in sourceforge data
url.replace("/project/", "/projects/");
if (url.contains("experimental")) {
experimental.url = url;
experimental.filesize = atts.value("filesize").toUInt();
}
if (url.contains("bleeding")) {
bleeding.url = url;
bleeding.filesize = atts.value("filesize").toUInt();
}
if (url.contains("current")) {
current.url = url;
current.filesize = atts.value("filesize").toUInt();
}
}
}
currentText.clear();
return true;
}
bool xmlHandler::endElement(const QString &, const QString &, const QString &qName)
{
if (qName == "media:content" &&
info.url.isValid() &&
info.filesize != 0 &&
!info.md5sum.isEmpty()) {
releases.append(info);
clearInfo();
}
if (qName == "media:hash") {
info.md5sum = qPrintable(currentText);
}
return true;
}
bool xmlHandler::characters(const QString &str)
{
currentText += str;
return true;
}
void xmlHandler::clearInfo()
{
info.filesize = 0;
info.md5sum = QByteArray();
info.url = QUrl();
}