File indexing completed on 2024-12-01 12:29:21
0001 /* 0002 This file is part of KDE. 0003 0004 SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "buildserviceparser.h" 0010 #include <qdebug.h> 0011 0012 using namespace Attica; 0013 0014 BuildService BuildService::Parser::parseXml(QXmlStreamReader &xml) 0015 { 0016 // For specs about the XML provided, see here: 0017 // http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft 0018 0019 BuildService buildservice; 0020 0021 while (!xml.atEnd()) { 0022 xml.readNext(); 0023 0024 if (xml.isStartElement()) { 0025 if (xml.name() == QLatin1String("id")) { 0026 buildservice.setId(xml.readElementText()); 0027 } else if (xml.name() == QLatin1String("name")) { 0028 buildservice.setName(xml.readElementText()); 0029 } else if (xml.name() == QLatin1String("registrationurl")) { 0030 buildservice.setUrl(xml.readElementText()); 0031 } else if (xml.name() == QLatin1String("supportedtargets")) { 0032 while (!xml.atEnd()) { 0033 xml.readNextStartElement(); 0034 if (xml.isStartElement()) { 0035 if (xml.name() == QLatin1String("target")) { 0036 Target t; 0037 while (!xml.atEnd()) { 0038 xml.readNextStartElement(); 0039 if (xml.isStartElement()) { 0040 if (xml.name() == QLatin1String("id")) { 0041 t.id = xml.readElementText(); 0042 } else if (xml.name() == QLatin1String("name")) { 0043 t.name = xml.readElementText(); 0044 } 0045 } else if (xml.isEndElement() && (xml.name() == QLatin1String("target"))) { 0046 xml.readNext(); 0047 break; 0048 } 0049 } 0050 buildservice.addTarget(t); 0051 } 0052 } else if (xml.isEndElement() && (xml.name() == QLatin1String("supportedtargets"))) { 0053 xml.readNext(); 0054 break; 0055 } 0056 } 0057 } 0058 } else if (xml.isEndElement() // 0059 && (xml.name() == QLatin1String("buildservice") || xml.name() == QLatin1String("user"))) { 0060 break; 0061 } 0062 } 0063 return buildservice; 0064 } 0065 0066 QStringList BuildService::Parser::xmlElement() const 0067 { 0068 return QStringList(QStringLiteral("buildservice")) << QStringLiteral("user"); 0069 }