Commit 3779f0e3 authored by Gus Grubba's avatar Gus Grubba

Test authentication as soon as the user adds/changes user name and/or password.

parent 7aecf62b
......@@ -63,6 +63,7 @@ AirMapManager::~AirMapManager()
void
AirMapManager::setToolbox(QGCToolbox* toolbox)
{
_settingsTimer.setSingleShot(true);
AirspaceManager::setToolbox(toolbox);
AirMapSettings* ap = toolbox->settingsManager()->airMapSettings();
connect(ap->enableAirMap(), &Fact::rawValueChanged, this, &AirMapManager::_settingsChanged);
......@@ -71,7 +72,8 @@ AirMapManager::setToolbox(QGCToolbox* toolbox)
connect(ap->clientID(), &Fact::rawValueChanged, this, &AirMapManager::_settingsChanged);
connect(ap->userName(), &Fact::rawValueChanged, this, &AirMapManager::_settingsChanged);
connect(ap->password(), &Fact::rawValueChanged, this, &AirMapManager::_settingsChanged);
_settingsChanged();
connect(&_settingsTimer, &QTimer::timeout, this, &AirMapManager::_settingsTimeout);
_settingsTimeout();
}
//-----------------------------------------------------------------------------
......@@ -100,6 +102,13 @@ AirMapManager::_authStatusChanged(AirspaceManager::AuthStatus status)
//-----------------------------------------------------------------------------
void
AirMapManager::_settingsChanged()
{
_settingsTimer.start(1000);
}
//-----------------------------------------------------------------------------
void
AirMapManager::_settingsTimeout()
{
qCDebug(AirMapManagerLog) << "AirMap settings changed";
_connectStatus.clear();
......@@ -156,6 +165,8 @@ AirMapManager::_settingsChanged()
emit connectedChanged();
_connectStatus = tr("AirMap Enabled");
emit connectStatusChanged();
//-- Now test authentication
_shared.login();
} else {
qWarning("Failed to create airmap::qt::Client instance");
QString description = QString::fromStdString(result.error().description() ? result.error().description().get() : "");
......
......@@ -55,10 +55,12 @@ protected:
private slots:
void _error (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);
void _settingsChanged ();
void _settingsTimeout ();
void _authStatusChanged (AirspaceManager::AuthStatus status);
private:
QString _connectStatus;
QTimer _settingsTimer;
AirMapSharedState _shared;
std::shared_ptr<airmap::qt::Logger> _logger;
std::shared_ptr<airmap::qt::DispatchingLogger> _dispatchingLogger;
......
......@@ -76,7 +76,7 @@ AirMapSharedState::login()
if (result) {
qCDebug(AirMapManagerLog) << "Successfully authenticated with AirMap: id="<< result.value().id.c_str()<<", access="
<<result.value().access.c_str();
emit authStatus(AirspaceManager::AuthStatus::Autheticated);
emit authStatus(AirspaceManager::AuthStatus::Authenticated);
_loginToken = QString::fromStdString(result.value().id);
_processPendingRequests();
} else {
......
......@@ -209,10 +209,10 @@ QGCView {
return qsTr("")
case AirspaceManager.Anonymous:
return qsTr("Anonymous")
case AirspaceManager.Autheticated:
return qsTr("Autheticated")
case AirspaceManager.Authenticated:
return qsTr("Authenticated")
default:
return qsTr("Authetication Error")
return qsTr("Authentication Error")
}
}
Layout.rowSpan: 2
......
......@@ -60,7 +60,7 @@ public:
enum AuthStatus {
Unknown,
Anonymous,
Autheticated,
Authenticated,
Error
};
......
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