some fixes
This commit is contained in:
parent
5086d1373a
commit
4d6ba26a59
@ -164,7 +164,7 @@ void NymeaDiscovery::cacheHost(NymeaHost *host)
|
||||
settings.beginGroup(QString::number(i++));
|
||||
settings.setValue("url", connection->url());
|
||||
settings.setValue("bearerType", connection->bearerType());
|
||||
settings.value("secure", connection->secure());
|
||||
settings.setValue("secure", connection->secure());
|
||||
settings.setValue("displayName", connection->displayName());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -161,6 +161,7 @@ Connection *NymeaConnection::currentConnection() const
|
||||
if (!m_currentHost || !m_currentTransport) {
|
||||
return nullptr;
|
||||
}
|
||||
qDebug() << "secure:" << m_transportCandidates.value(m_currentTransport)->secure();
|
||||
return m_transportCandidates.value(m_currentTransport);
|
||||
}
|
||||
|
||||
|
||||
@ -189,6 +189,11 @@ bool JsonRpcClient::pushButtonAuthAvailable() const
|
||||
return m_pushButtonAuthAvailable;
|
||||
}
|
||||
|
||||
bool JsonRpcClient::authenticated() const
|
||||
{
|
||||
return m_authenticated;
|
||||
}
|
||||
|
||||
JsonRpcClient::CloudConnectionState JsonRpcClient::cloudConnectionState() const
|
||||
{
|
||||
return m_cloudConnectionState;
|
||||
@ -297,6 +302,9 @@ void JsonRpcClient::processAuthenticate(const QVariantMap &data)
|
||||
settings.endGroup();
|
||||
emit authenticationRequiredChanged();
|
||||
|
||||
m_authenticated = true;
|
||||
emit authenticated();
|
||||
|
||||
setNotificationsEnabled();
|
||||
} else {
|
||||
qWarning() << "Authentication failed" << data;
|
||||
@ -376,6 +384,7 @@ void JsonRpcClient::onInterfaceConnectedChanged(bool connected)
|
||||
qDebug() << "JsonRpcClient: Transport disconnected.";
|
||||
m_initialSetupRequired = false;
|
||||
m_authenticationRequired = false;
|
||||
m_authenticated = false;
|
||||
m_serverQtVersion.clear();
|
||||
m_serverQtBuildVersion.clear();
|
||||
if (m_connected) {
|
||||
@ -442,6 +451,8 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
||||
settings.setValue(m_serverUuid, m_token);
|
||||
settings.endGroup();
|
||||
emit authenticationRequiredChanged();
|
||||
m_authenticated = false;
|
||||
emit authenticatedChanged();
|
||||
}
|
||||
|
||||
if (!reply->caller().isNull() && !reply->callback().isEmpty()) {
|
||||
@ -508,11 +519,13 @@ void JsonRpcClient::helloReply(const QVariantMap ¶ms)
|
||||
if (m_token.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_authenticated = true;
|
||||
emit authenticatedChanged();
|
||||
}
|
||||
|
||||
setNotificationsEnabled();
|
||||
getCloudConnectionStatus();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ class JsonRpcClient : public JsonHandler
|
||||
Q_PROPERTY(bool initialSetupRequired READ initialSetupRequired NOTIFY initialSetupRequiredChanged)
|
||||
Q_PROPERTY(bool authenticationRequired READ authenticationRequired NOTIFY authenticationRequiredChanged)
|
||||
Q_PROPERTY(bool pushButtonAuthAvailable READ pushButtonAuthAvailable NOTIFY pushButtonAuthAvailableChanged)
|
||||
Q_PROPERTY(bool authenticated READ authenticated NOTIFY authenticatedChanged)
|
||||
Q_PROPERTY(CloudConnectionState cloudConnectionState READ cloudConnectionState NOTIFY cloudConnectionStateChanged)
|
||||
Q_PROPERTY(QString serverVersion READ serverVersion NOTIFY handshakeReceived)
|
||||
Q_PROPERTY(QString jsonRpcVersion READ jsonRpcVersion NOTIFY handshakeReceived)
|
||||
@ -81,6 +82,7 @@ public:
|
||||
bool initialSetupRequired() const;
|
||||
bool authenticationRequired() const;
|
||||
bool pushButtonAuthAvailable() const;
|
||||
bool authenticated() const;
|
||||
CloudConnectionState cloudConnectionState() const;
|
||||
void deployCertificate(const QByteArray &rootCA, const QByteArray &certificate, const QByteArray &publicKey, const QByteArray &privateKey, const QString &endpoint);
|
||||
|
||||
@ -103,6 +105,7 @@ signals:
|
||||
void initialSetupRequiredChanged();
|
||||
void authenticationRequiredChanged();
|
||||
void pushButtonAuthAvailableChanged();
|
||||
void authenticatedChanged();
|
||||
void connectedChanged(bool connected);
|
||||
void tokenChanged();
|
||||
void invalidProtocolVersion(const QString &actualVersion, const QString &minimumVersion);
|
||||
@ -135,6 +138,7 @@ private:
|
||||
bool m_initialSetupRequired = false;
|
||||
bool m_authenticationRequired = false;
|
||||
bool m_pushButtonAuthAvailable = false;
|
||||
bool m_authenticated = false;
|
||||
CloudConnectionState m_cloudConnectionState = CloudConnectionStateDisabled;
|
||||
int m_pendingPushButtonTransaction = -1;
|
||||
QString m_serverUuid;
|
||||
|
||||
@ -75,6 +75,7 @@ Page {
|
||||
Material.elevation: layout.isGrid ? 1 : 0
|
||||
padding: 0
|
||||
visible: engine.jsonRpcClient.ensureServerVersion("4.2")
|
||||
&& engine.jsonRpcClient.authenticated
|
||||
NymeaListItemDelegate {
|
||||
width: parent.width
|
||||
iconName: "../images/account.svg"
|
||||
|
||||
@ -53,7 +53,7 @@ Page {
|
||||
popup.open();
|
||||
}
|
||||
onCreateUserSucceeded: {
|
||||
engine.jsonRpcClient.authenticate(usernameTextField.text, passwordTextField.password, "nymea-app (" + PlatformHelper.device + ")");
|
||||
engine.jsonRpcClient.authenticate(usernameTextField.text, passwordTextField.password, "nymea-app (" + PlatformHelper.deviceModel + ")");
|
||||
}
|
||||
|
||||
onCreateUserFailed: {
|
||||
@ -153,7 +153,7 @@ Page {
|
||||
engine.jsonRpcClient.createUser(usernameTextField.text, passwordTextField.password);
|
||||
} else {
|
||||
print("authenticate", usernameTextField.text, passwordTextField.text, "nymea-app")
|
||||
engine.jsonRpcClient.authenticate(usernameTextField.text, passwordTextField.password, "nymea-app (" + PlatformHelper.device + ")");
|
||||
engine.jsonRpcClient.authenticate(usernameTextField.text, passwordTextField.password, "nymea-app (" + PlatformHelper.deviceModel + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user