2 * Qt OBS - A Qt based OBS client
4 * Copyright (C) 2010 Novell Inc, Klaas Freitag <freitag@suse.de>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Written by Klaas Freitag <freitag@suse.de>
25 #include <QApplication>
27 #include "buildstatxmlreader.h"
28 #include "obsbuildresults.h"
30 BuildStatXmlReader::BuildStatXmlReader()
36 bool BuildStatXmlReader::read(QIODevice *device)
38 // setDevice( device );
39 QByteArray arr = device->readAll();
40 qDebug() << "ALL contents: " << arr;
45 bool BuildStatXmlReader::parse()
51 * <result project="home:kfreitag:Kraft" repository="Debian_Etch" arch="i586">
52 * <status package="ctemplate" code="disabled"/>
53 * <status package="python-ReportLab" code="excluded"/>
54 * <status package="python-trml2pdf" code="disabled"/>
55 * <status package="Kraft" code="succeeded"/>
59 if( isStartElement() ) {
60 qDebug() << "XML name: " << name();
61 if( name() == "result" ) {
62 QString repo = attributes().value("repository").toString();
63 QString arch = attributes().value("arch").toString();
64 QString prj = attributes().value("project").toString();
66 OBSProjectBuildResult prjBuildResult;
67 prjBuildResult.setProject( prj );
68 prjBuildResult.setArchitecture( arch );
69 prjBuildResult.setRepository( repo );
71 prjBuildResult.setPackageBuildResults( parsePackageBuildResults() );
73 mProjectBuildResults.append( prjBuildResult );
77 qDebug() << "Paring error: " << error();
82 QList<OBSPackageBuildResult> BuildStatXmlReader::parsePackageBuildResults()
84 Q_ASSERT( isStartElement() );
85 QList<OBSPackageBuildResult> list;
86 while (QXmlStreamReader::StartElement != readNext()) {}
88 Q_ASSERT( name() == "status" );
90 while (! (isEndElement() && name() == "result" ) ) {
91 QXmlStreamAttributes attribs = attributes();
92 if( name() == "status" && isStartElement() ) {
93 list.append( OBSPackageBuildResult( attribs.value( "package" ).toString(),
94 attribs.value( "code" ).toString() ) );
101 OBSProjectBuildResults BuildStatXmlReader::buildResultList()
103 return mProjectBuildResults;