File indexing completed on 2025-01-05 04:29:53
0001 /** 0002 * SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "uploadepisodeactionrequest.h" 0008 0009 #include <QJsonArray> 0010 #include <QJsonDocument> 0011 #include <QJsonObject> 0012 #include <QNetworkReply> 0013 #include <QString> 0014 #include <QUrl> 0015 #include <QVector> 0016 0017 #include "synclogging.h" 0018 0019 UploadEpisodeActionRequest::UploadEpisodeActionRequest(SyncUtils::Provider provider, QNetworkReply *reply, QObject *parent) 0020 : GenericRequest(provider, reply, parent) 0021 { 0022 } 0023 0024 QVector<std::pair<QString, QString>> UploadEpisodeActionRequest::updateUrls() const 0025 { 0026 return m_updateUrls; 0027 } 0028 0029 qulonglong UploadEpisodeActionRequest::timestamp() const 0030 { 0031 return m_timestamp; 0032 } 0033 0034 void UploadEpisodeActionRequest::processResults() 0035 { 0036 if (m_reply->error()) { 0037 m_error = m_reply->error(); 0038 m_errorString = m_reply->errorString(); 0039 qCDebug(kastsSync) << "m_reply error" << m_reply->errorString(); 0040 } else if (!m_abort) { 0041 QJsonParseError *error = nullptr; 0042 QJsonDocument data = QJsonDocument::fromJson(m_reply->readAll(), error); 0043 if (error) { 0044 qCDebug(kastsSync) << "parse error" << error->errorString(); 0045 m_error = 1; 0046 m_errorString = error->errorString(); 0047 } else { 0048 for (auto jsonFeed : data.object().value(QStringLiteral("update_urls")).toArray()) { 0049 m_updateUrls += std::pair<QString, QString>(jsonFeed.toArray().at(0).toString(), jsonFeed.toArray().at(1).toString()); 0050 } 0051 m_timestamp = data.object().value(QStringLiteral("timestamp")).toInt(); 0052 } 0053 } 0054 Q_EMIT finished(); 0055 m_reply->deleteLater(); 0056 deleteLater(); 0057 }