2023-06-02 14:23:26 +02:00
|
|
|
/**
|
|
|
|
* SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
2024-01-02 14:27:27 +01:00
|
|
|
#include <QQmlEngine>
|
2023-06-02 14:23:26 +02:00
|
|
|
|
|
|
|
class NetworkConnectionManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2024-01-02 14:27:27 +01:00
|
|
|
QML_ELEMENT
|
|
|
|
QML_SINGLETON
|
2023-06-02 14:23:26 +02:00
|
|
|
|
2023-11-06 16:50:02 +01:00
|
|
|
Q_PROPERTY(bool networkReachable READ networkReachable NOTIFY networkReachableChanged)
|
2023-06-02 14:23:26 +02:00
|
|
|
Q_PROPERTY(bool feedUpdatesAllowed READ feedUpdatesAllowed NOTIFY feedUpdatesAllowedChanged)
|
|
|
|
Q_PROPERTY(bool episodeDownloadsAllowed READ episodeDownloadsAllowed NOTIFY episodeDownloadsAllowedChanged)
|
|
|
|
Q_PROPERTY(bool imageDownloadsAllowed READ imageDownloadsAllowed NOTIFY imageDownloadsAllowedChanged)
|
|
|
|
Q_PROPERTY(bool streamingAllowed READ streamingAllowed NOTIFY streamingAllowedChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
static NetworkConnectionManager &instance()
|
|
|
|
{
|
|
|
|
static NetworkConnectionManager _instance;
|
|
|
|
return _instance;
|
|
|
|
}
|
2024-01-02 14:27:27 +01:00
|
|
|
static NetworkConnectionManager *create(QQmlEngine *engine, QJSEngine *)
|
|
|
|
{
|
|
|
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
|
|
|
return &instance();
|
|
|
|
}
|
2023-06-02 14:23:26 +02:00
|
|
|
|
2023-11-06 16:50:02 +01:00
|
|
|
[[nodiscard]] bool networkReachable() const;
|
2023-06-02 14:23:26 +02:00
|
|
|
[[nodiscard]] bool feedUpdatesAllowed() const;
|
|
|
|
[[nodiscard]] bool episodeDownloadsAllowed() const;
|
|
|
|
[[nodiscard]] bool imageDownloadsAllowed() const;
|
|
|
|
[[nodiscard]] bool streamingAllowed() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2023-11-06 16:50:02 +01:00
|
|
|
void networkReachableChanged();
|
2023-06-02 14:23:26 +02:00
|
|
|
void feedUpdatesAllowedChanged();
|
|
|
|
void episodeDownloadsAllowedChanged();
|
|
|
|
void imageDownloadsAllowedChanged();
|
|
|
|
void streamingAllowedChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
NetworkConnectionManager(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
bool m_backendAvailable = false;
|
|
|
|
};
|