2
This file is part of KDE.
4
Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) version 3, or any
10
later version accepted by the membership of KDE e.V. (or its
11
successor approved by the membership of KDE e.V.), which shall
12
act as a proxy defined in Section 6 of version 3 of the license.
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library. If not, see <http://www.gnu.org/licenses/>.
26
#include <QXmlStreamReader>
29
#include <QtNetwork/QNetworkAccessManager>
31
#include "platformdependent_v2.h"
33
using namespace Attica;
35
PutJob::PutJob(PlatformDependent *internals, const QNetworkRequest &request, QIODevice *iodevice)
36
: BaseJob(internals), m_ioDevice(iodevice), m_request(request)
40
Attica::PutJob::PutJob(PlatformDependent *internals, const QNetworkRequest &request, const QByteArray &byteArray)
41
: BaseJob(internals), m_ioDevice(0), m_byteArray(byteArray), m_request(request)
45
PutJob::PutJob(PlatformDependent *internals, const QNetworkRequest &request, const StringMap ¶meters)
46
: BaseJob(internals), m_ioDevice(0), m_request(request)
50
for (StringMap::const_iterator i = parameters.begin(); i != parameters.end(); ++i) {
52
m_byteArray.append('&');
54
m_byteArray.append(QUrl::toPercentEncoding(i.key()));
55
m_byteArray.append('=');
56
m_byteArray.append(QUrl::toPercentEncoding(i.value()));
60
QNetworkReply *PutJob::executeRequest()
62
Attica::PlatformDependentV2 *platformDependentV2 = dynamic_cast<Attica::PlatformDependentV2 *>(internals());
63
if (!platformDependentV2) {
68
return platformDependentV2->put(m_request, m_ioDevice);
70
return platformDependentV2->put(m_request, m_byteArray);
74
void PutJob::parse(const QString &xmlString)
76
//qDebug() << "PutJob::parse" << xmlString;
77
QXmlStreamReader xml(xmlString);
79
while (!xml.atEnd()) {
82
if (xml.isStartElement()) {
83
if (xml.name() == QLatin1String("meta")) {
84
while (!xml.atEnd()) {
86
if (xml.isEndElement() && xml.name() == QLatin1String("meta")) {
88
} else if (xml.isStartElement()) {
89
if (xml.name() == QLatin1String("status")) {
90
data.setStatusString(xml.readElementText());
91
} else if (xml.name() == QLatin1String("statuscode")) {
92
data.setStatusCode(xml.readElementText().toInt());
93
} else if (xml.name() == QLatin1String("message")) {
94
data.setMessage(xml.readElementText());
95
} else if (xml.name() == QLatin1String("totalitems")) {
96
data.setTotalItems(xml.readElementText().toInt());
97
} else if (xml.name() == QLatin1String("itemsperpage")) {
98
data.setItemsPerPage(xml.readElementText().toInt());
102
} else if (xml.name() == QLatin1String("data")) {
103
while (!xml.atEnd()) {
105
if (xml.isEndElement() && xml.name() == QLatin1String("data")) {
107
} else if (xml.isStartElement()) {
108
if (xml.name() == QLatin1String("projectid")) {
109
data.setResultingId(xml.readElementText());
110
} if (xml.name() == QLatin1String("buildjobid")) {
111
data.setResultingId(xml.readElementText());
122
#include "putjob.moc"