Attica

buildservicejobparser.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2010 Sebastian Kügler <[email protected]>
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 
12 using namespace Attica;
13 
14 BuildServiceJob 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 
53 QStringList BuildServiceJob::Parser::xmlElement() const
54 {
55  return QStringList(QStringLiteral("buildjob")) << QStringLiteral("user");
56 }
bool isEndElement() const const
QStringRef name() const const
QXmlStreamReader::TokenType readNext()
Q_SCRIPTABLE CaptureState status()
int toInt(bool *ok, int base) const const
float toFloat(bool *ok) const const
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
The Attica namespace,.
bool isStartElement() const const
bool atEnd() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 04:05:13 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.