Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
9377ebb2
Commit
9377ebb2
authored
Jul 24, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep track of user name/password authentication state
parent
1323625b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
79 additions
and
20 deletions
+79
-20
AirMapManager.cc
src/Airmap/AirMapManager.cc
+20
-6
AirMapManager.h
src/Airmap/AirMapManager.h
+3
-0
AirMapRulesetsManager.cc
src/Airmap/AirMapRulesetsManager.cc
+0
-3
AirMapSharedState.cc
src/Airmap/AirMapSharedState.cc
+4
-0
AirMapSharedState.h
src/Airmap/AirMapSharedState.h
+4
-1
AirmapSettings.qml
src/Airmap/AirmapSettings.qml
+30
-5
AirspaceAdvisoryProvider.h
src/AirspaceManagement/AirspaceAdvisoryProvider.h
+1
-1
AirspaceManager.h
src/AirspaceManagement/AirspaceManager.h
+13
-0
AirspaceRestriction.h
src/AirspaceManagement/AirspaceRestriction.h
+3
-3
AirspaceRestrictionProvider.h
src/AirspaceManagement/AirspaceRestrictionProvider.h
+1
-1
No files found.
src/Airmap/AirMapManager.cc
View file @
9377ebb2
...
...
@@ -39,6 +39,7 @@ QGC_LOGGING_CATEGORY(AirMapManagerLog, "AirMapManagerLog")
//-----------------------------------------------------------------------------
AirMapManager
::
AirMapManager
(
QGCApplication
*
app
,
QGCToolbox
*
toolbox
)
:
AirspaceManager
(
app
,
toolbox
)
,
_authStatus
(
Unknown
)
{
_logger
=
std
::
make_shared
<
qt
::
Logger
>
();
qt
::
register_types
();
// TODO: still needed?
...
...
@@ -47,6 +48,7 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox)
_logger
->
logging_category
().
setEnabled
(
QtWarningMsg
,
false
);
_dispatchingLogger
=
std
::
make_shared
<
qt
::
DispatchingLogger
>
(
_logger
);
connect
(
&
_shared
,
&
AirMapSharedState
::
error
,
this
,
&
AirMapManager
::
_error
);
connect
(
&
_shared
,
&
AirMapSharedState
::
authStatus
,
this
,
&
AirMapManager
::
_authStatusChanged
);
}
//-----------------------------------------------------------------------------
...
...
@@ -87,6 +89,14 @@ AirMapManager::_error(const QString& what, const QString& airmapdMessage, const
qgcApp
()
->
showMessage
(
QString
(
"AirMap Error: %1. %2"
).
arg
(
what
).
arg
(
airmapdMessage
));
}
//-----------------------------------------------------------------------------
void
AirMapManager
::
_authStatusChanged
(
AirspaceManager
::
AuthStatus
status
)
{
_authStatus
=
status
;
emit
authStatusChanged
();
}
//-----------------------------------------------------------------------------
void
AirMapManager
::
_settingsChanged
()
...
...
@@ -97,6 +107,7 @@ AirMapManager::_settingsChanged()
AirMapSettings
*
ap
=
_toolbox
->
settingsManager
()
->
airMapSettings
();
//-- If we are disabled, there is nothing else to do.
if
(
!
ap
->
enableAirMap
()
->
rawValue
().
toBool
())
{
_shared
.
logout
();
if
(
_shared
.
client
())
{
delete
_shared
.
client
();
_shared
.
setClient
(
nullptr
);
...
...
@@ -109,21 +120,24 @@ AirMapManager::_settingsChanged()
settings
.
apiKey
=
ap
->
apiKey
()
->
rawValueString
();
settings
.
clientID
=
ap
->
clientID
()
->
rawValueString
();
}
settings
.
userName
=
ap
->
userName
()
->
rawValueString
();
settings
.
password
=
ap
->
password
()
->
rawValueString
();
//-- If we have a hardwired key (and no custom key is present), set it.
#if defined(QGC_AIRMAP_KEY_AVAILABLE)
if
(
!
ap
->
usePersonalApiKey
()
->
rawValue
().
toBool
())
{
settings
.
apiKey
=
kAirmapAPIKey
;
settings
.
clientID
=
kAirmapClientID
;
}
bool
a
piKey
Changed
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
||
settings
.
apiKey
.
isEmpty
();
bool
a
uth
Changed
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
||
settings
.
apiKey
.
isEmpty
();
#else
bool
a
piKey
Changed
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
;
bool
a
uth
Changed
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
;
#endif
settings
.
userName
=
ap
->
userName
()
->
rawValueString
();
settings
.
password
=
ap
->
password
()
->
rawValueString
();
if
(
settings
.
userName
!=
_shared
.
settings
().
userName
||
settings
.
password
!=
_shared
.
settings
().
password
)
{
authChanged
=
true
;
}
_shared
.
setSettings
(
settings
);
//-- Need to re-create the client if the API key changed
if
((
_shared
.
client
()
&&
a
piKey
Changed
)
||
!
ap
->
enableAirMap
()
->
rawValue
().
toBool
())
{
//-- Need to re-create the client if the API key
or user name/password
changed
if
((
_shared
.
client
()
&&
a
uth
Changed
)
||
!
ap
->
enableAirMap
()
->
rawValue
().
toBool
())
{
delete
_shared
.
client
();
_shared
.
setClient
(
nullptr
);
emit
connectedChanged
();
...
...
src/Airmap/AirMapManager.h
View file @
9377ebb2
...
...
@@ -43,6 +43,7 @@ public:
AirspaceVehicleManager
*
instantiateVehicle
(
const
Vehicle
&
vehicle
)
override
;
bool
connected
()
const
override
;
QString
connectStatus
()
const
override
{
return
_connectStatus
;
}
AirspaceManager
::
AuthStatus
authStatus
()
const
override
{
return
_authStatus
;
}
protected:
AirspaceRulesetsProvider
*
_instantiateRulesetsProvider
()
override
;
...
...
@@ -54,12 +55,14 @@ protected:
private
slots
:
void
_error
(
const
QString
&
what
,
const
QString
&
airmapdMessage
,
const
QString
&
airmapdDetails
);
void
_settingsChanged
();
void
_authStatusChanged
(
AirspaceManager
::
AuthStatus
status
);
private:
QString
_connectStatus
;
AirMapSharedState
_shared
;
std
::
shared_ptr
<
airmap
::
qt
::
Logger
>
_logger
;
std
::
shared_ptr
<
airmap
::
qt
::
DispatchingLogger
>
_dispatchingLogger
;
AirspaceManager
::
AuthStatus
_authStatus
;
};
src/Airmap/AirMapRulesetsManager.cc
View file @
9377ebb2
...
...
@@ -197,7 +197,6 @@ AirMapRuleSet::setSelected(bool sel)
if
(
_selected
!=
sel
)
{
_selected
=
sel
;
emit
selectedChanged
();
qDebug
()
<<
"Selection"
<<
name
()
<<
sel
;
qgcApp
()
->
toolbox
()
->
airspaceManager
()
->
setUpdate
();
}
}
else
{
...
...
@@ -244,7 +243,6 @@ void AirMapRulesetsManager::setROI(const QGCGeoBoundingCube& roi, bool reset)
for
(
int
rs
=
0
;
rs
<
ruleSets
()
->
count
();
rs
++
)
{
AirMapRuleSet
*
ruleSet
=
qobject_cast
<
AirMapRuleSet
*>
(
ruleSets
()
->
get
(
rs
));
selectionSet
[
ruleSet
->
id
()]
=
ruleSet
->
selected
();
qDebug
()
<<
ruleSet
->
id
()
<<
ruleSet
->
selected
();
}
_ruleSets
.
clearAndDeleteContents
();
_state
=
State
::
RetrieveItems
;
...
...
@@ -277,7 +275,6 @@ void AirMapRulesetsManager::setROI(const QGCGeoBoundingCube& roi, bool reset)
//-- Restore selection set (if any)
if
(
selectionSet
.
contains
(
pRuleSet
->
id
()))
{
pRuleSet
->
_selected
=
selectionSet
[
pRuleSet
->
id
()];
qDebug
()
<<
pRuleSet
->
name
()
<<
pRuleSet
->
id
()
<<
pRuleSet
->
_selected
;
}
else
{
if
(
pRuleSet
->
_isDefault
)
{
pRuleSet
->
_selected
=
true
;
...
...
src/Airmap/AirMapSharedState.cc
View file @
9377ebb2
...
...
@@ -50,10 +50,12 @@ AirMapSharedState::login()
}
if
(
result
)
{
qCDebug
(
AirMapManagerLog
)
<<
"Successfully authenticated with AirMap: id="
<<
result
.
value
().
id
.
c_str
();
emit
authStatus
(
AirspaceManager
::
AuthStatus
::
Anonymous
);
_loginToken
=
QString
::
fromStdString
(
result
.
value
().
id
);
_processPendingRequests
();
}
else
{
_pendingRequests
.
clear
();
emit
authStatus
(
AirspaceManager
::
AuthStatus
::
Error
);
QString
description
=
QString
::
fromStdString
(
result
.
error
().
description
()
?
result
.
error
().
description
().
get
()
:
""
);
emit
error
(
"Failed to authenticate with AirMap"
,
QString
::
fromStdString
(
result
.
error
().
message
()),
description
);
...
...
@@ -73,11 +75,13 @@ 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
);
_loginToken
=
QString
::
fromStdString
(
result
.
value
().
id
);
_processPendingRequests
();
}
else
{
_pendingRequests
.
clear
();
QString
description
=
QString
::
fromStdString
(
result
.
error
().
description
()
?
result
.
error
().
description
().
get
()
:
""
);
emit
authStatus
(
AirspaceManager
::
AuthStatus
::
Error
);
emit
error
(
"Failed to authenticate with AirMap"
,
QString
::
fromStdString
(
result
.
error
().
message
()),
description
);
}
...
...
src/Airmap/AirMapSharedState.h
View file @
9377ebb2
...
...
@@ -12,6 +12,8 @@
#include <QObject>
#include <QQueue>
#include "AirspaceManager.h"
#include <airmap/qt/client.h>
/**
...
...
@@ -55,7 +57,8 @@ public:
const
QString
&
loginToken
()
const
{
return
_loginToken
;
}
signals:
void
error
(
const
QString
&
what
,
const
QString
&
airmapdMessage
,
const
QString
&
airmapdDetails
);
void
error
(
const
QString
&
what
,
const
QString
&
airmapdMessage
,
const
QString
&
airmapdDetails
);
void
authStatus
(
AirspaceManager
::
AuthStatus
status
);
private:
void
_processPendingRequests
();
...
...
src/Airmap/AirmapSettings.qml
View file @
9377ebb2
...
...
@@ -19,6 +19,7 @@ import QtLocation 5.3
import
QtPositioning
5.3
import
QGroundControl
1.0
import
QGroundControl
.
Airspace
1.0
import
QGroundControl
.
Controllers
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
FactControls
1.0
...
...
@@ -42,6 +43,7 @@ QGCView {
property
real
_panelWidth
:
_qgcView
.
width
*
_internalWidthRatio
property
Fact
_enableAirMapFact
:
QGroundControl
.
settingsManager
.
airMapSettings
.
enableAirMap
property
bool
_airMapEnabled
:
_enableAirMapFact
.
rawValue
property
var
_authStatus
:
QGroundControl
.
airspaceManager
.
authStatus
readonly
property
real
_internalWidthRatio
:
0.8
...
...
@@ -184,7 +186,8 @@ QGCView {
anchors.horizontalCenter
:
parent
.
horizontalCenter
GridLayout
{
id
:
loginGrid
columns
:
2
columns
:
3
columnSpacing
:
ScreenTools
.
defaultFontPixelWidth
rowSpacing
:
ScreenTools
.
defaultFontPixelHeight
*
0.25
anchors.centerIn
:
parent
QGCLabel
{
text
:
qsTr
(
"
User Name:
"
)
}
...
...
@@ -197,6 +200,24 @@ QGCView {
Layout.minimumWidth
:
_editFieldWidth
property
Fact
_usernameFact
:
QGroundControl
.
settingsManager
.
airMapSettings
.
userName
}
QGCLabel
{
text
:
{
if
(
!
QGroundControl
.
airspaceManager
.
connected
)
return
qsTr
(
"
Not Connected
"
)
switch
(
_authStatus
)
{
case
AirspaceManager
.
Unknown
:
return
qsTr
(
""
)
case
AirspaceManager
.
Anonymous
:
return
qsTr
(
"
Anonymous
"
)
case
AirspaceManager
.
Autheticated
:
return
qsTr
(
"
Autheticated
"
)
default
:
return
qsTr
(
"
Authetication Error
"
)
}
}
Layout
.
rowSpan
:
2
Layout
.
alignment
:
Qt
.
AlignVCenter
}
QGCLabel
{
text
:
qsTr
(
"
Password:
"
)
}
FactTextField
{
fact
:
_passwordFact
...
...
@@ -211,22 +232,26 @@ QGCView {
Item
{
width
:
1
height
:
1
Layout.columnSpan
:
2
}
Item
{
width
:
1
height
:
1
Layout.columnSpan
:
3
}
QGCLabel
{
text
:
qsTr
(
"
Forgot Your AirMap Password?
"
)
Layout.alignment
:
Qt
.
AlignHCenter
Layout.columnSpan
:
2
Layout.columnSpan
:
3
}
Item
{
width
:
1
height
:
1
Layout.columnSpan
:
2
Layout.columnSpan
:
3
}
QGCButton
{
text
:
qsTr
(
"
Register for an AirMap Account
"
)
Layout.alignment
:
Qt
.
AlignHCenter
Layout.columnSpan
:
2
Layout.columnSpan
:
3
enabled
:
_airMapEnabled
onClicked
:
{
Qt
.
openUrlExternally
(
"
https://www.airmap.com
"
);
...
...
src/AirspaceManagement/AirspaceAdvisoryProvider.h
View file @
9377ebb2
...
...
@@ -81,7 +81,7 @@ public:
Q_ENUM
(
AdvisoryType
)
AirspaceAdvisory
(
QObject
*
parent
=
NULL
);
AirspaceAdvisory
(
QObject
*
parent
=
nullptr
);
Q_PROPERTY
(
QString
id
READ
id
CONSTANT
)
Q_PROPERTY
(
QString
name
READ
name
CONSTANT
)
...
...
src/AirspaceManagement/AirspaceManager.h
View file @
9377ebb2
...
...
@@ -57,6 +57,15 @@ public:
AirspaceManager
(
QGCApplication
*
app
,
QGCToolbox
*
toolbox
);
virtual
~
AirspaceManager
()
override
;
enum
AuthStatus
{
Unknown
,
Anonymous
,
Autheticated
,
Error
};
Q_ENUM
(
AuthStatus
)
Q_PROPERTY
(
QString
providerName
READ
providerName
CONSTANT
)
Q_PROPERTY
(
AirspaceWeatherInfoProvider
*
weatherInfo
READ
weatherInfo
CONSTANT
)
Q_PROPERTY
(
AirspaceAdvisoryProvider
*
advisories
READ
advisories
CONSTANT
)
...
...
@@ -65,6 +74,7 @@ public:
Q_PROPERTY
(
AirspaceFlightPlanProvider
*
flightPlan
READ
flightPlan
CONSTANT
)
Q_PROPERTY
(
bool
connected
READ
connected
NOTIFY
connectedChanged
)
Q_PROPERTY
(
QString
connectStatus
READ
connectStatus
NOTIFY
connectStatusChanged
)
Q_PROPERTY
(
AirspaceManager
::
AuthStatus
authStatus
READ
authStatus
NOTIFY
authStatusChanged
)
Q_PROPERTY
(
bool
airspaceVisible
READ
airspaceVisible
WRITE
setAirspaceVisible
NOTIFY
airspaceVisibleChanged
)
Q_INVOKABLE
void
setROI
(
const
QGeoCoordinate
&
pointNW
,
const
QGeoCoordinate
&
pointSE
,
bool
planView
,
bool
reset
=
false
);
...
...
@@ -85,6 +95,8 @@ public:
virtual
QString
connectStatus
()
const
{
return
QString
();
}
virtual
void
setUpdate
();
virtual
AirspaceManager
::
AuthStatus
authStatus
()
const
{
return
Anonymous
;
}
/**
* Factory method to create an AirspaceVehicleManager object
*/
...
...
@@ -94,6 +106,7 @@ signals:
void
airspaceVisibleChanged
();
void
connectedChanged
();
void
connectStatusChanged
();
void
authStatusChanged
();
void
update
();
protected:
...
...
src/AirspaceManagement/AirspaceRestriction.h
View file @
9377ebb2
...
...
@@ -22,7 +22,7 @@ class AirspaceRestriction : public QObject
{
Q_OBJECT
public:
AirspaceRestriction
(
QObject
*
parent
=
NULL
);
AirspaceRestriction
(
QObject
*
parent
=
nullptr
);
};
/**
...
...
@@ -34,7 +34,7 @@ class AirspacePolygonRestriction : public AirspaceRestriction
{
Q_OBJECT
public:
AirspacePolygonRestriction
(
const
QVariantList
&
polygon
,
QObject
*
parent
=
NULL
);
AirspacePolygonRestriction
(
const
QVariantList
&
polygon
,
QObject
*
parent
=
nullptr
);
Q_PROPERTY
(
QVariantList
polygon
MEMBER
_polygon
CONSTANT
)
...
...
@@ -53,7 +53,7 @@ class AirspaceCircularRestriction : public AirspaceRestriction
{
Q_OBJECT
public:
AirspaceCircularRestriction
(
const
QGeoCoordinate
&
center
,
double
radius
,
QObject
*
parent
=
NULL
);
AirspaceCircularRestriction
(
const
QGeoCoordinate
&
center
,
double
radius
,
QObject
*
parent
=
nullptr
);
Q_PROPERTY
(
QGeoCoordinate
center
MEMBER
_center
CONSTANT
)
Q_PROPERTY
(
double
radius
MEMBER
_radius
CONSTANT
)
...
...
src/AirspaceManagement/AirspaceRestrictionProvider.h
View file @
9377ebb2
...
...
@@ -27,7 +27,7 @@ class AirspaceCircularRestriction;
class
AirspaceRestrictionProvider
:
public
QObject
{
Q_OBJECT
public:
AirspaceRestrictionProvider
(
QObject
*
parent
=
NULL
);
AirspaceRestrictionProvider
(
QObject
*
parent
=
nullptr
);
~
AirspaceRestrictionProvider
()
=
default
;
Q_PROPERTY
(
QmlObjectListModel
*
polygons
READ
polygons
CONSTANT
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment