diff --git a/data/config/guhd.conf b/data/config/guhd.conf index 39f20628..5c28b241 100644 --- a/data/config/guhd.conf +++ b/data/config/guhd.conf @@ -6,7 +6,7 @@ ip="IPv4", "IPv6" [WebServer] port=3333 https=false -publicFolder=/usr/share/guh-webinterface/public +publicFolder=/usr/share/nymea-webinterface/public [WebSocketServer] https=false diff --git a/libnymea-core/awsconnector.cpp b/libnymea-core/awsconnector.cpp index dbe7eb2b..56de011d 100644 --- a/libnymea-core/awsconnector.cpp +++ b/libnymea-core/awsconnector.cpp @@ -20,7 +20,7 @@ #include "awsconnector.h" #include "loggingcategories.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include #include @@ -505,24 +505,24 @@ ResponseCode AWSConnector::onDisconnectedCallback(util::String mqtt_client_id, s void AWSConnector::storeRegisteredFlag(bool registered) { - QSettings settings(GuhSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); + QSettings settings(NymeaSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); settings.setValue("registered", registered); } bool AWSConnector::readRegisteredFlag() const { - QSettings settings(GuhSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); + QSettings settings(NymeaSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); return settings.value("registered", false).toBool(); } void AWSConnector::storeSyncedNameCache(const QString &syncedName) { - QSettings settings(GuhSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); + QSettings settings(NymeaSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); settings.setValue("syncedName", syncedName); } QString AWSConnector::readSyncedNameCache() { - QSettings settings(GuhSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); + QSettings settings(NymeaSettings::storagePath() + "/cloudstatus.conf", QSettings::IniFormat); return settings.value("syncedName", QString()).toString(); } diff --git a/libnymea-core/debugserverhandler.cpp b/libnymea-core/debugserverhandler.cpp index 2649e14b..0679931c 100644 --- a/libnymea-core/debugserverhandler.cpp +++ b/libnymea-core/debugserverhandler.cpp @@ -20,7 +20,7 @@ #include "guhcore.h" #include "httpreply.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "httprequest.h" #include "loggingcategories.h" #include "debugserverhandler.h" @@ -219,19 +219,19 @@ QByteArray DebugServerHandler::createDebugXmlDocument() writer.writeStartElement("tr"); //: The settings path description in the server infromation section of the debug interface writer.writeTextElement("th", QCoreApplication::translate("main", "Settings path")); - writer.writeTextElement("td", GuhSettings::settingsPath()); + writer.writeTextElement("td", NymeaSettings::settingsPath()); writer.writeEndElement(); // tr writer.writeStartElement("tr"); //: The translation path description in the server infromation section of the debug interface writer.writeTextElement("th", QCoreApplication::translate("main", "Translations path")); - writer.writeTextElement("td", GuhSettings(GuhSettings::SettingsRoleGlobal).translationsPath()); + writer.writeTextElement("td", NymeaSettings(NymeaSettings::SettingsRoleGlobal).translationsPath()); writer.writeEndElement(); // tr writer.writeStartElement("tr"); //: The log database path description in the server infromation section of the debug interface writer.writeTextElement("th", QCoreApplication::translate("main", "Log database")); - writer.writeTextElement("td", GuhSettings(GuhSettings::SettingsRoleGlobal).logPath()); + writer.writeTextElement("td", NymeaSettings(NymeaSettings::SettingsRoleGlobal).logPath()); writer.writeEndElement(); // tr for (int i = 0; i < GuhCore::instance()->deviceManager()->pluginSearchDirs().count(); i++) { @@ -273,7 +273,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument() writer.writeStartElement("div"); writer.writeAttribute("class", "download-path-column"); - writer.writeTextElement("p", GuhSettings::logPath()); + writer.writeTextElement("p", NymeaSettings::logPath()); writer.writeEndElement(); // div download-path-column writer.writeStartElement("div"); @@ -344,7 +344,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument() writer.writeStartElement("div"); writer.writeAttribute("class", "download-path-column"); - writer.writeTextElement("p", GuhSettings(GuhSettings::SettingsRoleGlobal).fileName()); + writer.writeTextElement("p", NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName()); writer.writeEndElement(); // div download-path-column writer.writeStartElement("div"); @@ -376,7 +376,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument() writer.writeStartElement("div"); writer.writeAttribute("class", "download-path-column"); - writer.writeTextElement("p", GuhSettings(GuhSettings::SettingsRoleDevices).fileName()); + writer.writeTextElement("p", NymeaSettings(NymeaSettings::SettingsRoleDevices).fileName()); writer.writeEndElement(); // div download-path-column writer.writeStartElement("div"); @@ -408,7 +408,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument() writer.writeStartElement("div"); writer.writeAttribute("class", "download-path-column"); - writer.writeTextElement("p", GuhSettings(GuhSettings::SettingsRoleDeviceStates).fileName()); + writer.writeTextElement("p", NymeaSettings(NymeaSettings::SettingsRoleDeviceStates).fileName()); writer.writeEndElement(); // div download-path-column writer.writeStartElement("div"); @@ -440,7 +440,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument() writer.writeStartElement("div"); writer.writeAttribute("class", "download-path-column"); - writer.writeTextElement("p", GuhSettings(GuhSettings::SettingsRoleRules).fileName()); + writer.writeTextElement("p", NymeaSettings(NymeaSettings::SettingsRoleRules).fileName()); writer.writeEndElement(); // div download-path-column writer.writeStartElement("div"); @@ -472,7 +472,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument() writer.writeStartElement("div"); writer.writeAttribute("class", "download-path-column"); - writer.writeTextElement("p", GuhSettings(GuhSettings::SettingsRolePlugins).fileName()); + writer.writeTextElement("p", NymeaSettings(NymeaSettings::SettingsRolePlugins).fileName()); writer.writeEndElement(); // div download-path-column writer.writeStartElement("div"); @@ -643,10 +643,10 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath) // Check if this is a logdb requested if (requestPath.startsWith("/debug/logdb.sql")) { - qCDebug(dcWebServer()) << "Loading" << GuhSettings::logPath(); - QFile logDatabaseFile(GuhSettings::logPath()); + qCDebug(dcWebServer()) << "Loading" << NymeaSettings::logPath(); + QFile logDatabaseFile(NymeaSettings::logPath()); if (!logDatabaseFile.exists()) { - qCWarning(dcWebServer()) << "Could not read log database file for debug download" << GuhSettings::logPath() << "file does not exist."; + qCWarning(dcWebServer()) << "Could not read log database file for debug download" << NymeaSettings::logPath() << "file does not exist."; HttpReply *reply = RestResource::createErrorReply(HttpReply::NotFound); reply->setHeader(HttpReply::ContentTypeHeader, "text/html"); //: The HTTP error message of the debug interface. The %1 represents the file name. @@ -655,7 +655,7 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath) } if (!logDatabaseFile.open(QFile::ReadOnly)) { - qCWarning(dcWebServer()) << "Could not read log database file for debug download" << GuhSettings::logPath(); + qCWarning(dcWebServer()) << "Could not read log database file for debug download" << NymeaSettings::logPath(); HttpReply *reply = RestResource::createErrorReply(HttpReply::Forbidden); reply->setHeader(HttpReply::ContentTypeHeader, "text/html"); //: The HTTP error message of the debug interface. The %1 represents the file name. @@ -706,7 +706,7 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath) // Check if this is a settings request if (requestPath.startsWith("/debug/settings")) { if (requestPath.startsWith("/debug/settings/devices")) { - QString settingsFileName = GuhSettings(GuhSettings::SettingsRoleDevices).fileName(); + QString settingsFileName = NymeaSettings(NymeaSettings::SettingsRoleDevices).fileName(); qCDebug(dcWebServer()) << "Loading" << settingsFileName; QFile settingsFile(settingsFileName); if (!settingsFile.exists()) { @@ -735,7 +735,7 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath) } if (requestPath.startsWith("/debug/settings/rules")) { - QString settingsFileName = GuhSettings(GuhSettings::SettingsRoleRules).fileName(); + QString settingsFileName = NymeaSettings(NymeaSettings::SettingsRoleRules).fileName(); qCDebug(dcWebServer()) << "Loading" << settingsFileName; QFile settingsFile(settingsFileName); if (!settingsFile.exists()) { @@ -764,7 +764,7 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath) } if (requestPath.startsWith("/debug/settings/nymead")) { - QString settingsFileName = GuhSettings(GuhSettings::SettingsRoleGlobal).fileName(); + QString settingsFileName = NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName(); qCDebug(dcWebServer()) << "Loading" << settingsFileName; QFile settingsFile(settingsFileName); if (!settingsFile.exists()) { @@ -793,7 +793,7 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath) } if (requestPath.startsWith("/debug/settings/devicestates")) { - QString settingsFileName = GuhSettings(GuhSettings::SettingsRoleDeviceStates).fileName(); + QString settingsFileName = NymeaSettings(NymeaSettings::SettingsRoleDeviceStates).fileName(); qCDebug(dcWebServer()) << "Loading" << settingsFileName; QFile settingsFile(settingsFileName); if (!settingsFile.exists()) { @@ -822,7 +822,7 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath) } if (requestPath.startsWith("/debug/settings/plugins")) { - QString settingsFileName = GuhSettings(GuhSettings::SettingsRolePlugins).fileName(); + QString settingsFileName = NymeaSettings(NymeaSettings::SettingsRolePlugins).fileName(); qCDebug(dcWebServer()) << "Loading" << settingsFileName; QFile settingsFile(settingsFileName); if (!settingsFile.exists()) { diff --git a/libnymea-core/guhconfiguration.cpp b/libnymea-core/guhconfiguration.cpp index 8c58d330..9d9cf2e7 100644 --- a/libnymea-core/guhconfiguration.cpp +++ b/libnymea-core/guhconfiguration.cpp @@ -20,7 +20,7 @@ #include "loggingcategories.h" #include "guhconfiguration.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include #include @@ -58,7 +58,7 @@ GuhConfiguration::GuhConfiguration(QObject *parent) : setSslCertificate(sslCertificate(), sslCertificateKey()); setDebugServerEnabled(debugServerEnabled()); - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); // TcpServer bool createDefaults = !settings.childGroups().contains("TcpServer"); @@ -160,15 +160,15 @@ GuhConfiguration::GuhConfiguration(QObject *parent) : QUuid GuhConfiguration::serverUuid() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); return settings.value("uuid", QUuid()).toUuid(); } QString GuhConfiguration::serverName() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); return settings.value("name", "guhIO").toString(); } @@ -176,8 +176,8 @@ void GuhConfiguration::setServerName(const QString &serverName) { qCDebug(dcApplication()) << "Configuration: Server name:" << serverName; - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); if (settings.value("name").toString() == serverName) { qCDebug(dcApplication()) << "Configuration: Server name unchanged."; settings.endGroup(); @@ -190,8 +190,8 @@ void GuhConfiguration::setServerName(const QString &serverName) QByteArray GuhConfiguration::timeZone() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); return settings.value("timeZone", QTimeZone::systemTimeZoneId()).toByteArray(); } @@ -199,8 +199,8 @@ void GuhConfiguration::setTimeZone(const QByteArray &timeZone) { qCDebug(dcApplication()) << "Configuration: Time zone:" << QString::fromUtf8(timeZone); - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); if (settings.value("timeZone").toByteArray() == timeZone) { qCDebug(dcApplication()) << "Configuration: Time zone unchanged."; settings.endGroup(); @@ -213,8 +213,8 @@ void GuhConfiguration::setTimeZone(const QByteArray &timeZone) QLocale GuhConfiguration::locale() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); return settings.value("language", "en_US").toString(); } @@ -222,8 +222,8 @@ void GuhConfiguration::setLocale(const QLocale &locale) { qCDebug(dcApplication()) << "Configuration: set locale:" << locale.name() << locale.nativeCountryName() << locale.nativeLanguageName(); - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); if (settings.value("language").toString() == locale.name()) { qCDebug(dcApplication()) << "Configuration: Language unchanged."; settings.endGroup(); @@ -265,7 +265,7 @@ void GuhConfiguration::setWebServerConfiguration(const WebServerConfiguration &c storeServerConfig("WebServer", config); // This is a bit odd that we need to open the config once more just for the publicFolder... - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("WebServer"); settings.beginGroup(config.id); settings.setValue("publicFolder", config.publicFolder); @@ -303,7 +303,7 @@ void GuhConfiguration::removeWebSocketServerConfiguration(const QString &id) bool GuhConfiguration::bluetoothServerEnabled() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("BluetoothServer"); return settings.value("enabled", false).toBool(); } @@ -312,7 +312,7 @@ void GuhConfiguration::setBluetoothServerEnabled(const bool &enabled) { qCDebug(dcApplication()) << "Configuration: Bluetooth server" << (enabled ? "enabled" : "disabled"); - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("BluetoothServer"); settings.setValue("enabled", enabled); settings.endGroup(); @@ -321,7 +321,7 @@ void GuhConfiguration::setBluetoothServerEnabled(const bool &enabled) bool GuhConfiguration::cloudEnabled() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("Cloud"); return settings.value("enabled", false).toBool(); } @@ -329,7 +329,7 @@ bool GuhConfiguration::cloudEnabled() const void GuhConfiguration::setCloudEnabled(bool enabled) { if (cloudEnabled() != enabled) { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("Cloud"); settings.setValue("enabled", enabled); settings.endGroup(); @@ -339,49 +339,49 @@ void GuhConfiguration::setCloudEnabled(bool enabled) QString GuhConfiguration::cloudServerUrl() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("Cloud"); return settings.value("cloudServerUrl").toString(); } QString GuhConfiguration::cloudCertificateCA() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("Cloud"); return settings.value("cloudCertificateCA").toString(); } QString GuhConfiguration::cloudCertificate() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("Cloud"); return settings.value("cloudCertificate").toString(); } QString GuhConfiguration::cloudCertificateKey() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("Cloud"); return settings.value("cloudCertificateKey").toString(); } QString GuhConfiguration::sslCertificate() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("SSL"); return settings.value("certificate").toString(); } QString GuhConfiguration::sslCertificateKey() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("SSL"); return settings.value("certificate-key").toString(); } void GuhConfiguration::setSslCertificate(const QString &sslCertificate, const QString &sslCertificateKey) { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("SSL"); settings.setValue("certificate", sslCertificate); settings.setValue("certificate-key", sslCertificateKey); @@ -390,8 +390,8 @@ void GuhConfiguration::setSslCertificate(const QString &sslCertificate, const QS bool GuhConfiguration::debugServerEnabled() const { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); return settings.value("debugServerEnabled", false).toBool(); } @@ -399,8 +399,8 @@ void GuhConfiguration::setDebugServerEnabled(bool enabled) { qCDebug(dcApplication()) << "Configuration: Set debug server" << (enabled ? "enabled" : "disabled"); bool currentValue = debugServerEnabled(); - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); settings.setValue("debugServerEnabled", enabled); settings.endGroup(); @@ -413,8 +413,8 @@ void GuhConfiguration::setServerUuid(const QUuid &uuid) { qCDebug(dcApplication()) << "Configuration: Server uuid:" << uuid.toString(); - GuhSettings settings(GuhSettings::SettingsRoleGlobal); - settings.beginGroup("guhd"); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); + settings.beginGroup("nymead"); settings.setValue("uuid", uuid); settings.endGroup(); } @@ -433,7 +433,7 @@ QString GuhConfiguration::defaultWebserverPublicFolderPath() const void GuhConfiguration::storeServerConfig(const QString &group, const ServerConfiguration &config) { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup(group); settings.remove("disabled"); settings.beginGroup(config.id); @@ -448,7 +448,7 @@ void GuhConfiguration::storeServerConfig(const QString &group, const ServerConfi ServerConfiguration GuhConfiguration::readServerConfig(const QString &group, const QString &id) { ServerConfiguration config; - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup(group); settings.beginGroup(id); config.id = id; @@ -463,7 +463,7 @@ ServerConfiguration GuhConfiguration::readServerConfig(const QString &group, con void GuhConfiguration::deleteServerConfig(const QString &group, const QString &id) { - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup(group); settings.remove(id); if (settings.childGroups().isEmpty()) { @@ -475,7 +475,7 @@ void GuhConfiguration::deleteServerConfig(const QString &group, const QString &i void GuhConfiguration::storeWebServerConfig(const WebServerConfiguration &config) { storeServerConfig("WebServer", config); - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("WebServer"); settings.beginGroup(config.id); settings.setValue("publicFolder", config.publicFolder); @@ -486,7 +486,7 @@ void GuhConfiguration::storeWebServerConfig(const WebServerConfiguration &config WebServerConfiguration GuhConfiguration::readWebServerConfig(const QString &id) { WebServerConfiguration config; - GuhSettings settings(GuhSettings::SettingsRoleGlobal); + NymeaSettings settings(NymeaSettings::SettingsRoleGlobal); settings.beginGroup("WebServer"); settings.beginGroup(id); config.id = id; diff --git a/libnymea-core/guhcore.cpp b/libnymea-core/guhcore.cpp index b620babb..f34f5aa4 100644 --- a/libnymea-core/guhcore.cpp +++ b/libnymea-core/guhcore.cpp @@ -100,6 +100,7 @@ #include "jsonrpc/jsonrpcserver.h" #include "ruleengine.h" #include "networkmanager/networkmanager.h" +#include "nymeasettings.h" #include "devicemanager.h" #include "plugin/device.h" @@ -476,14 +477,14 @@ GuhCore::GuhCore(QObject *parent) : } void GuhCore::init() { - qCDebug(dcApplication()) << "Loading guh configurations" << GuhSettings(GuhSettings::SettingsRoleGlobal).fileName(); + qCDebug(dcApplication()) << "Loading guh configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName(); m_configuration = new GuhConfiguration(this); qCDebug(dcApplication()) << "Creating Time Manager"; m_timeManager = new TimeManager(QTimeZone::systemTimeZoneId(), this); qCDebug(dcApplication) << "Creating Log Engine"; - m_logger = new LogEngine(GuhSettings::logPath(), this); + m_logger = new LogEngine(NymeaSettings::logPath(), this); qCDebug(dcApplication) << "Creating Hardware Manager"; m_hardwareManager = new HardwareManagerImplementation(this); diff --git a/libnymea-core/hardware/network/upnp/upnpdiscoveryimplementation.cpp b/libnymea-core/hardware/network/upnp/upnpdiscoveryimplementation.cpp index 790993be..3da8f54f 100644 --- a/libnymea-core/hardware/network/upnp/upnpdiscoveryimplementation.cpp +++ b/libnymea-core/hardware/network/upnp/upnpdiscoveryimplementation.cpp @@ -42,7 +42,7 @@ */ -#include "guhsettings.h" +#include "nymeasettings.h" #include "loggingcategories.h" #include "upnpdiscoveryimplementation.h" @@ -119,8 +119,8 @@ void UpnpDiscoveryImplementation::requestDeviceInformation(const QNetworkRequest void UpnpDiscoveryImplementation::respondToSearchRequest(QHostAddress host, int port) { // TODO: Once DeviceManager (and with that this can be moved into the server, use GuhCore's configuration manager instead of parsing the config here... - GuhSettings globalSettings(GuhSettings::SettingsRoleGlobal); - globalSettings.beginGroup("guhd"); + NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal); + globalSettings.beginGroup("nymead"); QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray(); globalSettings.endGroup(); @@ -349,8 +349,8 @@ void UpnpDiscoveryImplementation::notificationTimeout() void UpnpDiscoveryImplementation::sendByeByeMessage() { // TODO: Once DeviceManager (and with that this can be moved into the server, use GuhCore's configuration manager instead of parsing the config here... - GuhSettings globalSettings(GuhSettings::SettingsRoleGlobal); - globalSettings.beginGroup("guhd"); + NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal); + globalSettings.beginGroup("nymead"); QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray(); globalSettings.endGroup(); @@ -394,9 +394,9 @@ void UpnpDiscoveryImplementation::sendByeByeMessage() void UpnpDiscoveryImplementation::sendAliveMessage() { - // TODO: Once DeviceManager (and with that this can be moved into the server, use GuhCore's configuration manager instead of parsing the config here... - GuhSettings globalSettings(GuhSettings::SettingsRoleGlobal); - globalSettings.beginGroup("guhd"); + // TODO: Once DeviceManager (and with that this) can be moved into the server, use GuhCore's configuration manager instead of parsing the config here... + NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal); + globalSettings.beginGroup("nymead"); QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray(); globalSettings.endGroup(); diff --git a/libnymea-core/hardware/radio433/radio433brennenstuhl.cpp b/libnymea-core/hardware/radio433/radio433brennenstuhl.cpp index cc77aa42..4323001d 100644 --- a/libnymea-core/hardware/radio433/radio433brennenstuhl.cpp +++ b/libnymea-core/hardware/radio433/radio433brennenstuhl.cpp @@ -49,7 +49,6 @@ #include "radio433brennenstuhl.h" #include "loggingcategories.h" -#include "guhsettings.h" #include "hardware/gpio.h" #include diff --git a/libnymea-core/logging/logengine.cpp b/libnymea-core/logging/logengine.cpp index 7338e275..ca6c091d 100644 --- a/libnymea-core/logging/logengine.cpp +++ b/libnymea-core/logging/logengine.cpp @@ -110,7 +110,7 @@ This \l{LogEntry} represents the enable/disable event from an \l{Rule}. */ -#include "guhsettings.h" +#include "nymeasettings.h" #include "logengine.h" #include "loggingcategories.h" #include "logging.h" diff --git a/libnymea-core/logging/logengine.h b/libnymea-core/logging/logengine.h index 38441fc3..8020b055 100644 --- a/libnymea-core/logging/logengine.h +++ b/libnymea-core/logging/logengine.h @@ -27,6 +27,7 @@ #include "types/event.h" #include "types/action.h" #include "rule.h" +#include "nymeasettings.h" #include #include @@ -38,7 +39,7 @@ class LogEngine: public QObject { Q_OBJECT public: - LogEngine(const QString &logPath = GuhSettings::logPath(), QObject *parent = 0); + LogEngine(const QString &logPath = NymeaSettings::logPath(), QObject *parent = 0); ~LogEngine(); QList logEntries(const LogFilter &filter = LogFilter()) const; diff --git a/libnymea-core/ruleengine.cpp b/libnymea-core/ruleengine.cpp index ba83f59f..f1b883da 100644 --- a/libnymea-core/ruleengine.cpp +++ b/libnymea-core/ruleengine.cpp @@ -107,7 +107,7 @@ #include "types/eventdescriptor.h" #include "types/paramdescriptor.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "devicemanager.h" #include "plugin/device.h" @@ -124,7 +124,7 @@ namespace guhserver { RuleEngine::RuleEngine(QObject *parent) : QObject(parent) { - GuhSettings settings(GuhSettings::SettingsRoleRules); + NymeaSettings settings(NymeaSettings::SettingsRoleRules); qCDebug(dcRuleEngine) << "Loading rules from" << settings.fileName(); foreach (const QString &idString, settings.childGroups()) { settings.beginGroup(idString); @@ -797,7 +797,7 @@ RuleEngine::RuleError RuleEngine::removeRule(const RuleId &ruleId, bool fromEdit m_rules.remove(ruleId); m_activeRules.removeAll(ruleId); - GuhSettings settings(GuhSettings::SettingsRoleRules); + NymeaSettings settings(NymeaSettings::SettingsRoleRules); settings.beginGroup(ruleId.toString()); settings.remove(""); settings.endGroup(); @@ -1056,7 +1056,7 @@ void RuleEngine::removeDeviceFromRule(const RuleId &id, const DeviceId &deviceId } // remove the rule from settings - GuhSettings settings(GuhSettings::SettingsRoleRules); + NymeaSettings settings(NymeaSettings::SettingsRoleRules); settings.beginGroup(id.toString()); settings.remove(""); settings.endGroup(); @@ -1215,7 +1215,7 @@ void RuleEngine::appendRule(const Rule &rule) void RuleEngine::saveRule(const Rule &rule) { - GuhSettings settings(GuhSettings::SettingsRoleRules); + NymeaSettings settings(NymeaSettings::SettingsRoleRules); settings.beginGroup(rule.id().toString()); settings.setValue("name", rule.name()); settings.setValue("enabled", rule.enabled()); diff --git a/libnymea-core/servermanager.cpp b/libnymea-core/servermanager.cpp index 96ee5191..2fdb2800 100644 --- a/libnymea-core/servermanager.cpp +++ b/libnymea-core/servermanager.cpp @@ -59,8 +59,8 @@ ServerManager::ServerManager(GuhConfiguration* configuration, QObject *parent) : QString configCertificateFileName = configuration->sslCertificate(); QString configKeyFileName = configuration->sslCertificateKey(); - QString fallbackCertificateFileName = GuhSettings::storagePath() + "/certs/nymead-certificate.crt"; - QString fallbackKeyFileName = GuhSettings::storagePath() + "/certs/nymead-certificate.key"; + QString fallbackCertificateFileName = NymeaSettings::storagePath() + "/certs/nymead-certificate.crt"; + QString fallbackKeyFileName = NymeaSettings::storagePath() + "/certs/nymead-certificate.key"; bool certsLoaded = false; if (loadCertificate(configKeyFileName, configCertificateFileName)) { diff --git a/libnymea-core/stateevaluator.cpp b/libnymea-core/stateevaluator.cpp index 6b8f82f7..28cd1a03 100644 --- a/libnymea-core/stateevaluator.cpp +++ b/libnymea-core/stateevaluator.cpp @@ -38,7 +38,7 @@ #include "guhcore.h" #include "devicemanager.h" #include "loggingcategories.h" -#include "guhsettings.h" +#include "nymeasettings.h" namespace guhserver { @@ -169,7 +169,7 @@ QList StateEvaluator::containedDevices() const /*! This method will be used to save this \l StateEvaluator to the given \a settings. The \a groupName will normally be the corresponding \l Rule. */ -void StateEvaluator::dumpToSettings(GuhSettings &settings, const QString &groupName) const +void StateEvaluator::dumpToSettings(NymeaSettings &settings, const QString &groupName) const { settings.beginGroup(groupName); @@ -193,7 +193,7 @@ void StateEvaluator::dumpToSettings(GuhSettings &settings, const QString &groupN /*! This method will be used to load a \l StateEvaluator from the given \a settings. The \a groupName will be the corresponding \l RuleId. Returns the loaded \l StateEvaluator. */ -StateEvaluator StateEvaluator::loadFromSettings(GuhSettings &settings, const QString &groupName) +StateEvaluator StateEvaluator::loadFromSettings(NymeaSettings &settings, const QString &groupName) { settings.beginGroup(groupName); settings.beginGroup("stateDescriptor"); diff --git a/libnymea-core/stateevaluator.h b/libnymea-core/stateevaluator.h index 15bab77a..79ad6dba 100644 --- a/libnymea-core/stateevaluator.h +++ b/libnymea-core/stateevaluator.h @@ -27,7 +27,7 @@ #include -class GuhSettings; +class NymeaSettings; namespace guhserver { @@ -52,8 +52,8 @@ public: void removeDevice(const DeviceId &deviceId); QList containedDevices() const; - void dumpToSettings(GuhSettings &settings, const QString &groupName) const; - static StateEvaluator loadFromSettings(GuhSettings &settings, const QString &groupPrefix); + void dumpToSettings(NymeaSettings &settings, const QString &groupName) const; + static StateEvaluator loadFromSettings(NymeaSettings &settings, const QString &groupPrefix); bool isValid() const; diff --git a/libnymea-core/tcpserver.cpp b/libnymea-core/tcpserver.cpp index 0e95cb7b..de7a82bb 100644 --- a/libnymea-core/tcpserver.cpp +++ b/libnymea-core/tcpserver.cpp @@ -34,7 +34,6 @@ */ #include "tcpserver.h" -#include "guhsettings.h" #include "guhcore.h" #include diff --git a/libnymea-core/time/timedescriptor.h b/libnymea-core/time/timedescriptor.h index ca46cb5b..816bec2f 100644 --- a/libnymea-core/time/timedescriptor.h +++ b/libnymea-core/time/timedescriptor.h @@ -23,7 +23,6 @@ #include "timeeventitem.h" #include "calendaritem.h" -#include "guhsettings.h" namespace guhserver { @@ -43,8 +42,8 @@ public: bool evaluate(const QDateTime &lastEvaluationTime, const QDateTime &dateTime) const; -// void dumpToSettings(GuhSettings &settings, const QString &groupName) const; -// static TimeDescriptor loadFromSettings(GuhSettings &settings, const QString &groupPrefix); +// void dumpToSettings(NymeaSettings &settings, const QString &groupName) const; +// static TimeDescriptor loadFromSettings(NymeaSettings &settings, const QString &groupPrefix); private: diff --git a/libnymea-core/usermanager.cpp b/libnymea-core/usermanager.cpp index 3de327fb..4bf2b348 100644 --- a/libnymea-core/usermanager.cpp +++ b/libnymea-core/usermanager.cpp @@ -19,7 +19,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "usermanager.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "loggingcategories.h" #include "guhcore.h" #include "pushbuttondbusservice.h" @@ -38,7 +38,7 @@ namespace guhserver { UserManager::UserManager(QObject *parent) : QObject(parent) { m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), "users"); - m_db.setDatabaseName(GuhSettings::settingsPath() + "/user-db.sqlite"); + m_db.setDatabaseName(NymeaSettings::settingsPath() + "/user-db.sqlite"); if (!m_db.open()) { qCWarning(dcUserManager) << "Error opening users database:" << m_db.lastError().driverText(); diff --git a/libnymea-core/webserver.cpp b/libnymea-core/webserver.cpp index 3edba430..a8887d92 100644 --- a/libnymea-core/webserver.cpp +++ b/libnymea-core/webserver.cpp @@ -27,7 +27,7 @@ The \l{WebServer} class provides a HTTP/1.1 web server. The web server provides access to the guh-webinterface and the path can be specified - in the \tt /etc/guh/guhd.conf file and to the guh \l{https://github.com/guh/guh/wiki/REST-Api-documentation}{REST API}. + in the \tt /etc/guh/nymead.conf file and to the guh \l{https://github.com/guh/guh/wiki/REST-Api-documentation}{REST API}. The default port for the web server is 3333, which is according to this \l{https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers}{list} officially free. @@ -44,10 +44,10 @@ The URL for the secure HTTPS (TLS 1.2) REST API access to a \l{RestResource}: \code https://localhost:3333/api/v1/{RestResource}\endcode - You can turn on the HTTPS server in the \tt WebServer section of the \tt /etc/guh/guhd.conf file. + You can turn on the HTTPS server in the \tt WebServer section of the \tt /etc/guh/nymead.conf file. \note For \tt HTTPS you need to have a certificate and configure it in the \tt SSL-configuration - section of the \tt /etc/guh/guhd.conf file. + section of the \tt /etc/guh/nymead.conf file. \sa WebServerClient, WebSocketServer, TcpServer */ @@ -72,7 +72,8 @@ #include "webserver.h" #include "loggingcategories.h" -#include "guhsettings.h" +#include "nymeasettings.h" +#include "guhcore.h" #include "httpreply.h" #include "httprequest.h" #include "rest/restresource.h" @@ -384,7 +385,7 @@ void WebServer::readClient() reply->deleteLater(); return; } else { - qCWarning(dcWebServer()) << "The debug server handler is disabled. You can enable it by adding \'debugServerEnabled=true\' in the \'nymead\' section of the guhd.conf file."; + qCWarning(dcWebServer()) << "The debug server handler is disabled. You can enable it by adding \'debugServerEnabled=true\' in the \'nymead\' section of the nymead.conf file."; HttpReply *reply = RestResource::createErrorReply(HttpReply::NotFound); reply->setClientId(clientId); sendHttpReply(reply); diff --git a/libnymea-core/websocketserver.cpp b/libnymea-core/websocketserver.cpp index 169258f5..38d97b66 100644 --- a/libnymea-core/websocketserver.cpp +++ b/libnymea-core/websocketserver.cpp @@ -39,15 +39,15 @@ 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/guhd.conf file. + You can turn on the \tt wss server in the \tt WebServerServer section of the \tt /etc/guh/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/guhd.conf file. + section of the \tt /etc/guh/nymead.conf file. \sa WebServer, TcpServer, TransportInterface */ -#include "guhsettings.h" +#include "nymeasettings.h" #include "guhcore.h" #include "websocketserver.h" #include "loggingcategories.h" diff --git a/libnymea/devicemanager.cpp b/libnymea/devicemanager.cpp index 1794a9bd..45565b1f 100644 --- a/libnymea/devicemanager.cpp +++ b/libnymea/devicemanager.cpp @@ -163,7 +163,7 @@ #include "plugin/devicepairinginfo.h" #include "plugin/deviceplugin.h" #include "typeutils.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "unistd.h" #include "plugintimer.h" @@ -346,7 +346,7 @@ DeviceManager::DeviceError DeviceManager::setPluginConfig(const PluginId &plugin if (result != DeviceErrorNoError) return result; - GuhSettings settings(GuhSettings::SettingsRolePlugins); + NymeaSettings settings(NymeaSettings::SettingsRolePlugins); settings.beginGroup("PluginConfig"); settings.beginGroup(plugin->pluginId().toString()); foreach (const Param ¶m, params) { @@ -760,13 +760,13 @@ DeviceManager::DeviceError DeviceManager::removeConfiguredDevice(const DeviceId device->deleteLater(); - GuhSettings settings(GuhSettings::SettingsRoleDevices); + NymeaSettings settings(NymeaSettings::SettingsRoleDevices); settings.beginGroup("DeviceConfig"); settings.beginGroup(deviceId.toString()); settings.remove(""); settings.endGroup(); - GuhSettings stateCache(GuhSettings::SettingsRoleDeviceStates); + NymeaSettings stateCache(NymeaSettings::SettingsRoleDeviceStates); stateCache.remove(deviceId.toString()); emit deviceRemoved(deviceId); @@ -1070,7 +1070,7 @@ void DeviceManager::loadPlugin(DevicePlugin *pluginIface) qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name(); } - GuhSettings settings(GuhSettings::SettingsRolePlugins); + NymeaSettings settings(NymeaSettings::SettingsRolePlugins); settings.beginGroup("PluginConfig"); ParamList params; if (settings.childGroups().contains(pluginIface->pluginId().toString())) { @@ -1109,7 +1109,7 @@ void DeviceManager::loadPlugin(DevicePlugin *pluginIface) void DeviceManager::loadConfiguredDevices() { - GuhSettings settings(GuhSettings::SettingsRoleDevices); + NymeaSettings settings(NymeaSettings::SettingsRoleDevices); settings.beginGroup("DeviceConfig"); qCDebug(dcDeviceManager) << "Loading devices from" << settings.fileName(); foreach (const QString &idString, settings.childGroups()) { @@ -1142,7 +1142,7 @@ void DeviceManager::loadConfiguredDevices() void DeviceManager::storeConfiguredDevices() { - GuhSettings settings(GuhSettings::SettingsRoleDevices); + NymeaSettings settings(NymeaSettings::SettingsRoleDevices); settings.beginGroup("DeviceConfig"); foreach (Device *device, m_configuredDevices) { settings.beginGroup(device->id().toString()); @@ -1407,7 +1407,7 @@ void DeviceManager::onLoaded() void DeviceManager::cleanupDeviceStateCache() { - GuhSettings settings(GuhSettings::SettingsRoleDeviceStates); + NymeaSettings settings(NymeaSettings::SettingsRoleDeviceStates); foreach (const QString &entry, settings.childGroups()) { DeviceId deviceId(entry); if (!m_configuredDevices.contains(deviceId)) { @@ -1484,7 +1484,7 @@ void DeviceManager::postSetupDevice(Device *device) void DeviceManager::loadDeviceStates(Device *device) { - GuhSettings settings(GuhSettings::SettingsRoleDeviceStates); + NymeaSettings settings(NymeaSettings::SettingsRoleDeviceStates); settings.beginGroup(device->id().toString()); DeviceClass deviceClass = m_supportedDevices.value(device->deviceClassId()); foreach (const StateType &stateType, deviceClass.stateTypes()) { @@ -1499,7 +1499,7 @@ void DeviceManager::loadDeviceStates(Device *device) void DeviceManager::storeDeviceStates(Device *device) { - GuhSettings settings(GuhSettings::SettingsRoleDeviceStates); + NymeaSettings settings(NymeaSettings::SettingsRoleDeviceStates); settings.beginGroup(device->id().toString()); DeviceClass deviceClass = m_supportedDevices.value(device->deviceClassId()); foreach (const StateType &stateType, deviceClass.stateTypes()) { diff --git a/libnymea/hardware/radio433/radio433.cpp b/libnymea/hardware/radio433/radio433.cpp index a59efc09..65e8b507 100644 --- a/libnymea/hardware/radio433/radio433.cpp +++ b/libnymea/hardware/radio433/radio433.cpp @@ -49,7 +49,6 @@ #include "radio433.h" #include "loggingcategories.h" -#include "guhsettings.h" #include "hardware/gpio.h" #include diff --git a/libnymea/hardwareresource.cpp b/libnymea/hardwareresource.cpp index e9794009..56295be2 100644 --- a/libnymea/hardwareresource.cpp +++ b/libnymea/hardwareresource.cpp @@ -21,7 +21,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "hardwareresource.h" -#include "guhsettings.h" #include "hardwaremanager.h" #include "loggingcategories.h" diff --git a/libnymea/libnymea.pro b/libnymea/libnymea.pro index 8c52ed01..3d45d2e2 100644 --- a/libnymea/libnymea.pro +++ b/libnymea/libnymea.pro @@ -18,7 +18,7 @@ HEADERS += devicemanager.h \ libnymea.h \ typeutils.h \ loggingcategories.h \ - guhsettings.h \ + nymeasettings.h \ plugin/device.h \ plugin/deviceplugin.h \ plugin/devicedescriptor.h \ @@ -74,7 +74,7 @@ HEADERS += devicemanager.h \ SOURCES += devicemanager.cpp \ loggingcategories.cpp \ - guhsettings.cpp \ + nymeasettings.cpp \ plugin/device.cpp \ plugin/deviceplugin.cpp \ plugin/devicedescriptor.cpp \ diff --git a/libnymea/guhsettings.cpp b/libnymea/nymeasettings.cpp similarity index 67% rename from libnymea/guhsettings.cpp rename to libnymea/nymeasettings.cpp index 3fde4dfc..2964a7c0 100644 --- a/libnymea/guhsettings.cpp +++ b/libnymea/nymeasettings.cpp @@ -21,21 +21,21 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*! - \class GuhSettings - \brief The settings class for guh. + \class NymeaSettings + \brief The settings class for nymea. \ingroup devices - \inmodule libguh + \inmodule libnymea - Depending on how the guh server was started (which user started guhd), the setting have to + Depending on how the nymea server was started (which user started nymead), the setting have to be stored in different locations. This class represents a centralized mechanism to store settings of the system. The different settings are represented ba the \l{SettingsRole} and can be used everywhere in the project. */ -/*! \enum GuhSettings::SettingsRole - Represents the role for the \l{GuhSettings}. Each role creates its own settings file. +/*! \enum NymeaSettings::SettingsRole + Represents the role for the \l{NymeaSettings}. Each role creates its own settings file. \value SettingsRoleNone No role will be used. This sould not be used! @@ -46,11 +46,11 @@ \value SettingsRolePlugins This role will create the \b{plugins.conf} file and is used to store the \l{DevicePlugin}{Plugin} configurations. \value SettingsRoleGlobal - This role will create the \b{guhd.conf} file and is used to store the global settings of the guh system. This settings + This role will create the \b{nymead.conf} file and is used to store the global settings of the guh system. This settings file is read only. */ -#include "guhsettings.h" +#include "nymeasettings.h" #include "unistd.h" #include @@ -58,8 +58,8 @@ #include #include -/*! Constructs a \l{GuhSettings} instance with the given \a role and \a parent. */ -GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): +/*! Constructs a \l{NymeaSettings} instance with the given \a role and \a parent. */ +NymeaSettings::NymeaSettings(const SettingsRole &role, QObject *parent): QObject(parent), m_role(role) { @@ -69,7 +69,7 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): if (!qgetenv("SNAP").isEmpty()) { basePath = QString(qgetenv("SNAP_DATA")) + "/"; settingsPrefix.clear(); // We don't want that in the snappy case... - } else if (settingsPrefix == "guh-test/") { + } else if (settingsPrefix == "nymea-test/") { basePath = "/tmp/"; } else if (isRoot()) { basePath = "/etc/"; @@ -91,7 +91,7 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): fileName = "plugins.conf"; break; case SettingsRoleGlobal: - fileName = "guhd.conf"; + fileName = "nymead.conf"; break; case SettingsRoleDeviceStates: fileName = "devicestates.conf"; @@ -100,21 +100,21 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): m_settings = new QSettings(basePath + settingsPrefix + fileName, QSettings::IniFormat, this); } -/*! Destructor of the GuhSettings.*/ -GuhSettings::~GuhSettings() +/*! Destructor of the NymeaSettings.*/ +NymeaSettings::~NymeaSettings() { m_settings->sync(); delete m_settings; } -/*! Returns the \l{SettingsRole} of this \l{GuhSettings}.*/ -GuhSettings::SettingsRole GuhSettings::settingsRole() const +/*! Returns the \l{SettingsRole} of this \l{NymeaSettings}.*/ +NymeaSettings::SettingsRole NymeaSettings::settingsRole() const { return m_role; } -/*! Returns true if guhd is started as \b{root}.*/ -bool GuhSettings::isRoot() +/*! Returns true if nymead is started as \b{root}.*/ +bool NymeaSettings::isRoot() { if (getuid() != 0) return false; @@ -126,62 +126,62 @@ bool GuhSettings::isRoot() \sa guhserver::LogEngine */ -QString GuhSettings::logPath() +QString NymeaSettings::logPath() { QString logPath; QString organisationName = QCoreApplication::instance()->organizationName(); if (!qgetenv("SNAP").isEmpty()) { - logPath = QString(qgetenv("SNAP_COMMON")) + "/guhd.sqlite"; - } else if (organisationName == "guh-test") { - logPath = "/tmp/" + organisationName + "/guhd-test.sqlite"; - } else if (GuhSettings::isRoot()) { - logPath = "/var/log/guhd.sqlite"; + logPath = QString(qgetenv("SNAP_COMMON")) + "/nymead.sqlite"; + } else if (organisationName == "nymea-test") { + logPath = "/tmp/" + organisationName + "/nymead-test.sqlite"; + } else if (NymeaSettings::isRoot()) { + logPath = "/var/log/nymead.sqlite"; } else { - logPath = QDir::homePath() + "/.config/" + organisationName + "/guhd.sqlite"; + logPath = QDir::homePath() + "/.config/" + organisationName + "/nymead.sqlite"; } return logPath; } -/*! Returns the path to the folder where the GuhSettings will be saved i.e. \tt{/etc/guh}. */ -QString GuhSettings::settingsPath() +/*! Returns the path to the folder where the NymeaSettings will be saved i.e. \tt{/etc/nymea}. */ +QString NymeaSettings::settingsPath() { QString path; QString organisationName = QCoreApplication::instance()->organizationName(); if (!qgetenv("SNAP").isEmpty()) { path = QString(qgetenv("SNAP_DATA")); - } else if (organisationName == "guh-test") { + } else if (organisationName == "nymea-test") { path = "/tmp/" + organisationName; - } else if (GuhSettings::isRoot()) { - path = "/etc/guh"; + } else if (NymeaSettings::isRoot()) { + path = "/etc/nymea"; } else { path = QDir::homePath() + "/.config/" + organisationName; } return path; } -/*! Returns the default system translation path \tt{/usr/share/guh/translations}. */ -QString GuhSettings::translationsPath() +/*! Returns the default system translation path \tt{/usr/share/nymea/translations}. */ +QString NymeaSettings::translationsPath() { if (!qgetenv("SNAP").isEmpty()) { - return QString(qgetenv("SNAP") + "/usr/share/guh/translations"); + return QString(qgetenv("SNAP") + "/usr/share/nymea/translations"); } else { - return QString("/usr/share/guh/translations"); + return QString("/usr/share/nymea/translations"); } } -/*! Returns the default system sorage path i.e. \tt{/var/lib/guh}. */ -QString GuhSettings::storagePath() +/*! Returns the default system sorage path i.e. \tt{/var/lib/nymea}. */ +QString NymeaSettings::storagePath() { QString path; QString organisationName = QCoreApplication::instance()->organizationName(); if (!qgetenv("SNAP").isEmpty()) { path = QString(qgetenv("SNAP_DATA")); - } else if (organisationName == "guh-test") { + } else if (organisationName == "nymea-test") { path = "/tmp/" + organisationName; - } else if (GuhSettings::isRoot()) { + } else if (NymeaSettings::isRoot()) { path = "/var/lib/" + organisationName; } else { path = QDir::homePath() + "/.local/share/" + organisationName; @@ -190,105 +190,105 @@ QString GuhSettings::storagePath() } /*! Return a list of all settings keys.*/ -QStringList GuhSettings::allKeys() const +QStringList NymeaSettings::allKeys() const { return m_settings->allKeys(); } /*! Adds \a prefix to the current group and starts writing an array of size size. If size is -1 (the default), * it is automatically determined based on the indexes of the entries written. */ -void GuhSettings::beginWriteArray(const QString &prefix) +void NymeaSettings::beginWriteArray(const QString &prefix) { m_settings->beginWriteArray(prefix); } /*! Sets the current array index to \a i. */ -void GuhSettings::setArrayIndex(int i) +void NymeaSettings::setArrayIndex(int i) { m_settings->setArrayIndex(i); } /*! Adds \a prefix to the current group and starts reading from an array. Returns the size of the array.*/ -int GuhSettings::beginReadArray(const QString &prefix) +int NymeaSettings::beginReadArray(const QString &prefix) { return m_settings->beginReadArray(prefix); } /*! End an array. */ -void GuhSettings::endArray() +void NymeaSettings::endArray() { m_settings->endArray(); } /*! Begins a new group with the given \a prefix.*/ -void GuhSettings::beginGroup(const QString &prefix) +void NymeaSettings::beginGroup(const QString &prefix) { m_settings->beginGroup(prefix); } /*! Returns a list of all key top-level groups that contain keys that can be read - * using the \l{GuhSettings} object.*/ -QStringList GuhSettings::childGroups() const + * using the \l{NymeaSettings} object.*/ +QStringList NymeaSettings::childGroups() const { return m_settings->childGroups(); } -/*! Returns a list of all top-level keys that can be read using the \l{GuhSettings} object.*/ -QStringList GuhSettings::childKeys() const +/*! Returns a list of all top-level keys that can be read using the \l{NymeaSettings} object.*/ +QStringList NymeaSettings::childKeys() const { return m_settings->childKeys(); } -/*! Removes all entries in the primary location associated to this \l{GuhSettings} object.*/ -void GuhSettings::clear() +/*! Removes all entries in the primary location associated to this \l{NymeaSettings} object.*/ +void NymeaSettings::clear() { m_settings->clear(); } /*! Returns true if there exists a setting called \a key; returns false otherwise. */ -bool GuhSettings::contains(const QString &key) const +bool NymeaSettings::contains(const QString &key) const { return m_settings->contains(key); } /*! Resets the group to what it was before the corresponding beginGroup() call. */ -void GuhSettings::endGroup() +void NymeaSettings::endGroup() { m_settings->endGroup(); } /*! Returns the current group. */ -QString GuhSettings::group() const +QString NymeaSettings::group() const { return m_settings->group(); } -/*! Returns the path where settings written using this \l{GuhSettings} object are stored. */ -QString GuhSettings::fileName() const +/*! Returns the path where settings written using this \l{NymeaSettings} object are stored. */ +QString NymeaSettings::fileName() const { return m_settings->fileName(); } -/*! Returns true if settings can be written using this \l{GuhSettings} object; returns false otherwise. */ -bool GuhSettings::isWritable() const +/*! Returns true if settings can be written using this \l{NymeaSettings} object; returns false otherwise. */ +bool NymeaSettings::isWritable() const { return m_settings->isWritable(); } /*! Removes the setting key and any sub-settings of \a key. */ -void GuhSettings::remove(const QString &key) +void NymeaSettings::remove(const QString &key) { m_settings->remove(key); } /*! Sets the \a value of setting \a key to value. If the \a key already exists, the previous value is overwritten. */ -void GuhSettings::setValue(const QString &key, const QVariant &value) +void NymeaSettings::setValue(const QString &key, const QVariant &value) { m_settings->setValue(key, value); } /*! Returns the value for setting \a key. If the setting doesn't exist, returns \a defaultValue. */ -QVariant GuhSettings::value(const QString &key, const QVariant &defaultValue) const +QVariant NymeaSettings::value(const QString &key, const QVariant &defaultValue) const { return m_settings->value(key, defaultValue); } diff --git a/libnymea/guhsettings.h b/libnymea/nymeasettings.h similarity index 92% rename from libnymea/guhsettings.h rename to libnymea/nymeasettings.h index 89703497..b333dc39 100644 --- a/libnymea/guhsettings.h +++ b/libnymea/nymeasettings.h @@ -20,8 +20,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef GUHSETTINGS_H -#define GUHSETTINGS_H +#ifndef NYMEASETTINGS_H +#define NYMEASETTINGS_H #include #include @@ -30,7 +30,7 @@ class QSettings; -class LIBNYMEA_EXPORT GuhSettings : public QObject +class LIBNYMEA_EXPORT NymeaSettings : public QObject { Q_OBJECT public: @@ -43,8 +43,8 @@ public: SettingsRoleDeviceStates }; - explicit GuhSettings(const SettingsRole &role = SettingsRoleNone, QObject *parent = nullptr); - ~GuhSettings(); + explicit NymeaSettings(const SettingsRole &role = SettingsRoleNone, QObject *parent = nullptr); + ~NymeaSettings(); SettingsRole settingsRole() const; @@ -80,4 +80,4 @@ private: }; -#endif // GUHSETTINGS_H +#endif // NYMEASETTINGS_H diff --git a/libnymea/plugin/deviceplugin.cpp b/libnymea/plugin/deviceplugin.cpp index c10f670d..9a8f8e1e 100644 --- a/libnymea/plugin/deviceplugin.cpp +++ b/libnymea/plugin/deviceplugin.cpp @@ -96,7 +96,7 @@ #include "loggingcategories.h" #include "devicemanager.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "hardware/radio433/radio433.h" #include "network/upnp/upnpdiscovery.h" @@ -178,8 +178,8 @@ bool DevicePlugin::setLocale(const QLocale &locale) } // otherwise use the system translations - if (m_translator->load(locale, m_metaData.value("id").toString(), "-", GuhSettings::translationsPath(), ".qm")) { - qCDebug(dcDeviceManager()) << "* Load translation" << locale.name() << "for" << pluginName() << "from" << GuhSettings::translationsPath(); + if (m_translator->load(locale, m_metaData.value("id").toString(), "-", NymeaSettings::translationsPath(), ".qm")) { + qCDebug(dcDeviceManager()) << "* Load translation" << locale.name() << "for" << pluginName() << "from" << NymeaSettings::translationsPath(); return true; } diff --git a/server/guhservice.cpp b/server/guhservice.cpp index 3c53c3f0..d8c3369d 100644 --- a/server/guhservice.cpp +++ b/server/guhservice.cpp @@ -37,7 +37,7 @@ #include #include "guhservice.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "loggingcategories.h" @@ -66,8 +66,8 @@ GuhService::~GuhService() void GuhService::start() { // check if config directory for logfile exists - if (!QDir().mkpath(GuhSettings::settingsPath())) { - fprintf(stdout, "Could not create guh settings directory %s", qPrintable(GuhSettings::settingsPath())); + if (!QDir().mkpath(NymeaSettings::settingsPath())) { + fprintf(stdout, "Could not create nymea settings directory %s", qPrintable(NymeaSettings::settingsPath())); exit(EXIT_FAILURE); } qCDebug(dcApplication) << "====================================="; diff --git a/server/main.cpp b/server/main.cpp index 117c3962..6882470d 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -37,7 +37,7 @@ #include "unistd.h" #include "guhcore.h" #include "guhservice.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "guhdbusservice.h" #include "guhapplication.h" #include "loggingcategories.h" @@ -149,8 +149,8 @@ int main(int argc, char *argv[]) QTranslator translator; // check if there are local translations if (!translator.load(QLocale::system(), application.applicationName(), "-", QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath(), ".qm")) - if (!translator.load(QLocale::system(), application.applicationName(), "-", GuhSettings::translationsPath(), ".qm")) - qWarning(dcApplication()) << "Could not find nymead translations for" << QLocale::system().name() << endl << (QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath()) << endl << GuhSettings::translationsPath(); + if (!translator.load(QLocale::system(), application.applicationName(), "-", NymeaSettings::translationsPath(), ".qm")) + qWarning(dcApplication()) << "Could not find nymead translations for" << QLocale::system().name() << endl << (QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath()) << endl << NymeaSettings::translationsPath(); @@ -252,8 +252,8 @@ int main(int argc, char *argv[]) int userId = getuid(); if (userId != 0) { // check if config directory for logfile exists - if (!QDir().mkpath(GuhSettings::settingsPath())) { - fprintf(stdout, "Could not create guh settings directory %s", qPrintable(GuhSettings::settingsPath())); + if (!QDir().mkpath(NymeaSettings::settingsPath())) { + fprintf(stdout, "Could not create nymea settings directory %s", qPrintable(NymeaSettings::settingsPath())); exit(EXIT_FAILURE); } qCDebug(dcApplication) << "====================================="; diff --git a/tests/auto/devices/testdevices.cpp b/tests/auto/devices/testdevices.cpp index 1530cbc1..3623fb57 100644 --- a/tests/auto/devices/testdevices.cpp +++ b/tests/auto/devices/testdevices.cpp @@ -22,7 +22,7 @@ #include "guhtestbase.h" #include "guhcore.h" #include "devicemanager.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "plugin/deviceplugin.h" #include @@ -1196,7 +1196,7 @@ void TestDevices::removeDevice() QFETCH(DeviceId, deviceId); QFETCH(DeviceManager::DeviceError, deviceError); - GuhSettings settings(GuhSettings::SettingsRoleDevices); + NymeaSettings settings(NymeaSettings::SettingsRoleDevices); settings.beginGroup("DeviceConfig"); if (deviceError == DeviceManager::DeviceErrorNoError) { settings.beginGroup(m_mockDeviceId.toString()); diff --git a/tests/auto/guhtestbase.cpp b/tests/auto/guhtestbase.cpp index a77db100..bb29e476 100644 --- a/tests/auto/guhtestbase.cpp +++ b/tests/auto/guhtestbase.cpp @@ -22,7 +22,7 @@ #include "guhtestbase.h" #include "mocktcpserver.h" #include "guhcore.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "devicemanager.h" #include "loggingcategories.h" #include "logging/logengine.h" @@ -130,18 +130,18 @@ void GuhTestBase::initTestCase() // If testcase asserts cleanup won't do. Lets clear any previous test run settings leftovers qDebug() << "Reset test settings"; - GuhSettings rulesSettings(GuhSettings::SettingsRoleRules); + NymeaSettings rulesSettings(NymeaSettings::SettingsRoleRules); rulesSettings.clear(); - GuhSettings deviceSettings(GuhSettings::SettingsRoleDevices); + NymeaSettings deviceSettings(NymeaSettings::SettingsRoleDevices); deviceSettings.clear(); - GuhSettings pluginSettings(GuhSettings::SettingsRolePlugins); + NymeaSettings pluginSettings(NymeaSettings::SettingsRolePlugins); pluginSettings.clear(); - GuhSettings statesSettings(GuhSettings::SettingsRoleDeviceStates); + NymeaSettings statesSettings(NymeaSettings::SettingsRoleDeviceStates); statesSettings.clear(); // Reset to default settings - GuhSettings guhdSettings(GuhSettings::SettingsRoleGlobal); - guhdSettings.clear(); + NymeaSettings nymeadSettings(NymeaSettings::SettingsRoleGlobal); + nymeadSettings.clear(); // debug categories // logging filers for core and libnymea diff --git a/tests/auto/logging/testlogging.cpp b/tests/auto/logging/testlogging.cpp index b0ca6ce6..dfe1bad0 100644 --- a/tests/auto/logging/testlogging.cpp +++ b/tests/auto/logging/testlogging.cpp @@ -22,7 +22,7 @@ #include "guhtestbase.h" #include "guhcore.h" #include "devicemanager.h" -#include "guhsettings.h" +#include "nymeasettings.h" #include "logging/logentry.h" #include "logging/logvaluetool.h" #include "plugin/deviceplugin.h" @@ -582,7 +582,7 @@ void TestLogging::testHouseKeeping() QVERIFY2(response.toMap().value("params").toMap().value("logEntries").toList().count() > 0, "Couldn't find state change event in log..."); // Manually delete this device from config - GuhSettings settings(GuhSettings::SettingsRoleDevices); + NymeaSettings settings(NymeaSettings::SettingsRoleDevices); settings.beginGroup("DeviceConfig"); settings.remove(deviceId.toString()); settings.endGroup(); diff --git a/tests/auto/loggingloading/testloggingloading.cpp b/tests/auto/loggingloading/testloggingloading.cpp index 896d6c7a..a886b802 100644 --- a/tests/auto/loggingloading/testloggingloading.cpp +++ b/tests/auto/loggingloading/testloggingloading.cpp @@ -58,14 +58,14 @@ void TestLoggingLoading::initTestCase() void TestLoggingLoading::testLogMigration() { // Create LogEngine with log db from resource file - QString temporaryDbName = GuhSettings::settingsPath() + "/guhd-v2.sqlite"; + QString temporaryDbName = NymeaSettings::settingsPath() + "/nymead-v2.sqlite"; if (QFile::exists(temporaryDbName)) QVERIFY(QFile(temporaryDbName).remove()); // Copy v2 log db from resources to default settings path and set permissions qDebug() << "Copy logdb v2 to" << temporaryDbName; - QVERIFY(QFile::copy(":/guhd-v2.sqlite", temporaryDbName)); + QVERIFY(QFile::copy(":/nymead-v2.sqlite", temporaryDbName)); QVERIFY(QFile::setPermissions(temporaryDbName, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther)); LogEngine *logEngine = new LogEngine(temporaryDbName, this); @@ -80,8 +80,8 @@ void TestLoggingLoading::testLogMigration() void TestLoggingLoading::testLogfileRotation() { // Create LogEngine with log db from resource file - QString temporaryDbName = GuhSettings::settingsPath() + "/guhd-broken.sqlite"; - QString rotatedDbName = GuhSettings::settingsPath() + "/guhd-broken.sqlite.1"; + QString temporaryDbName = NymeaSettings::settingsPath() + "/nymead-broken.sqlite"; + QString rotatedDbName = NymeaSettings::settingsPath() + "/nymead-broken.sqlite.1"; // Remove the files if there are some left if (QFile::exists(temporaryDbName)) @@ -92,7 +92,7 @@ void TestLoggingLoading::testLogfileRotation() // Copy broken log db from resources to default settings path and set permissions qDebug() << "Copy broken log db to" << temporaryDbName; - QVERIFY(QFile::copy(":/guhd-broken.sqlite", temporaryDbName)); + QVERIFY(QFile::copy(":/nymead-broken.sqlite", temporaryDbName)); QVERIFY(QFile::setPermissions(temporaryDbName, QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther)); QVERIFY(!QFile::exists(rotatedDbName)); diff --git a/tests/auto/restlogging/testrestlogging.cpp b/tests/auto/restlogging/testrestlogging.cpp index 522ed188..1bf9ec23 100644 --- a/tests/auto/restlogging/testrestlogging.cpp +++ b/tests/auto/restlogging/testrestlogging.cpp @@ -22,7 +22,6 @@ #include "guhtestbase.h" #include "guhcore.h" #include "devicemanager.h" -#include "guhsettings.h" #include "plugin/deviceplugin.h" #include diff --git a/tests/auto/rules/testrules.cpp b/tests/auto/rules/testrules.cpp index b82858dd..4d02edb0 100644 --- a/tests/auto/rules/testrules.cpp +++ b/tests/auto/rules/testrules.cpp @@ -2270,7 +2270,7 @@ void TestRules::testHousekeeping() } // Manually delete this device from config - GuhSettings settings(GuhSettings::SettingsRoleDevices); + NymeaSettings settings(NymeaSettings::SettingsRoleDevices); settings.beginGroup("DeviceConfig"); settings.remove(deviceId.toString()); settings.endGroup(); diff --git a/tests/auto/webserver/testwebserver.cpp b/tests/auto/webserver/testwebserver.cpp index ce14f16d..54f9961e 100644 --- a/tests/auto/webserver/testwebserver.cpp +++ b/tests/auto/webserver/testwebserver.cpp @@ -381,7 +381,7 @@ void TestWebserver::getFiles_data() QTest::newRow("get /../../etc/passwd") << "/../../etc/passwd" << 404; QTest::newRow("get /../../") << "/../../" << 403; QTest::newRow("get /../") << "/../" << 403; - QTest::newRow("get /etc/guh/guhd.conf") << "/etc/guh/guhd.conf" << 404; + QTest::newRow("get /etc/guh/nymead.conf") << "/etc/guh/nymead.conf" << 404; QTest::newRow("get /etc/sudoers") << "/etc/sudoers" << 404; QTest::newRow("get /root/.ssh/id_rsa.pub") << "/root/.ssh/id_rsa.pub" << 404; }