2021-07-30 14:19:46 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021 Tobias Fella <fella@posteo.de>
|
2022-02-11 03:50:09 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
2021-07-30 14:19:46 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <ModemManagerQt/Manager>
|
2022-04-24 11:44:41 +00:00
|
|
|
#include <ModemManagerQt/Modem3Gpp>
|
2022-02-11 03:50:09 +00:00
|
|
|
|
2022-02-13 04:07:09 +00:00
|
|
|
#include <NetworkManagerQt/Connection>
|
|
|
|
|
#include <NetworkManagerQt/ModemDevice>
|
|
|
|
|
|
2021-07-30 14:19:46 +00:00
|
|
|
#include <QObject>
|
2023-11-02 11:08:17 +00:00
|
|
|
#include <qqmlregistration.h>
|
2021-07-30 14:19:46 +00:00
|
|
|
|
2023-04-01 07:09:57 +00:00
|
|
|
#include "profilesettings.h"
|
|
|
|
|
|
2022-02-11 03:50:09 +00:00
|
|
|
// We make the assumption that there is only one modem.
|
2021-07-30 14:19:46 +00:00
|
|
|
class SignalIndicator : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2023-11-02 11:08:17 +00:00
|
|
|
QML_ELEMENT
|
|
|
|
|
QML_SINGLETON
|
2021-07-30 14:19:46 +00:00
|
|
|
|
|
|
|
|
Q_PROPERTY(int strength READ strength NOTIFY strengthChanged)
|
|
|
|
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
2022-10-23 16:12:40 +00:00
|
|
|
Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableChanged)
|
2021-07-30 14:19:46 +00:00
|
|
|
Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged)
|
2022-09-12 20:36:19 +00:00
|
|
|
Q_PROPERTY(bool simEmpty READ simEmpty NOTIFY simEmptyChanged)
|
2023-02-23 16:43:38 +00:00
|
|
|
|
2022-02-13 04:07:09 +00:00
|
|
|
Q_PROPERTY(bool mobileDataSupported READ mobileDataSupported NOTIFY mobileDataSupportedChanged)
|
|
|
|
|
Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledChanged)
|
2023-02-23 16:43:38 +00:00
|
|
|
|
2022-09-10 03:37:15 +00:00
|
|
|
Q_PROPERTY(bool needsAPNAdded READ needsAPNAdded NOTIFY mobileDataEnabledChanged)
|
2023-04-01 07:09:57 +00:00
|
|
|
Q_PROPERTY(QList<ProfileSettings *> profiles READ profileList NOTIFY profileListChanged)
|
|
|
|
|
Q_PROPERTY(QString activeConnectionUni READ activeConnectionUni NOTIFY activeConnectionUniChanged)
|
2021-07-30 14:19:46 +00:00
|
|
|
|
|
|
|
|
public:
|
2022-10-23 17:45:29 +00:00
|
|
|
SignalIndicator(QObject *parent = nullptr);
|
2021-07-30 14:19:46 +00:00
|
|
|
|
|
|
|
|
int strength() const;
|
|
|
|
|
QString name() const;
|
2022-10-23 16:12:40 +00:00
|
|
|
bool modemAvailable() const;
|
2021-07-30 14:19:46 +00:00
|
|
|
bool simLocked() const;
|
2022-09-12 20:36:19 +00:00
|
|
|
bool simEmpty() const;
|
2022-02-13 04:07:09 +00:00
|
|
|
bool mobileDataSupported() const;
|
|
|
|
|
bool mobileDataEnabled() const;
|
2022-09-10 03:37:15 +00:00
|
|
|
bool needsAPNAdded() const;
|
2023-04-01 07:09:57 +00:00
|
|
|
QString activeConnectionUni() const;
|
2022-02-11 03:50:09 +00:00
|
|
|
|
2022-02-13 04:07:09 +00:00
|
|
|
void setMobileDataEnabled(bool enabled);
|
2021-07-30 14:19:46 +00:00
|
|
|
|
2023-04-01 07:09:57 +00:00
|
|
|
// connection profiles
|
|
|
|
|
QList<ProfileSettings *> &profileList();
|
|
|
|
|
void refreshProfiles();
|
|
|
|
|
Q_INVOKABLE void activateProfile(const QString &connectionUni);
|
|
|
|
|
Q_INVOKABLE void addProfile(const QString &name, const QString &apn, const QString &username, const QString &password, const QString &networkType);
|
|
|
|
|
Q_INVOKABLE void removeProfile(const QString &connectionUni);
|
|
|
|
|
Q_INVOKABLE void updateProfile(const QString &connectionUni,
|
|
|
|
|
const QString &name,
|
|
|
|
|
const QString &apn,
|
|
|
|
|
const QString &username,
|
|
|
|
|
const QString &password,
|
|
|
|
|
const QString &networkType);
|
|
|
|
|
|
2021-07-30 14:19:46 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
|
void strengthChanged();
|
|
|
|
|
void nameChanged();
|
2022-10-23 16:12:40 +00:00
|
|
|
void modemAvailableChanged();
|
2021-07-30 14:19:46 +00:00
|
|
|
void simLockedChanged();
|
2022-09-12 20:36:19 +00:00
|
|
|
void simEmptyChanged();
|
2022-02-13 04:07:09 +00:00
|
|
|
void mobileDataSupportedChanged();
|
|
|
|
|
void mobileDataEnabledChanged();
|
2023-04-01 07:09:57 +00:00
|
|
|
void profileListChanged();
|
|
|
|
|
void activeConnectionUniChanged();
|
2021-07-30 14:19:46 +00:00
|
|
|
|
|
|
|
|
private:
|
2022-02-13 04:07:09 +00:00
|
|
|
NetworkManager::ModemDevice::Ptr m_nmModem;
|
|
|
|
|
ModemManager::ModemDevice::Ptr m_modemDevice;
|
2021-07-30 14:19:46 +00:00
|
|
|
ModemManager::Modem::Ptr m_modem;
|
|
|
|
|
ModemManager::Modem3gpp::Ptr m_3gppModem;
|
2022-02-13 04:07:09 +00:00
|
|
|
|
2023-04-01 07:09:57 +00:00
|
|
|
QList<ProfileSettings *> m_profileList;
|
|
|
|
|
|
2022-10-23 16:12:40 +00:00
|
|
|
void updateModemManagerModem();
|
|
|
|
|
void updateNetworkManagerModem();
|
2021-07-30 14:19:46 +00:00
|
|
|
};
|