Commit cd52626a authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

snap: Use OdrsRatingsBackend for Snap as well

We have AppStream ids there so there's no reason to use anything else.
parent 457aa9f4
add_subdirectory(libsnapclient)
add_library(snap-backend MODULE SnapResource.cpp SnapBackend.cpp SnapReviewsBackend.cpp SnapTransaction.cpp snapui.qrc)
add_library(snap-backend MODULE SnapResource.cpp SnapBackend.cpp SnapTransaction.cpp snapui.qrc)
target_link_libraries(snap-backend Qt5::Core KF5::CoreAddons KF5::ConfigCore Discover::Common Snapd::Core)
if ("${Snapd_VERSION}" VERSION_GREATER 1.40)
......
......@@ -21,7 +21,7 @@
#include "SnapBackend.h"
#include "SnapTransaction.h"
#include "SnapResource.h"
#include "SnapReviewsBackend.h"
#include "appstream/OdrsReviewsBackend.h"
#include <resources/StandardBackendUpdater.h>
#include <resources/SourcesModel.h>
#include <Category/Category.h>
......@@ -68,7 +68,7 @@ private:
SnapBackend::SnapBackend(QObject* parent)
: AbstractResourcesBackend(parent)
, m_updater(new StandardBackendUpdater(this))
, m_reviews(new SnapReviewsBackend(this))
, m_reviews(new OdrsReviewsBackend(this))
{
{
auto request = m_client.connect();
......@@ -79,7 +79,7 @@ SnapBackend::SnapBackend(QObject* parent)
return;
}
}
connect(m_reviews, &SnapReviewsBackend::ratingsReady, this, &AbstractResourcesBackend::emitRatingsReady);
connect(m_reviews, &OdrsReviewsBackend::ratingsReady, this, &AbstractResourcesBackend::emitRatingsReady);
//make sure we populate the installed resources first
refreshStates();
......
......@@ -28,7 +28,7 @@
#include <functional>
class QAction;
class SnapReviewsBackend;
class OdrsReviewsBackend;
class StandardBackendUpdater;
class SnapResource;
class SnapBackend : public AbstractResourcesBackend
......@@ -66,7 +66,7 @@ private:
QHash<QString, SnapResource*> m_resources;
StandardBackendUpdater* m_updater;
SnapReviewsBackend* m_reviews;
OdrsReviewsBackend* m_reviews;
bool m_valid = true;
bool m_fetching = false;
......
/***************************************************************************
* Copyright © 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "SnapReviewsBackend.h"
#include "SnapBackend.h"
#include <ReviewsBackend/Review.h>
#include <ReviewsBackend/Rating.h>
#include <resources/AbstractResource.h>
#include <QTimer>
#include <QDebug>
SnapReviewsBackend::SnapReviewsBackend(SnapBackend* parent)
: AbstractReviewsBackend(parent)
{}
void SnapReviewsBackend::fetchReviews(AbstractResource* /*app*/, int /*page*/)
{
emit reviewsReady({}, {}, false);
}
Rating* SnapReviewsBackend::ratingForApplication(AbstractResource* /*app*/) const
{
return nullptr;
}
void SnapReviewsBackend::submitUsefulness(Review* /*r*/, bool /*useful*/)
{
}
void SnapReviewsBackend::submitReview(AbstractResource* /*res*/, const QString& /*a*/, const QString& /*b*/, const QString& /*c*/)
{
}
bool SnapReviewsBackend::isResourceSupported(AbstractResource* /*res*/) const
{
return false;
}
/***************************************************************************
* Copyright © 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef SNAPREVIEWSBACKEND_H
#define SNAPREVIEWSBACKEND_H
#include <ReviewsBackend/AbstractReviewsBackend.h>
#include <ReviewsBackend/ReviewsModel.h>
#include <QMap>
class SnapBackend;
class SnapReviewsBackend : public AbstractReviewsBackend
{
Q_OBJECT
public:
explicit SnapReviewsBackend(SnapBackend* parent = nullptr);
QString userName() const override { return QStringLiteral("snap"); }
void login() override {}
void logout() override {}
void registerAndLogin() override {}
Rating* ratingForApplication(AbstractResource* app) const override;
bool hasCredentials() const override { return false; }
void deleteReview(Review*) override {}
void fetchReviews(AbstractResource* app, int page = 1) override;
bool isFetching() const override { return false; }
void submitReview(AbstractResource*, const QString&, const QString&, const QString&) override;
void flagReview(Review*, const QString&, const QString&) override {}
void submitUsefulness(Review*, bool) override;
bool isResourceSupported(AbstractResource * res) const override;
Q_SIGNALS:
void ratingsReady();
};
#endif // SNAPREVIEWSBACKEND_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment