Add device serial api
This commit is contained in:
parent
a9c394b577
commit
8a327717db
@ -59,6 +59,11 @@ void SystemController::init()
|
||||
m_updateManagementAvailable = false;
|
||||
m_timeManagementAvailable = false;
|
||||
}
|
||||
if (m_jsonRpcClient->ensureServerVersion("5.5")) {
|
||||
m_jsonRpcClient->sendCommand("System.GetSystemInfo", this, "getSystemInfoResponse");
|
||||
} else {
|
||||
m_deviceSerialNumber.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QString SystemController::nameSpace() const
|
||||
@ -203,6 +208,11 @@ int SystemController::setAutomaticTime(bool automaticTime)
|
||||
return m_jsonRpcClient->sendCommand("System.SetTime", params, this, "setTimeResponse");
|
||||
}
|
||||
|
||||
QString SystemController::deviceSerialNumber() const
|
||||
{
|
||||
return m_deviceSerialNumber;
|
||||
}
|
||||
|
||||
void SystemController::getCapabilitiesResponse(int /*commandId*/, const QVariantMap &data)
|
||||
{
|
||||
m_powerManagementAvailable = data.value("powerManagement").toBool();
|
||||
@ -318,6 +328,13 @@ void SystemController::shutdownResponse(int commandId, const QVariantMap ¶ms
|
||||
emit shutdownReply(commandId, success);
|
||||
}
|
||||
|
||||
void SystemController::getSystemInfoResponse(int commandId, const QVariantMap ¶ms)
|
||||
{
|
||||
Q_UNUSED(commandId)
|
||||
m_deviceSerialNumber = params.value("deviceSerialNumber").toString();
|
||||
emit deviceSerialNumberChanged();
|
||||
}
|
||||
|
||||
void SystemController::notificationReceived(const QVariantMap &data)
|
||||
{
|
||||
QString notification = data.value("notification").toString();
|
||||
|
||||
@ -57,6 +57,8 @@ class SystemController : public JsonHandler
|
||||
Q_PROPERTY(bool automaticTimeAvailable READ automaticTimeAvailable NOTIFY automaticTimeAvailableChanged)
|
||||
Q_PROPERTY(bool automaticTime READ automaticTime WRITE setAutomaticTime NOTIFY automaticTimeChanged)
|
||||
|
||||
Q_PROPERTY(QString deviceSerialNumber READ deviceSerialNumber NOTIFY deviceSerialNumberChanged)
|
||||
|
||||
public:
|
||||
explicit SystemController(JsonRpcClient *jsonRpcClient, QObject *parent = nullptr);
|
||||
|
||||
@ -88,6 +90,8 @@ public:
|
||||
bool automaticTime() const;
|
||||
int setAutomaticTime(bool automaticTime);
|
||||
|
||||
QString deviceSerialNumber() const;
|
||||
|
||||
signals:
|
||||
void powerManagementAvailableChanged();
|
||||
void updateManagementAvailableChanged();
|
||||
@ -99,6 +103,7 @@ signals:
|
||||
void serverTimeZoneChanged();
|
||||
void automaticTimeAvailableChanged();
|
||||
void automaticTimeChanged();
|
||||
void deviceSerialNumberChanged();
|
||||
|
||||
void restartReply(int id, bool success);
|
||||
void rebootReply(int id, bool success);
|
||||
@ -116,6 +121,7 @@ private slots:
|
||||
void restartResponse(int commandId, const QVariantMap ¶ms);
|
||||
void rebootResponse(int commandId, const QVariantMap ¶ms);
|
||||
void shutdownResponse(int commandId, const QVariantMap ¶ms);
|
||||
void getSystemInfoResponse(int commandId, const QVariantMap ¶ms);
|
||||
|
||||
void notificationReceived(const QVariantMap &data);
|
||||
|
||||
@ -140,6 +146,8 @@ private:
|
||||
QStringList m_timeZones;
|
||||
bool m_automaticTimeAvailable = false;
|
||||
bool m_automaticTime = false;
|
||||
|
||||
QString m_deviceSerialNumber;
|
||||
};
|
||||
|
||||
#endif // SYSTEMCONTROLLER_H
|
||||
|
||||
@ -37,6 +37,7 @@ import Nymea 1.0
|
||||
SwipeDelegate {
|
||||
id: root
|
||||
implicitWidth: 200
|
||||
implicitHeight: Style.smallDelegateHeight
|
||||
|
||||
property string subText
|
||||
property bool progressive: true
|
||||
|
||||
@ -81,5 +81,13 @@ SettingsPageBase {
|
||||
progressive: false
|
||||
prominentSubText: false
|
||||
}
|
||||
NymeaSwipeDelegate {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Device serial number")
|
||||
subText: engine.systemController.deviceSerialNumber
|
||||
visible: engine.systemController.deviceSerialNumber.length > 0
|
||||
progressive: false
|
||||
prominentSubText: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user