1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#include "buildservicejobparser.h"
10#include <qdebug.h>
11
12using namespace Attica;
13
14BuildServiceJob BuildServiceJob::Parser::parseXml(QXmlStreamReader &xml)
15{
16 BuildServiceJob buildservicejob;
17
18 // For specs about the XML provided, see here:
19 // http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft#BuildServiceJobs
20 while (!xml.atEnd()) {
21 // qCDebug(ATTICA) << "XML returned:" << xml.text().toString();
22 xml.readNext();
23
24 if (xml.isStartElement()) {
25 if (xml.name() == QLatin1String("id")) { // FIXME: server should give "id" here ...
26 buildservicejob.setId(xml.readElementText());
27 } else if (xml.name() == QLatin1String("project")) {
28 buildservicejob.setProjectId(xml.readElementText());
29 } else if (xml.name() == QLatin1String("buildservice")) {
30 buildservicejob.setBuildServiceId(xml.readElementText());
31 } else if (xml.name() == QLatin1String("target")) {
32 buildservicejob.setTarget(xml.readElementText());
33 } else if (xml.name() == QLatin1String("name")) {
34 buildservicejob.setName(xml.readElementText());
35 } else if (xml.name() == QLatin1String("status")) {
36 int status = xml.readElementText().toInt();
37 buildservicejob.setStatus(status);
38 } else if (xml.name() == QLatin1String("progress")) {
39 qreal progress = (qreal)(xml.readElementText().toFloat());
40 buildservicejob.setProgress(progress);
41 } else if (xml.name() == QLatin1String("message")) {
42 buildservicejob.setMessage(xml.readElementText());
43 } else if (xml.name() == QLatin1String("url")) {
44 buildservicejob.setUrl(xml.readElementText());
45 }
46 } else if (xml.isEndElement() && (xml.name() == QLatin1String("buildjob") || xml.name() == QLatin1String("user"))) {
47 break;
48 }
49 }
50 return buildservicejob;
51}
52
53QStringList BuildServiceJob::Parser::xmlElement() const
54{
55 return QStringList(QStringLiteral("buildjob")) << QStringLiteral("user");
56}
57

source code of attica/src/buildservicejobparser.cpp