1 #include "appcastparser.h"
3 #include "defaultupdater.h"
7 AppcastParser::AppcastParser() {}
9 void AppcastParser::parse(const QByteArray &bytes) {
13 const QLatin1String sparkleNS("http://www.andymatuschak.org/xml-namespaces/sparkle");
15 QXmlStreamReader reader(bytes);
16 while (!reader.atEnd()) {
18 if (reader.name() == QLatin1String("item")) {
19 while (reader.readNextStartElement()) {
20 if (reader.name() == QLatin1String("enclosure")) {
21 auto attrs = reader.attributes();
22 QString url = attrs.value(QLatin1String("url")).toString();
23 updater->setDownloadUrl(url);
25 QString version = attrs.value(sparkleNS, QLatin1String("version")).toString();
26 updater->setVersion(version);
28 QString shortVersionString =
29 attrs.value(sparkleNS, QLatin1String("shortVersionString")).toString();
30 updater->setDisplayVersion(shortVersionString);
32 reader.skipCurrentElement();
37 if (reader.hasError()) {
39 errorMessage = reader.errorString();
43 } // namespace updater