guhconfiguration -> nymeaconfiguration

This commit is contained in:
Michael Zanetti 2018-01-30 10:23:27 +01:00
parent 559a8be1f6
commit da9fe61044
24 changed files with 117 additions and 114 deletions

View File

@ -220,14 +220,14 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent):
params.insert("enabled", JsonTypes::basicTypeToString(JsonTypes::Bool));
setParams("CloudConfigurationChanged", params);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::serverNameChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::timeZoneChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::localeChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::debugServerEnabledChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::tcpServerConfigurationChanged, this, &ConfigurationHandler::onTcpServerConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::webServerConfigurationChanged, this, &ConfigurationHandler::onWebServerConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::webSocketServerConfigurationChanged, this, &ConfigurationHandler::onWebSocketServerConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::cloudEnabledChanged, this, &ConfigurationHandler::onCloudConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::serverNameChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::timeZoneChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::localeChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::debugServerEnabledChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::tcpServerConfigurationChanged, this, &ConfigurationHandler::onTcpServerConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::webServerConfigurationChanged, this, &ConfigurationHandler::onWebServerConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::webSocketServerConfigurationChanged, this, &ConfigurationHandler::onWebSocketServerConfigurationChanged);
connect(NymeaCore::instance()->configuration(), &NymeaConfiguration::cloudEnabledChanged, this, &ConfigurationHandler::onCloudConfigurationChanged);
connect(NymeaCore::instance()->deviceManager(), &DeviceManager::languageUpdated, this, &ConfigurationHandler::onLanguageChanged);
}
@ -297,7 +297,7 @@ JsonReply *ConfigurationHandler::SetServerName(const QVariantMap &params) const
{
QString serverName = params.value("serverName").toString();
NymeaCore::instance()->configuration()->setServerName(serverName);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::SetTimeZone(const QVariantMap &params) const
@ -306,10 +306,10 @@ JsonReply *ConfigurationHandler::SetTimeZone(const QVariantMap &params) const
QByteArray timeZone = params.value("timeZone").toString().toUtf8();
if (!NymeaCore::instance()->timeManager()->setTimeZone(timeZone))
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidTimeZone));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidTimeZone));
NymeaCore::instance()->configuration()->setTimeZone(timeZone);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::SetLanguage(const QVariantMap &params) const
@ -319,37 +319,37 @@ JsonReply *ConfigurationHandler::SetLanguage(const QVariantMap &params) const
NymeaCore::instance()->configuration()->setLocale(locale);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::SetTcpServerConfiguration(const QVariantMap &params) const
{
ServerConfiguration config = JsonTypes::unpackServerConfiguration(params.value("configuration").toMap());
if (config.id.isEmpty()) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidId));
}
if (config.address.isNull())
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidHostAddress));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidHostAddress));
if (config.port <= 0 || config.port > 65535) {
qCWarning(dcJsonRpc()) << "Port out of range";
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidPort));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidPort));
}
qCDebug(dcJsonRpc()) << QString("Configure TCP server %1:%2").arg(config.address.toString()).arg(config.port);
NymeaCore::instance()->configuration()->setTcpServerConfiguration(config);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::DeleteTcpServerConfiguration(const QVariantMap &params) const
{
QString id = params.value("id").toString();
if (id.isEmpty() || !NymeaCore::instance()->configuration()->tcpServerConfigurations().contains(id)) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidId));
}
NymeaCore::instance()->configuration()->removeTcpServerConfiguration(id);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::SetWebServerConfiguration(const QVariantMap &params) const
@ -357,75 +357,75 @@ JsonReply *ConfigurationHandler::SetWebServerConfiguration(const QVariantMap &pa
WebServerConfiguration config = JsonTypes::unpackWebServerConfiguration(params.value("configuration").toMap());
if (config.id.isEmpty()) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidId));
}
if (config.address.isNull())
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidHostAddress));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidHostAddress));
if (config.port <= 0 || config.port > 65535) {
qCWarning(dcJsonRpc()) << "Port out of range";
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidPort));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidPort));
}
qCDebug(dcJsonRpc()) << QString("Configure web server %1:%2").arg(config.address.toString()).arg(config.port);
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::DeleteWebServerConfiguration(const QVariantMap &params) const
{
QString id = params.value("id").toString();
if (id.isEmpty() || !NymeaCore::instance()->configuration()->webServerConfigurations().contains(id)) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidId));
}
NymeaCore::instance()->configuration()->removeWebServerConfiguration(id);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::SetWebSocketServerConfiguration(const QVariantMap &params) const
{
ServerConfiguration config = JsonTypes::unpackServerConfiguration(params.value("configuration").toMap());
if (config.id.isEmpty()) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidId));
}
if (config.address.isNull())
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidHostAddress));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidHostAddress));
if (config.port <= 0 || config.port > 65535) {
qCWarning(dcJsonRpc()) << "Port out of range";
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidPort));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidPort));
}
qCDebug(dcJsonRpc()) << QString("Configure web socket server %1:%2").arg(config.address.toString()).arg(config.port);
NymeaCore::instance()->configuration()->setWebSocketServerConfiguration(config);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::DeleteWebSocketServerConfiguration(const QVariantMap &params) const
{
QString id = params.value("id").toString();
if (id.isEmpty() || !NymeaCore::instance()->configuration()->webSocketServerConfigurations().contains(id)) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorInvalidId));
}
NymeaCore::instance()->configuration()->removeWebSocketServerConfiguration(id);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::SetCloudEnabled(const QVariantMap &params) const
{
bool enabled = params.value("enabled").toBool();
NymeaCore::instance()->configuration()->setCloudEnabled(enabled);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
JsonReply *ConfigurationHandler::SetDebugServerEnabled(const QVariantMap &params) const
{
bool enabled = params.value("enabled").toBool();
NymeaCore::instance()->configuration()->setDebugServerEnabled(enabled);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
return createReply(statusToReply(NymeaConfiguration::ConfigurationErrorNoError));
}
void ConfigurationHandler::onBasicConfigurationChanged()

View File

@ -205,7 +205,7 @@ QVariantMap JsonHandler::statusToReply(Logging::LoggingError status) const
}
/*! Returns the formated error map for the given \a status. */
QVariantMap JsonHandler::statusToReply(GuhConfiguration::ConfigurationError status) const
QVariantMap JsonHandler::statusToReply(NymeaConfiguration::ConfigurationError status) const
{
QVariantMap returns;
returns.insert("configurationError", JsonTypes::configurationErrorToString(status));

View File

@ -111,7 +111,7 @@ protected:
QVariantMap statusToReply(DeviceManager::DeviceError status) const;
QVariantMap statusToReply(RuleEngine::RuleError status) const;
QVariantMap statusToReply(Logging::LoggingError status) const;
QVariantMap statusToReply(GuhConfiguration::ConfigurationError status) const;
QVariantMap statusToReply(NymeaConfiguration::ConfigurationError status) const;
QVariantMap statusToReply(NetworkManager::NetworkManagerError status) const;
private:

View File

@ -143,7 +143,7 @@ void JsonTypes::init()
s_loggingLevel = enumToStrings(Logging::staticMetaObject, "LoggingLevel");
s_loggingEventType = enumToStrings(Logging::staticMetaObject, "LoggingEventType");
s_repeatingMode = enumToStrings(RepeatingOption::staticMetaObject, "RepeatingMode");
s_configurationError = enumToStrings(GuhConfiguration::staticMetaObject, "ConfigurationError");
s_configurationError = enumToStrings(NymeaConfiguration::staticMetaObject, "ConfigurationError");
s_networkManagerError = enumToStrings(NetworkManager::staticMetaObject, "NetworkManagerError");
s_networkManagerState = enumToStrings(NetworkManager::staticMetaObject, "NetworkManagerState");
s_networkDeviceState = enumToStrings(NetworkDevice::staticMetaObject, "NetworkDeviceState");

View File

@ -27,7 +27,7 @@
#include "rule.h"
#include "devicemanager.h"
#include "ruleengine.h"
#include "guhconfiguration.h"
#include "nymeaconfiguration.h"
#include "usermanager.h"
#include "types/deviceclass.h"
@ -130,7 +130,7 @@ public:
DECLARE_TYPE(loggingLevel, "LoggingLevel", Logging, LoggingLevel)
DECLARE_TYPE(loggingEventType, "LoggingEventType", Logging, LoggingEventType)
DECLARE_TYPE(repeatingMode, "RepeatingMode", RepeatingOption, RepeatingMode)
DECLARE_TYPE(configurationError, "ConfigurationError", GuhConfiguration, ConfigurationError)
DECLARE_TYPE(configurationError, "ConfigurationError", NymeaConfiguration, ConfigurationError)
DECLARE_TYPE(networkManagerError, "NetworkManagerError", NetworkManager, NetworkManagerError)
DECLARE_TYPE(networkManagerState, "NetworkManagerState", NetworkManager, NetworkManagerState)
DECLARE_TYPE(networkDeviceState, "NetworkDeviceState", NetworkDevice, NetworkDeviceState)

View File

@ -27,7 +27,7 @@ HEADERS += nymeacore.h \
httprequest.h \
websocketserver.h \
httpreply.h \
guhconfiguration.h \
nymeaconfiguration.h \
bluetoothserver.h \
jsonrpc/jsonrpcserver.h \
jsonrpc/jsonhandler.h \
@ -108,7 +108,7 @@ SOURCES += nymeacore.cpp \
httprequest.cpp \
websocketserver.cpp \
httpreply.cpp \
guhconfiguration.cpp \
nymeaconfiguration.cpp \
bluetoothserver.cpp \
jsonrpc/jsonrpcserver.cpp \
jsonrpc/jsonhandler.cpp \

View File

@ -140,7 +140,7 @@ LogEngine::LogEngine(const QString &logPath, QObject *parent):
m_dbMaxSize = 50000;
m_overflow = 100;
if (QCoreApplication::instance()->organizationName() == "guh-test") {
if (QCoreApplication::instance()->organizationName() == "nymea-test") {
m_dbMaxSize = 20;
qCDebug(dcLogEngine) << "Set logging dab max size to" << m_dbMaxSize << "for testing.";
}

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "loggingcategories.h"
#include "guhconfiguration.h"
#include "nymeaconfiguration.h"
#include "nymeasettings.h"
#include <QTimeZone>
@ -28,7 +28,7 @@
namespace guhserver {
GuhConfiguration::GuhConfiguration(QObject *parent) :
NymeaConfiguration::NymeaConfiguration(QObject *parent) :
QObject(parent)
{
// Init server uuid if we don't have one.
@ -158,21 +158,21 @@ GuhConfiguration::GuhConfiguration(QObject *parent) :
}
}
QUuid GuhConfiguration::serverUuid() const
QUuid NymeaConfiguration::serverUuid() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("nymead");
return settings.value("uuid", QUuid()).toUuid();
}
QString GuhConfiguration::serverName() const
QString NymeaConfiguration::serverName() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("nymead");
return settings.value("name", "guhIO").toString();
}
void GuhConfiguration::setServerName(const QString &serverName)
void NymeaConfiguration::setServerName(const QString &serverName)
{
qCDebug(dcApplication()) << "Configuration: Server name:" << serverName;
@ -188,14 +188,14 @@ void GuhConfiguration::setServerName(const QString &serverName)
}
}
QByteArray GuhConfiguration::timeZone() const
QByteArray NymeaConfiguration::timeZone() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("nymead");
return settings.value("timeZone", QTimeZone::systemTimeZoneId()).toByteArray();
}
void GuhConfiguration::setTimeZone(const QByteArray &timeZone)
void NymeaConfiguration::setTimeZone(const QByteArray &timeZone)
{
qCDebug(dcApplication()) << "Configuration: Time zone:" << QString::fromUtf8(timeZone);
@ -211,14 +211,14 @@ void GuhConfiguration::setTimeZone(const QByteArray &timeZone)
}
}
QLocale GuhConfiguration::locale() const
QLocale NymeaConfiguration::locale() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("nymead");
return settings.value("language", "en_US").toString();
}
void GuhConfiguration::setLocale(const QLocale &locale)
void NymeaConfiguration::setLocale(const QLocale &locale)
{
qCDebug(dcApplication()) << "Configuration: set locale:" << locale.name() << locale.nativeCountryName() << locale.nativeLanguageName();
@ -234,31 +234,31 @@ void GuhConfiguration::setLocale(const QLocale &locale)
}
}
QHash<QString, ServerConfiguration> GuhConfiguration::tcpServerConfigurations() const
QHash<QString, ServerConfiguration> NymeaConfiguration::tcpServerConfigurations() const
{
return m_tcpServerConfigs;
}
void GuhConfiguration::setTcpServerConfiguration(const ServerConfiguration &config)
void NymeaConfiguration::setTcpServerConfiguration(const ServerConfiguration &config)
{
m_tcpServerConfigs[config.id] = config;
storeServerConfig("TcpServer", config);
emit tcpServerConfigurationChanged(config.id);
}
void GuhConfiguration::removeTcpServerConfiguration(const QString &id)
void NymeaConfiguration::removeTcpServerConfiguration(const QString &id)
{
m_tcpServerConfigs.take(id);
deleteServerConfig("TcpServer", id);
emit tcpServerConfigurationRemoved(id);
}
QHash<QString, WebServerConfiguration> GuhConfiguration::webServerConfigurations() const
QHash<QString, WebServerConfiguration> NymeaConfiguration::webServerConfigurations() const
{
return m_webServerConfigs;
}
void GuhConfiguration::setWebServerConfiguration(const WebServerConfiguration &config)
void NymeaConfiguration::setWebServerConfiguration(const WebServerConfiguration &config)
{
m_webServerConfigs[config.id] = config;
@ -275,40 +275,40 @@ void GuhConfiguration::setWebServerConfiguration(const WebServerConfiguration &c
emit webServerConfigurationChanged(config.id);
}
void GuhConfiguration::removeWebServerConfiguration(const QString &id)
void NymeaConfiguration::removeWebServerConfiguration(const QString &id)
{
m_webServerConfigs.take(id);
deleteServerConfig("WebServer", id);
emit webServerConfigurationRemoved(id);
}
QHash<QString, ServerConfiguration> GuhConfiguration::webSocketServerConfigurations() const
QHash<QString, ServerConfiguration> NymeaConfiguration::webSocketServerConfigurations() const
{
return m_webSocketServerConfigs;
}
void GuhConfiguration::setWebSocketServerConfiguration(const ServerConfiguration &config)
void NymeaConfiguration::setWebSocketServerConfiguration(const ServerConfiguration &config)
{
m_webSocketServerConfigs[config.id] = config;
storeServerConfig("WebSocketServer", config);
emit webSocketServerConfigurationChanged(config.id);
}
void GuhConfiguration::removeWebSocketServerConfiguration(const QString &id)
void NymeaConfiguration::removeWebSocketServerConfiguration(const QString &id)
{
m_webSocketServerConfigs.take(id);
deleteServerConfig("WebSocketServer", id);
emit webSocketServerConfigurationRemoved(id);
}
bool GuhConfiguration::bluetoothServerEnabled() const
bool NymeaConfiguration::bluetoothServerEnabled() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("BluetoothServer");
return settings.value("enabled", false).toBool();
}
void GuhConfiguration::setBluetoothServerEnabled(const bool &enabled)
void NymeaConfiguration::setBluetoothServerEnabled(const bool &enabled)
{
qCDebug(dcApplication()) << "Configuration: Bluetooth server" << (enabled ? "enabled" : "disabled");
@ -319,14 +319,14 @@ void GuhConfiguration::setBluetoothServerEnabled(const bool &enabled)
emit bluetoothServerEnabled();
}
bool GuhConfiguration::cloudEnabled() const
bool NymeaConfiguration::cloudEnabled() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("Cloud");
return settings.value("enabled", false).toBool();
}
void GuhConfiguration::setCloudEnabled(bool enabled)
void NymeaConfiguration::setCloudEnabled(bool enabled)
{
if (cloudEnabled() != enabled) {
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
@ -337,49 +337,49 @@ void GuhConfiguration::setCloudEnabled(bool enabled)
}
}
QString GuhConfiguration::cloudServerUrl() const
QString NymeaConfiguration::cloudServerUrl() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("Cloud");
return settings.value("cloudServerUrl").toString();
}
QString GuhConfiguration::cloudCertificateCA() const
QString NymeaConfiguration::cloudCertificateCA() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("Cloud");
return settings.value("cloudCertificateCA").toString();
}
QString GuhConfiguration::cloudCertificate() const
QString NymeaConfiguration::cloudCertificate() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("Cloud");
return settings.value("cloudCertificate").toString();
}
QString GuhConfiguration::cloudCertificateKey() const
QString NymeaConfiguration::cloudCertificateKey() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("Cloud");
return settings.value("cloudCertificateKey").toString();
}
QString GuhConfiguration::sslCertificate() const
QString NymeaConfiguration::sslCertificate() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("SSL");
return settings.value("certificate").toString();
}
QString GuhConfiguration::sslCertificateKey() const
QString NymeaConfiguration::sslCertificateKey() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("SSL");
return settings.value("certificate-key").toString();
}
void GuhConfiguration::setSslCertificate(const QString &sslCertificate, const QString &sslCertificateKey)
void NymeaConfiguration::setSslCertificate(const QString &sslCertificate, const QString &sslCertificateKey)
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("SSL");
@ -388,14 +388,14 @@ void GuhConfiguration::setSslCertificate(const QString &sslCertificate, const QS
settings.endGroup();
}
bool GuhConfiguration::debugServerEnabled() const
bool NymeaConfiguration::debugServerEnabled() const
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup("nymead");
return settings.value("debugServerEnabled", false).toBool();
}
void GuhConfiguration::setDebugServerEnabled(bool enabled)
void NymeaConfiguration::setDebugServerEnabled(bool enabled)
{
qCDebug(dcApplication()) << "Configuration: Set debug server" << (enabled ? "enabled" : "disabled");
bool currentValue = debugServerEnabled();
@ -409,7 +409,7 @@ void GuhConfiguration::setDebugServerEnabled(bool enabled)
}
}
void GuhConfiguration::setServerUuid(const QUuid &uuid)
void NymeaConfiguration::setServerUuid(const QUuid &uuid)
{
qCDebug(dcApplication()) << "Configuration: Server uuid:" << uuid.toString();
@ -419,19 +419,19 @@ void GuhConfiguration::setServerUuid(const QUuid &uuid)
settings.endGroup();
}
QString GuhConfiguration::defaultWebserverPublicFolderPath() const
QString NymeaConfiguration::defaultWebserverPublicFolderPath() const
{
QString publicFolderPath;
if (!qgetenv("SNAP").isEmpty()) {
// FIXME: one could point to sensible data by changing the SNAP env to i.e /etc
publicFolderPath = QString(qgetenv("SNAP")) + "/guh-webinterface";
publicFolderPath = QString(qgetenv("SNAP")) + "/nymea-webinterface";
} else {
publicFolderPath = "/usr/share/guh-webinterface/public/";
publicFolderPath = "/usr/share/nymea-webinterface/public/";
}
return publicFolderPath;
}
void GuhConfiguration::storeServerConfig(const QString &group, const ServerConfiguration &config)
void NymeaConfiguration::storeServerConfig(const QString &group, const ServerConfiguration &config)
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup(group);
@ -445,7 +445,7 @@ void GuhConfiguration::storeServerConfig(const QString &group, const ServerConfi
settings.endGroup();
}
ServerConfiguration GuhConfiguration::readServerConfig(const QString &group, const QString &id)
ServerConfiguration NymeaConfiguration::readServerConfig(const QString &group, const QString &id)
{
ServerConfiguration config;
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
@ -461,7 +461,7 @@ ServerConfiguration GuhConfiguration::readServerConfig(const QString &group, con
return config;
}
void GuhConfiguration::deleteServerConfig(const QString &group, const QString &id)
void NymeaConfiguration::deleteServerConfig(const QString &group, const QString &id)
{
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
settings.beginGroup(group);
@ -472,7 +472,7 @@ void GuhConfiguration::deleteServerConfig(const QString &group, const QString &i
settings.endGroup();
}
void GuhConfiguration::storeWebServerConfig(const WebServerConfiguration &config)
void NymeaConfiguration::storeWebServerConfig(const WebServerConfiguration &config)
{
storeServerConfig("WebServer", config);
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
@ -483,7 +483,7 @@ void GuhConfiguration::storeWebServerConfig(const WebServerConfiguration &config
settings.endGroup();
}
WebServerConfiguration GuhConfiguration::readWebServerConfig(const QString &id)
WebServerConfiguration NymeaConfiguration::readWebServerConfig(const QString &id)
{
WebServerConfiguration config;
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);

View File

@ -18,8 +18,8 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef GUHCONFIGURATION_H
#define GUHCONFIGURATION_H
#ifndef NYMEACONFIGURATION_H
#define NYMEACONFIGURATION_H
#include <QHostAddress>
#include <QObject>
@ -55,7 +55,7 @@ public:
QString publicFolder;
};
class GuhConfiguration : public QObject
class NymeaConfiguration : public QObject
{
Q_OBJECT
Q_ENUMS(ConfigurationError)
@ -72,7 +72,7 @@ public:
ConfigurationErrorInvalidCertificate
};
explicit GuhConfiguration(QObject *parent = 0);
explicit NymeaConfiguration(QObject *parent = 0);
// Global settings
QUuid serverUuid() const;
@ -157,4 +157,4 @@ signals:
}
#endif // GUHCONFIGURATION_H
#endif // NYMEACONFIGURATION_H

View File

@ -403,8 +403,8 @@ RuleEngine::RuleError NymeaCore::removeRule(const RuleId &id)
return removeError;
}
/*! Returns a pointer to the \l{GuhConfiguration} instance owned by NymeaCore.*/
GuhConfiguration *NymeaCore::configuration() const
/*! Returns a pointer to the \l{NymeaConfiguration} instance owned by NymeaCore.*/
NymeaConfiguration *NymeaCore::configuration() const
{
return m_configuration;
}
@ -477,8 +477,8 @@ NymeaCore::NymeaCore(QObject *parent) :
}
void NymeaCore::init() {
qCDebug(dcApplication()) << "Loading guh configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName();
m_configuration = new GuhConfiguration(this);
qCDebug(dcApplication()) << "Loading nymea configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName();
m_configuration = new NymeaConfiguration(this);
qCDebug(dcApplication()) << "Creating Time Manager";
m_timeManager = new TimeManager(QTimeZone::systemTimeZoneId(), this);
@ -518,10 +518,10 @@ void NymeaCore::init() {
CloudNotifications *cloudNotifications = m_cloudManager->createNotificationsPlugin();
m_deviceManager->registerStaticPlugin(cloudNotifications, cloudNotifications->metaData());
connect(m_configuration, &GuhConfiguration::localeChanged, this, &NymeaCore::onLocaleChanged);
connect(m_configuration, &GuhConfiguration::cloudEnabledChanged, m_cloudManager, &CloudManager::setEnabled);
connect(m_configuration, &GuhConfiguration::serverNameChanged, m_cloudManager, &CloudManager::setDeviceName);
connect(m_configuration, &GuhConfiguration::serverNameChanged, m_serverManager, &ServerManager::setServerName);
connect(m_configuration, &NymeaConfiguration::localeChanged, this, &NymeaCore::onLocaleChanged);
connect(m_configuration, &NymeaConfiguration::cloudEnabledChanged, m_cloudManager, &CloudManager::setEnabled);
connect(m_configuration, &NymeaConfiguration::serverNameChanged, m_cloudManager, &CloudManager::setDeviceName);
connect(m_configuration, &NymeaConfiguration::serverNameChanged, m_serverManager, &ServerManager::setServerName);
connect(m_deviceManager, &DeviceManager::pluginConfigChanged, this, &NymeaCore::pluginConfigChanged);
connect(m_deviceManager, &DeviceManager::eventTriggered, this, &NymeaCore::gotEvent);

View File

@ -29,7 +29,6 @@
#include "plugin/devicedescriptor.h"
#include "logging/logengine.h"
#include "guhconfiguration.h"
#include "devicemanager.h"
#include "ruleengine.h"
#include "servermanager.h"
@ -49,6 +48,7 @@ namespace guhserver {
class JsonRPCServer;
class LogEngine;
class NetworkManager;
class NymeaConfiguration;
class NymeaCore : public QObject
{
@ -71,6 +71,7 @@ public:
RuleEngine::RuleError removeRule(const RuleId &id);
NymeaConfiguration *configuration() const;
LogEngine* logEngine() const;
JsonRPCServer *jsonRPCServer() const;
RestServer *restServer() const;
@ -111,6 +112,7 @@ private:
explicit NymeaCore(QObject *parent = 0);
static NymeaCore *s_instance;
NymeaConfiguration *m_configuration;
ServerManager *m_serverManager;
DeviceManager *m_deviceManager;
RuleEngine *m_ruleEngine;

View File

@ -44,7 +44,7 @@
namespace guhserver {
/*! Constructs a \l{ServerManager} with the given \a parent. */
ServerManager::ServerManager(GuhConfiguration* configuration, QObject *parent) :
ServerManager::ServerManager(NymeaConfiguration *configuration, QObject *parent) :
QObject(parent),
m_sslConfiguration(QSslConfiguration())
{
@ -123,12 +123,12 @@ ServerManager::ServerManager(GuhConfiguration* configuration, QObject *parent) :
m_webServers.insert(config.id, webServer);
}
connect(configuration, &GuhConfiguration::tcpServerConfigurationChanged, this, &ServerManager::tcpServerConfigurationChanged);
connect(configuration, &GuhConfiguration::tcpServerConfigurationRemoved, this, &ServerManager::tcpServerConfigurationRemoved);
connect(configuration, &GuhConfiguration::webSocketServerConfigurationChanged, this, &ServerManager::webSocketServerConfigurationChanged);
connect(configuration, &GuhConfiguration::webSocketServerConfigurationRemoved, this, &ServerManager::webSocketServerConfigurationRemoved);
connect(configuration, &GuhConfiguration::webServerConfigurationChanged, this, &ServerManager::webServerConfigurationChanged);
connect(configuration, &GuhConfiguration::webServerConfigurationRemoved, this, &ServerManager::webServerConfigurationRemoved);
connect(configuration, &NymeaConfiguration::tcpServerConfigurationChanged, this, &ServerManager::tcpServerConfigurationChanged);
connect(configuration, &NymeaConfiguration::tcpServerConfigurationRemoved, this, &ServerManager::tcpServerConfigurationRemoved);
connect(configuration, &NymeaConfiguration::webSocketServerConfigurationChanged, this, &ServerManager::webSocketServerConfigurationChanged);
connect(configuration, &NymeaConfiguration::webSocketServerConfigurationRemoved, this, &ServerManager::webSocketServerConfigurationRemoved);
connect(configuration, &NymeaConfiguration::webServerConfigurationChanged, this, &ServerManager::webServerConfigurationChanged);
connect(configuration, &NymeaConfiguration::webServerConfigurationRemoved, this, &ServerManager::webServerConfigurationRemoved);
}
/*! Returns the pointer to the created \l{JsonRPCServer} in this \l{ServerManager}. */

View File

@ -41,7 +41,7 @@ class ServerManager : public QObject
{
Q_OBJECT
public:
explicit ServerManager(GuhConfiguration *configuration, QObject *parent = 0);
explicit ServerManager(NymeaConfiguration *configuration, QObject *parent = 0);
// Interfaces
JsonRPCServer *jsonServer() const;

View File

@ -26,7 +26,7 @@
#include <QList>
#include <QUuid>
#include "guhconfiguration.h"
#include "nymeaconfiguration.h"
namespace guhserver {

View File

@ -104,7 +104,7 @@ WebServer::WebServer(const WebServerConfiguration &configuration, const QSslConf
m_sslConfiguration(sslConfiguration),
m_enabled(false)
{
if (QCoreApplication::instance()->organizationName() == "guh-test") {
if (QCoreApplication::instance()->organizationName() == "nymea-test") {
m_configuration.publicFolder = QCoreApplication::applicationDirPath();
qCWarning(dcWebServer) << "Using public folder" << QDir(m_configuration.publicFolder).canonicalPath();
}

View File

@ -34,9 +34,9 @@
#include <QSslConfiguration>
#include <QSslKey>
#include "hardware/network/avahi/qtavahiservice.h"
#include "nymeaconfiguration.h"
#include "guhconfiguration.h"
#include "hardware/network/avahi/qtavahiservice.h"
// Note: Hypertext Transfer Protocol (HTTP/1.1) from the Internet Engineering Task Force (IETF):
// https://tools.ietf.org/html/rfc7231

View File

@ -39,10 +39,10 @@
The URL for the secure websocket (TLS 1.2):
\code wss://localhost:4444\endcode
You can turn on the \tt wss server in the \tt WebServerServer section of the \tt /etc/guh/nymead.conf file.
You can turn on the \tt wss server in the \tt WebServerServer section of the \tt /etc/nymea/nymead.conf file.
\note For \tt wss you need to have a certificate and configure it in the \tt SSL-configuration
section of the \tt /etc/guh/nymead.conf file.
section of the \tt /etc/nymea/nymead.conf file.
\sa WebServer, TcpServer, TransportInterface
*/

View File

@ -48,7 +48,7 @@ namespace guhserver {
GuhService::GuhService(int argc, char **argv):
QtService<QCoreApplication>(argc, argv, "nymea - IoT server")
{
application()->setOrganizationName("guh");
application()->setOrganizationName("nymea");
application()->setApplicationName("nymead");
application()->setApplicationVersion(NYMEA_VERSION_STRING);
close(STDIN_FILENO);

View File

@ -104,7 +104,7 @@ int main(int argc, char *argv[])
qInstallMessageHandler(consoleLogHandler);
GuhApplication application(argc, argv);
application.setOrganizationName("guh");
application.setOrganizationName("nymea");
application.setApplicationName("nymead");
application.setApplicationVersion(NYMEA_VERSION_STRING);

View File

@ -129,7 +129,7 @@ void TestConfigurations::testTimeZones()
params.clear(); response.clear(); configurations.clear();
params.insert("timeZone", "Moon/Darkside");
response = injectAndWait("Configuration.SetTimeZone", params);
verifyConfigurationError(response, GuhConfiguration::ConfigurationErrorInvalidTimeZone);
verifyConfigurationError(response, NymeaConfiguration::ConfigurationErrorInvalidTimeZone);
// Set new timezone
params.clear(); response.clear(); configurations.clear();

View File

@ -121,7 +121,7 @@ GuhTestBase::GuhTestBase(QObject *parent) :
m_mockDevice2Port = 7331 + (qrand() % 1000);
// Important for settings
QCoreApplication::instance()->setOrganizationName("guh-test");
QCoreApplication::instance()->setOrganizationName("nymea-test");
}
void GuhTestBase::initTestCase()

View File

@ -150,7 +150,7 @@ protected:
verifyError(response, "loggingError", JsonTypes::loggingErrorToString(error));
}
inline void verifyConfigurationError(const QVariant &response, GuhConfiguration::ConfigurationError error = GuhConfiguration::ConfigurationErrorNoError) {
inline void verifyConfigurationError(const QVariant &response, NymeaConfiguration::ConfigurationError error = NymeaConfiguration::ConfigurationErrorNoError) {
verifyError(response, "configurationError", JsonTypes::configurationErrorToString(error));
}

View File

@ -42,6 +42,7 @@ TestLoggingDirect::TestLoggingDirect(QObject *parent): QObject(parent)
{
// Setting timeout to 20 mins
qputenv("QTEST_FUNCTION_TIMEOUT", "1200000");
QCoreApplication::instance()->setOrganizationName("nymea-test");
}
void TestLoggingDirect::benchmarkDB_data() {

View File

@ -52,7 +52,7 @@ TestLoggingLoading::TestLoggingLoading(QObject *parent): QObject(parent)
void TestLoggingLoading::initTestCase()
{
// Important for settings
QCoreApplication::instance()->setOrganizationName("guh-test");
QCoreApplication::instance()->setOrganizationName("nymea-test");
}
void TestLoggingLoading::testLogMigration()