Attica

buildservicejobparser.cpp
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}
Represents a build service job.
Q_SCRIPTABLE CaptureState status()
The Attica namespace,.
float toFloat(bool *ok) const const
int toInt(bool *ok, int base) const const
bool atEnd() const const
bool isEndElement() const const
bool isStartElement() const const
QStringView name() const const
QString readElementText(ReadElementTextBehaviour behaviour)
TokenType readNext()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.