diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index ac9ee5c42b2719db6b54a69773ee78fdef4fa5b5..3d8ebdc5f8d9c2ee9436b416fb7a109134dee161 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -564,6 +564,7 @@ HEADERS += \ src/QmlControls/RCChannelMonitorController.h \ src/QmlControls/ScreenToolsController.h \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \ + src/Settings/AirMapSettings.h \ src/Settings/AppSettings.h \ src/Settings/AutoConnectSettings.h \ src/Settings/BrandImageSettings.h \ @@ -591,7 +592,15 @@ HEADERS += \ src/AnalyzeView/LogDownloadController.h \ libs/thirdParty/tiny-AES128-C/aes.h \ -# Protobuf +# Protobuf (AirMap) +# This should be optional. As is, QGC now requires protobuf to be installed. +MacBuild { + INCLUDEPATH += \ + /usr/local/opt/protobuf/include + LIBS += \ + -L/usr/local/opt/protobuf/lib +} + LIBS += -lprotobuf PROTOS = src/protobuf/airmap_telemetry.proto include(src/protobuf/proto_compile.pri) @@ -759,6 +768,7 @@ SOURCES += \ src/QmlControls/RCChannelMonitorController.cc \ src/QmlControls/ScreenToolsController.cc \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \ + src/Settings/AirMapSettings.cc \ src/Settings/AppSettings.cc \ src/Settings/AutoConnectSettings.cc \ src/Settings/BrandImageSettings.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 5a743baf9caed70fc9b10fd98611dd23a4dd7f83..dff24a84f142bd802e51b17ab6740b7206f9423f 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -190,6 +190,7 @@ src/MissionManager/MavCmdInfoRover.json src/MissionManager/MavCmdInfoSub.json src/MissionManager/MavCmdInfoVTOL.json + src/Settings/AirMap.SettingsGroup.json src/Settings/App.SettingsGroup.json src/Settings/AutoConnect.SettingsGroup.json src/Settings/FlightMap.SettingsGroup.json diff --git a/src/MissionManager/AirMapManager.cc b/src/MissionManager/AirMapManager.cc index e43d1debe4d91f7b79e5be3e08ceb19302e3e95c..878e8f92197c39849edf1f10a790c049ab1c9526 100644 --- a/src/MissionManager/AirMapManager.cc +++ b/src/MissionManager/AirMapManager.cc @@ -13,6 +13,7 @@ #include "JsonHelper.h" #include "SettingsManager.h" #include "AppSettings.h" +#include "AirMapSettings.h" #include "QGCQGeoCoordinate.h" #include "QGCApplication.h" @@ -344,7 +345,7 @@ void AirspaceRestrictionManager::updateROI(const QGeoCoordinate& center, double void AirspaceRestrictionManager::_parseAirspaceJson(QJsonParseError parseError, QJsonDocument airspaceDoc) { - + Q_UNUSED(parseError); QJsonObject rootObject = airspaceDoc.object(); switch(_state) { @@ -637,7 +638,7 @@ void AirMapFlightManager::_sendBriefingRequest() void AirMapFlightManager::_parseJson(QJsonParseError parseError, QJsonDocument doc) { - + Q_UNUSED(parseError); QJsonObject rootObject = doc.object(); switch(_state) { @@ -899,7 +900,7 @@ void AirMapTelemetry::_handleGlobalPositionInt(const mavlink_message_t& message) uint8_t* key = (uint8_t*)_key.data(); uint8_t iv[16]; - for (int i = 0; i < sizeof(iv); ++i) { + for (size_t i = 0; i < sizeof(iv); ++i) { iv[i] = (uint8_t)(qrand() & 0xff); // TODO: should use a secure random source } @@ -967,8 +968,8 @@ void AirMapTelemetry::_handleGlobalPositionInt(const mavlink_message_t& message) void AirMapTelemetry::_parseJson(QJsonParseError parseError, QJsonDocument doc) { + Q_UNUSED(parseError); QJsonObject rootObject = doc.object(); - switch(_state) { case State::StartCommunication: { @@ -1189,18 +1190,12 @@ void AirMapManager::_vehicleArmedChanged(bool armed) } } - void AirMapManager::setToolbox(QGCToolbox* toolbox) { QGCTool::setToolbox(toolbox); - - _networkingData.airmapAPIKey = toolbox->settingsManager()->appSettings()->airMapKey()->rawValueString(); - - // TODO: set login credentials from config - QString clientID = ""; - QString userName = ""; - QString password = ""; - _networkingData.login.setCredentials(clientID, userName, password); + AirMapSettings* ap = toolbox->settingsManager()->airMapSettings(); + _networkingData.airmapAPIKey = ap->apiKey()->rawValueString(); + _networkingData.login.setCredentials(ap->clientID()->rawValueString(), ap->userName()->rawValueString(), ap->password()->rawValueString()); } void AirMapManager::setROI(QGeoCoordinate& center, double radiusMeters) diff --git a/src/Settings/AirMap.SettingsGroup.json b/src/Settings/AirMap.SettingsGroup.json new file mode 100644 index 0000000000000000000000000000000000000000..37d39bc74eecdfe1fce894b30de7671a4c6d8263 --- /dev/null +++ b/src/Settings/AirMap.SettingsGroup.json @@ -0,0 +1,38 @@ +[ +{ + "name": "apiKey", + "shortDescription": "AirMap API Key", + "type": "string", + "defaultValue": "" +}, +{ + "name": "clientID", + "shortDescription": "AirMap Client ID", + "type": "string", + "defaultValue": "" +}, +{ + "name": "userName", + "shortDescription": "AirMap User Name", + "type": "string", + "defaultValue": "" +}, +{ + "name": "password", + "shortDescription": "AirMap Password", + "type": "string", + "defaultValue": "" +}, +{ + "name": "sitaUavReg", + "shortDescription": "AirMap SITA UAV Registration", + "type": "string", + "defaultValue": "" +}, +{ + "name": "sitaUserReg", + "shortDescription": "AirMap SITA User Registration", + "type": "string", + "defaultValue": "" +} +] diff --git a/src/Settings/AirMapSettings.cc b/src/Settings/AirMapSettings.cc new file mode 100644 index 0000000000000000000000000000000000000000..8a49fbecdf230718a728ee7980a472589034a3a0 --- /dev/null +++ b/src/Settings/AirMapSettings.cc @@ -0,0 +1,34 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "AirMapSettings.h" +#include "QGCPalette.h" +#include "QGCApplication.h" + +#include +#include + +DECLARE_SETTINGGROUP(AirMap) +{ + INIT_SETTINGFACT(apiKey); + INIT_SETTINGFACT(clientID); + INIT_SETTINGFACT(userName); + INIT_SETTINGFACT(password); + INIT_SETTINGFACT(sitaUavReg); + INIT_SETTINGFACT(sitaUserReg); + QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); + qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "AirMapSettings", "Reference only"); +} + +DECLARE_SETTINGSFACT(AirMapSettings, apiKey) +DECLARE_SETTINGSFACT(AirMapSettings, clientID) +DECLARE_SETTINGSFACT(AirMapSettings, userName) +DECLARE_SETTINGSFACT(AirMapSettings, password) +DECLARE_SETTINGSFACT(AirMapSettings, sitaUavReg) +DECLARE_SETTINGSFACT(AirMapSettings, sitaUserReg) diff --git a/src/Settings/AirMapSettings.h b/src/Settings/AirMapSettings.h new file mode 100644 index 0000000000000000000000000000000000000000..9466d3d4fe2b3515eb44f6191a633800d517d01e --- /dev/null +++ b/src/Settings/AirMapSettings.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include "SettingsGroup.h" +#include "QGCMAVLink.h" + +class AirMapSettings : public SettingsGroup +{ + Q_OBJECT +public: + AirMapSettings(QObject* parent = NULL); + + DEFINE_SETTINGGROUP(AirMap) + + DEFINE_SETTINGFACT(apiKey) + DEFINE_SETTINGFACT(clientID) + DEFINE_SETTINGFACT(userName) + DEFINE_SETTINGFACT(password) + DEFINE_SETTINGFACT(sitaUavReg) + DEFINE_SETTINGFACT(sitaUserReg) + +}; diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 058b2d5963c1c778f643d67da1b16892b3acfa8e..5b9bd15c2219da680b21cb0f958944e8f6670df7 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -176,10 +176,5 @@ "shortDescription": "Default firmware type for flashing", "type": "uint32", "defaultValue": 12 -}, -{ - "name": "AirMapKey", - "type": "string", - "defaultValue": "" } ] diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index a7502969a4d292a3a1a3fadb40dc2422eac2ad0f..65068ef39ef40bd38d44838f2f86cffec647a62b 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -36,7 +36,6 @@ const char* AppSettings::autoLoadMissionsName = "AutoLoa const char* AppSettings::mapboxTokenName = "MapboxToken"; const char* AppSettings::esriTokenName = "EsriToken"; const char* AppSettings::defaultFirmwareTypeName = "DefaultFirmwareType"; -const char* AppSettings::airMapKeyName = "AirMapKey"; const char* AppSettings::parameterFileExtension = "params"; const char* AppSettings::planFileExtension = "plan"; @@ -76,7 +75,6 @@ AppSettings::AppSettings(QObject* parent) , _mapboxTokenFact(NULL) , _esriTokenFact(NULL) , _defaultFirmwareTypeFact(NULL) - , _airMapKeyFact(NULL) { QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); @@ -391,12 +389,3 @@ Fact* AppSettings::defaultFirmwareType(void) return _defaultFirmwareTypeFact; } -Fact* AppSettings::airMapKey(void) -{ - if (!_airMapKeyFact) { - _airMapKeyFact = _createSettingsFact(airMapKeyName); - } - - return _airMapKeyFact; -} - diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index 9cea8a7a22fa50cae7851228411f080ca60950b7..5305f6d78b5bc374cdedd28d3102b1d0a0e18294 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -40,7 +40,6 @@ public: Q_PROPERTY(Fact* mapboxToken READ mapboxToken CONSTANT) Q_PROPERTY(Fact* esriToken READ esriToken CONSTANT) Q_PROPERTY(Fact* defaultFirmwareType READ defaultFirmwareType CONSTANT) - Q_PROPERTY(Fact* airMapKey READ airMapKey CONSTANT) Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged) @@ -76,13 +75,12 @@ public: Fact* mapboxToken (void); Fact* esriToken (void); Fact* defaultFirmwareType (void); - Fact* airMapKey (void); QString missionSavePath (void); QString parameterSavePath (void); QString telemetrySavePath (void); QString logSavePath (void); - QString videoSavePath (void); + QString videoSavePath (void); static MAV_AUTOPILOT offlineEditingFirmwareTypeFromFirmwareType(MAV_AUTOPILOT firmwareType); static MAV_TYPE offlineEditingVehicleTypeFromVehicleType(MAV_TYPE vehicleType); @@ -109,7 +107,6 @@ public: static const char* mapboxTokenName; static const char* esriTokenName; static const char* defaultFirmwareTypeName; - static const char* airMapKeyName; // Application wide file extensions static const char* parameterFileExtension; @@ -157,7 +154,6 @@ private: SettingsFact* _mapboxTokenFact; SettingsFact* _esriTokenFact; SettingsFact* _defaultFirmwareTypeFact; - SettingsFact* _airMapKeyFact; }; #endif diff --git a/src/Settings/SettingsGroup.h b/src/Settings/SettingsGroup.h index 048c0b1132fdb721cb48c5f962ad505776f2c934..7f0bfce022a0d9155b9530a520ec593f761ad56e 100644 --- a/src/Settings/SettingsGroup.h +++ b/src/Settings/SettingsGroup.h @@ -17,6 +17,34 @@ #include +#define DEFINE_SETTINGGROUP(CLASS) \ + static const char* CLASS ## Settings ## GroupName; + +#define DECLARE_SETTINGGROUP(CLASS) \ + const char* CLASS ## Settings::CLASS ## Settings ## GroupName = #CLASS; \ + CLASS ## Settings::CLASS ## Settings(QObject* parent) \ + : SettingsGroup(CLASS ## Settings ## GroupName, QString() /* root settings group */, parent) + +#define DECLARE_SETTINGSFACT(CLASS, NAME) \ + const char* CLASS::NAME ## Name = #NAME; \ + Fact* CLASS::NAME(void) \ + { \ + if (!_ ## NAME ## Fact) { \ + _ ## NAME ## Fact = _createSettingsFact(NAME ## Name); \ + } \ + return _ ## NAME ## Fact; \ + } + +#define DEFINE_SETTINGFACT(NAME) \ + public: \ + Q_PROPERTY(Fact* NAME READ NAME CONSTANT) \ + Fact* NAME(); \ + static const char* NAME ## Name; \ + private: \ + SettingsFact* _ ## NAME ## Fact; + +#define INIT_SETTINGFACT(NAME) _ ## NAME ## Fact = NULL + /// Provides access to group of settings. The group is named and has a visible property associated with which can control whether the group /// is shows in the ui. class SettingsGroup : public QObject diff --git a/src/Settings/SettingsManager.cc b/src/Settings/SettingsManager.cc index 643bf234515342e8b52af8e66fbe829e8907723d..b7d6a127bb6b4129139d6a906fb73a63c3c72421 100644 --- a/src/Settings/SettingsManager.cc +++ b/src/Settings/SettingsManager.cc @@ -14,6 +14,7 @@ SettingsManager::SettingsManager(QGCApplication* app, QGCToolbox* toolbox) : QGCTool(app, toolbox) + , _airMapSettings (NULL) , _appSettings (NULL) , _unitsSettings (NULL) , _autoConnectSettings (NULL) @@ -40,4 +41,5 @@ void SettingsManager::setToolbox(QGCToolbox *toolbox) _rtkSettings = new RTKSettings(this); _guidedSettings = new GuidedSettings(this); _brandImageSettings = new BrandImageSettings(this); + _airMapSettings = new AirMapSettings(this); } diff --git a/src/Settings/SettingsManager.h b/src/Settings/SettingsManager.h index a69b7f6bc55fcb7eec112da77aeaa0d7322a6c59..bba1104e797b27294960d98488f696be7d8875b9 100644 --- a/src/Settings/SettingsManager.h +++ b/src/Settings/SettingsManager.h @@ -22,6 +22,7 @@ #include "RTKSettings.h" #include "GuidedSettings.h" #include "BrandImageSettings.h" +#include "AirMapSettings.h" #include @@ -33,6 +34,7 @@ class SettingsManager : public QGCTool public: SettingsManager(QGCApplication* app, QGCToolbox* toolbox); + Q_PROPERTY(QObject* airMapSettings READ airMapSettings CONSTANT) Q_PROPERTY(QObject* appSettings READ appSettings CONSTANT) Q_PROPERTY(QObject* unitsSettings READ unitsSettings CONSTANT) Q_PROPERTY(QObject* autoConnectSettings READ autoConnectSettings CONSTANT) @@ -45,6 +47,7 @@ public: // Override from QGCTool virtual void setToolbox(QGCToolbox *toolbox); + AirMapSettings* airMapSettings (void) { return _airMapSettings; } AppSettings* appSettings (void) { return _appSettings; } UnitsSettings* unitsSettings (void) { return _unitsSettings; } AutoConnectSettings* autoConnectSettings (void) { return _autoConnectSettings; } @@ -55,6 +58,7 @@ public: BrandImageSettings* brandImageSettings (void) { return _brandImageSettings; } private: + AirMapSettings* _airMapSettings; AppSettings* _appSettings; UnitsSettings* _unitsSettings; AutoConnectSettings* _autoConnectSettings; diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 3ebc22c63d98b2104f118a1e841325ced641a101..84e03a7a39a8f1ed39092abb5061403096e92da3 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -2921,6 +2921,7 @@ void Vehicle::_vehicleParamLoaded(bool ready) void Vehicle::_trafficUpdate(QString traffic_id, QString vehicle_id, QGeoCoordinate location, float heading) { + Q_UNUSED(vehicle_id); // qDebug() << "traffic update:" << traffic_id << vehicle_id << heading << location; // TODO: filter based on minimum altitude? // TODO: remove a vehicle after a timeout? diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index f0814250f79668b2ff2d2de84ecf4ff30be9e25a..9db781e4dbcb922dfa2aaf70ee73d40661afa2fd 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -388,11 +388,6 @@ QGCView { } } } - - // FIXME: Hack - FactTextField { - fact: QGroundControl.settingsManager.appSettings.airMapKey - } } } @@ -492,6 +487,62 @@ QGCView { } } + //----------------------------------------------------------------- + //-- AirMap + Item { + width: _qgcView.width * 0.8 + height: unitLabel.height + anchors.margins: ScreenTools.defaultFontPixelWidth + anchors.horizontalCenter: parent.horizontalCenter + visible: QGroundControl.settingsManager.rtkSettings.visible + QGCLabel { + text: qsTr("AirMap") + font.family: ScreenTools.demiboldFontFamily + } + } + Rectangle { + height: airMapCol.height + (ScreenTools.defaultFontPixelHeight * 2) + width: _qgcView.width * 0.8 + color: qgcPal.windowShade + anchors.margins: ScreenTools.defaultFontPixelWidth + anchors.horizontalCenter: parent.horizontalCenter + visible: QGroundControl.settingsManager.airMapSettings.visible + Column { + id: airMapCol + spacing: ScreenTools.defaultFontPixelWidth + anchors.centerIn: parent + Row { + spacing: ScreenTools.defaultFontPixelWidth + QGCLabel {text: qsTr("API Key:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter } + FactTextField {fact: QGroundControl.settingsManager.airMapSettings.apiKey; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter } + } + Row { + spacing: ScreenTools.defaultFontPixelWidth + QGCLabel {text: qsTr("Client ID:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter } + FactTextField {fact: QGroundControl.settingsManager.airMapSettings.clientID; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter } + } + Row { + spacing: ScreenTools.defaultFontPixelWidth + QGCLabel {text: qsTr("User Name:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter } + FactTextField {fact: QGroundControl.settingsManager.airMapSettings.userName; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter } + } + Row { + spacing: ScreenTools.defaultFontPixelWidth + QGCLabel {text: qsTr("Password:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter } + FactTextField {fact: QGroundControl.settingsManager.airMapSettings.password; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter; echoMode: TextInput.Password } + } + Row { + spacing: ScreenTools.defaultFontPixelWidth + QGCLabel {text: qsTr("SITA UAV Reg:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter } + FactTextField {fact: QGroundControl.settingsManager.airMapSettings.sitaUavReg; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter } + } + Row { + spacing: ScreenTools.defaultFontPixelWidth + QGCLabel {text: qsTr("SITA User Reg:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter } + FactTextField {fact: QGroundControl.settingsManager.airMapSettings.sitaUserReg; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter } + } + } + } //----------------------------------------------------------------- //-- Video Source Item {