guhcore -> nymeacore

This commit is contained in:
Michael Zanetti 2018-01-30 09:55:57 +01:00
parent dca764fafd
commit 559a8be1f6
63 changed files with 565 additions and 569 deletions

View File

@ -18,7 +18,7 @@
* * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhcore.h" #include "nymeacore.h"
#include "httpreply.h" #include "httpreply.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "httprequest.h" #include "httprequest.h"
@ -44,7 +44,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
writer.writeProcessingInstruction("DOCUMENT", "html"); writer.writeProcessingInstruction("DOCUMENT", "html");
writer.writeComment("Auto generated html page from nymea server"); writer.writeComment("Auto generated html page from nymea server");
writer.writeStartElement("html"); writer.writeStartElement("html");
writer.writeAttribute("lang", GuhCore::instance()->configuration()->locale().name()); writer.writeAttribute("lang", NymeaCore::instance()->configuration()->locale().name());
// Head // Head
writer.writeStartElement("head"); writer.writeStartElement("head");
@ -183,7 +183,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
writer.writeStartElement("tr"); writer.writeStartElement("tr");
//: The server name description in the server infromation section of the debug interface //: The server name description in the server infromation section of the debug interface
writer.writeTextElement("th", QCoreApplication::translate("main", "Server name")); writer.writeTextElement("th", QCoreApplication::translate("main", "Server name"));
writer.writeTextElement("td", GuhCore::instance()->configuration()->serverName()); writer.writeTextElement("td", NymeaCore::instance()->configuration()->serverName());
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
writer.writeStartElement("tr"); writer.writeStartElement("tr");
@ -201,19 +201,19 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
writer.writeStartElement("tr"); writer.writeStartElement("tr");
//: The language description in the server infromation section of the debug interface //: The language description in the server infromation section of the debug interface
writer.writeTextElement("th", QCoreApplication::translate("main", "Language")); writer.writeTextElement("th", QCoreApplication::translate("main", "Language"));
writer.writeTextElement("td", GuhCore::instance()->configuration()->locale().name() + " (" + GuhCore::instance()->configuration()->locale().nativeCountryName() + " - " + GuhCore::instance()->configuration()->locale().nativeLanguageName() + ")"); writer.writeTextElement("td", NymeaCore::instance()->configuration()->locale().name() + " (" + NymeaCore::instance()->configuration()->locale().nativeCountryName() + " - " + NymeaCore::instance()->configuration()->locale().nativeLanguageName() + ")");
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
writer.writeStartElement("tr"); writer.writeStartElement("tr");
//: The timezone description in the server infromation section of the debug interface //: The timezone description in the server infromation section of the debug interface
writer.writeTextElement("th", QCoreApplication::translate("main", "Timezone")); writer.writeTextElement("th", QCoreApplication::translate("main", "Timezone"));
writer.writeTextElement("td", QString::fromUtf8(GuhCore::instance()->configuration()->timeZone())); writer.writeTextElement("td", QString::fromUtf8(NymeaCore::instance()->configuration()->timeZone()));
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
writer.writeStartElement("tr"); writer.writeStartElement("tr");
//: The server id description in the server infromation section of the debug interface //: The server id description in the server infromation section of the debug interface
writer.writeTextElement("th", QCoreApplication::translate("main", "Server UUID")); writer.writeTextElement("th", QCoreApplication::translate("main", "Server UUID"));
writer.writeTextElement("td", GuhCore::instance()->configuration()->serverUuid().toString()); writer.writeTextElement("td", NymeaCore::instance()->configuration()->serverUuid().toString());
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
writer.writeStartElement("tr"); writer.writeStartElement("tr");
@ -234,7 +234,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
writer.writeTextElement("td", NymeaSettings(NymeaSettings::SettingsRoleGlobal).logPath()); writer.writeTextElement("td", NymeaSettings(NymeaSettings::SettingsRoleGlobal).logPath());
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
for (int i = 0; i < GuhCore::instance()->deviceManager()->pluginSearchDirs().count(); i++) { for (int i = 0; i < NymeaCore::instance()->deviceManager()->pluginSearchDirs().count(); i++) {
writer.writeStartElement("tr"); writer.writeStartElement("tr");
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
@ -244,7 +244,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
} else { } else {
writer.writeTextElement("th", ""); writer.writeTextElement("th", "");
} }
writer.writeTextElement("td", QFileInfo(GuhCore::instance()->deviceManager()->pluginSearchDirs().at(i)).absoluteFilePath()); writer.writeTextElement("td", QFileInfo(NymeaCore::instance()->deviceManager()->pluginSearchDirs().at(i)).absoluteFilePath());
} }
writer.writeEndElement(); // table writer.writeEndElement(); // table
@ -517,7 +517,7 @@ QByteArray DebugServerHandler::createErrorXmlDocument(HttpReply::HttpStatusCode
writer.writeStartDocument("1.0"); writer.writeStartDocument("1.0");
writer.writeComment("Live generated html page from nymea"); writer.writeComment("Live generated html page from nymea");
writer.writeStartElement("html"); writer.writeStartElement("html");
writer.writeAttribute("lang", GuhCore::instance()->configuration()->locale().name()); writer.writeAttribute("lang", NymeaCore::instance()->configuration()->locale().name());
// Head // Head
writer.writeStartElement("head"); writer.writeStartElement("head");

View File

@ -20,6 +20,8 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhdbusservice.h" #include "guhdbusservice.h"
#include "usermanager.h"
#include "loggingcategories.h"
namespace guhserver { namespace guhserver {

View File

@ -24,10 +24,13 @@
#include <QObject> #include <QObject>
#include <QDBusConnection> #include <QDBusConnection>
#include "guhcore.h" #include <QDBusContext>
namespace guhserver { namespace guhserver {
class UserManager;
class GuhDBusService : public QObject, public QDBusContext class GuhDBusService : public QObject, public QDBusContext
{ {
Q_OBJECT Q_OBJECT

View File

@ -118,7 +118,7 @@ void UpnpDiscoveryImplementation::requestDeviceInformation(const QNetworkRequest
void UpnpDiscoveryImplementation::respondToSearchRequest(QHostAddress host, int port) 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... // TODO: Once DeviceManager (and with that this can be moved into the server, use NymeaCore's configuration manager instead of parsing the config here...
NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal); NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal);
globalSettings.beginGroup("nymead"); globalSettings.beginGroup("nymead");
QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray(); QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray();
@ -348,7 +348,7 @@ void UpnpDiscoveryImplementation::notificationTimeout()
void UpnpDiscoveryImplementation::sendByeByeMessage() 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... // TODO: Once DeviceManager (and with that this can be moved into the server, use NymeaCore's configuration manager instead of parsing the config here...
NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal); NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal);
globalSettings.beginGroup("nymead"); globalSettings.beginGroup("nymead");
QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray(); QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray();
@ -394,7 +394,7 @@ void UpnpDiscoveryImplementation::sendByeByeMessage()
void UpnpDiscoveryImplementation::sendAliveMessage() 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... // TODO: Once DeviceManager (and with that this) can be moved into the server, use NymeaCore's configuration manager instead of parsing the config here...
NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal); NymeaSettings globalSettings(NymeaSettings::SettingsRoleGlobal);
globalSettings.beginGroup("nymead"); globalSettings.beginGroup("nymead");
QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray(); QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray();

View File

@ -22,7 +22,7 @@
#include "plugintimermanagerimplementation.h" #include "plugintimermanagerimplementation.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
namespace guhserver { namespace guhserver {
@ -30,7 +30,7 @@ PluginTimerImplementation::PluginTimerImplementation(int intervall, QObject *par
PluginTimer(parent), PluginTimer(parent),
m_interval(intervall) m_interval(intervall)
{ {
connect(GuhCore::instance()->timeManager(), &TimeManager::tick, this, &PluginTimerImplementation::tick); connect(NymeaCore::instance()->timeManager(), &TimeManager::tick, this, &PluginTimerImplementation::tick);
} }
int PluginTimerImplementation::interval() const int PluginTimerImplementation::interval() const

View File

@ -133,7 +133,7 @@
#include "httpreply.h" #include "httpreply.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
#include <QDateTime> #include <QDateTime>
#include <QPair> #include <QPair>
@ -157,7 +157,7 @@ HttpReply::HttpReply(QObject *parent) :
// set known headers // set known headers
setHeader(HttpReply::ContentTypeHeader, "text/plain; charset=\"utf-8\";"); setHeader(HttpReply::ContentTypeHeader, "text/plain; charset=\"utf-8\";");
setHeader(HttpHeaderType::ServerHeader, "guh/" + QByteArray(NYMEA_VERSION_STRING)); setHeader(HttpHeaderType::ServerHeader, "guh/" + QByteArray(NYMEA_VERSION_STRING));
setHeader(HttpHeaderType::DateHeader, GuhCore::instance()->timeManager()->currentDateTime().toString("ddd, dd MMM yyyy hh:mm:ss").toUtf8()); setHeader(HttpHeaderType::DateHeader, NymeaCore::instance()->timeManager()->currentDateTime().toString("ddd, dd MMM yyyy hh:mm:ss").toUtf8());
setHeader(HttpHeaderType::CacheControlHeader, "no-cache"); setHeader(HttpHeaderType::CacheControlHeader, "no-cache");
setHeader(HttpHeaderType::ConnectionHeader, "Keep-Alive"); setHeader(HttpHeaderType::ConnectionHeader, "Keep-Alive");
setRawHeader("Access-Control-Allow-Origin","*"); setRawHeader("Access-Control-Allow-Origin","*");
@ -180,7 +180,7 @@ HttpReply::HttpReply(const HttpReply::HttpStatusCode &statusCode, const HttpRepl
// set known / default headers // set known / default headers
setHeader(HttpReply::ContentTypeHeader, "text/plain; charset=\"utf-8\";"); setHeader(HttpReply::ContentTypeHeader, "text/plain; charset=\"utf-8\";");
setHeader(HttpHeaderType::ServerHeader, "guh/" + QByteArray(NYMEA_VERSION_STRING)); setHeader(HttpHeaderType::ServerHeader, "guh/" + QByteArray(NYMEA_VERSION_STRING));
setHeader(HttpHeaderType::DateHeader, GuhCore::instance()->timeManager()->currentDateTime().toString("ddd, dd MMM yyyy hh:mm:ss").toUtf8()); setHeader(HttpHeaderType::DateHeader, NymeaCore::instance()->timeManager()->currentDateTime().toString("ddd, dd MMM yyyy hh:mm:ss").toUtf8());
setHeader(HttpHeaderType::CacheControlHeader, "no-cache"); setHeader(HttpHeaderType::CacheControlHeader, "no-cache");
setHeader(HttpHeaderType::ConnectionHeader, "Keep-Alive"); setHeader(HttpHeaderType::ConnectionHeader, "Keep-Alive");
setRawHeader("Access-Control-Allow-Origin","*"); setRawHeader("Access-Control-Allow-Origin","*");

View File

@ -34,7 +34,7 @@
#include "actionhandler.h" #include "actionhandler.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "types/action.h" #include "types/action.h"
#include "loggingcategories.h" #include "loggingcategories.h"
@ -62,7 +62,7 @@ ActionHandler::ActionHandler(QObject *parent) :
returns.insert("o:actionType", JsonTypes::actionTypeDescription()); returns.insert("o:actionType", JsonTypes::actionTypeDescription());
setReturns("GetActionType", returns); setReturns("GetActionType", returns);
connect(GuhCore::instance(), &GuhCore::actionExecuted, this, &ActionHandler::actionExecuted); connect(NymeaCore::instance(), &NymeaCore::actionExecuted, this, &ActionHandler::actionExecuted);
} }
/*! Returns the name of the \l{ActionHandler}. In this case \b Actions.*/ /*! Returns the name of the \l{ActionHandler}. In this case \b Actions.*/
@ -80,7 +80,7 @@ JsonReply* ActionHandler::ExecuteAction(const QVariantMap &params)
Action action(actionTypeId, deviceId); Action action(actionTypeId, deviceId);
action.setParams(actionParams); action.setParams(actionParams);
DeviceManager::DeviceError status = GuhCore::instance()->executeAction(action); DeviceManager::DeviceError status = NymeaCore::instance()->executeAction(action);
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {
JsonReply *reply = createAsyncReply("ExecuteAction"); JsonReply *reply = createAsyncReply("ExecuteAction");
ActionId id = action.id(); ActionId id = action.id();
@ -96,7 +96,7 @@ JsonReply *ActionHandler::GetActionType(const QVariantMap &params) const
{ {
qCDebug(dcJsonRpc) << "asked for action type" << params; qCDebug(dcJsonRpc) << "asked for action type" << params;
ActionTypeId actionTypeId(params.value("actionTypeId").toString()); ActionTypeId actionTypeId(params.value("actionTypeId").toString());
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) { foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices()) {
foreach (const ActionType &actionType, deviceClass.actionTypes()) { foreach (const ActionType &actionType, deviceClass.actionTypes()) {
if (actionType.id() == actionTypeId) { if (actionType.id() == actionTypeId) {
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError); QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);

View File

@ -59,7 +59,7 @@
#include "configurationhandler.h" #include "configurationhandler.h"
#include "guhcore.h" #include "nymeacore.h"
namespace guhserver { namespace guhserver {
@ -220,15 +220,15 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent):
params.insert("enabled", JsonTypes::basicTypeToString(JsonTypes::Bool)); params.insert("enabled", JsonTypes::basicTypeToString(JsonTypes::Bool));
setParams("CloudConfigurationChanged", params); setParams("CloudConfigurationChanged", params);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::serverNameChanged, this, &ConfigurationHandler::onBasicConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::serverNameChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::timeZoneChanged, this, &ConfigurationHandler::onBasicConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::timeZoneChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::localeChanged, this, &ConfigurationHandler::onBasicConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::localeChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::debugServerEnabledChanged, this, &ConfigurationHandler::onBasicConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::debugServerEnabledChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::tcpServerConfigurationChanged, this, &ConfigurationHandler::onTcpServerConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::tcpServerConfigurationChanged, this, &ConfigurationHandler::onTcpServerConfigurationChanged);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::webServerConfigurationChanged, this, &ConfigurationHandler::onWebServerConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::webServerConfigurationChanged, this, &ConfigurationHandler::onWebServerConfigurationChanged);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::webSocketServerConfigurationChanged, this, &ConfigurationHandler::onWebSocketServerConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::webSocketServerConfigurationChanged, this, &ConfigurationHandler::onWebSocketServerConfigurationChanged);
connect(GuhCore::instance()->configuration(), &GuhConfiguration::cloudEnabledChanged, this, &ConfigurationHandler::onCloudConfigurationChanged); connect(NymeaCore::instance()->configuration(), &GuhConfiguration::cloudEnabledChanged, this, &ConfigurationHandler::onCloudConfigurationChanged);
connect(GuhCore::instance()->deviceManager(), &DeviceManager::languageUpdated, this, &ConfigurationHandler::onLanguageChanged); connect(NymeaCore::instance()->deviceManager(), &DeviceManager::languageUpdated, this, &ConfigurationHandler::onLanguageChanged);
} }
/*! Returns the name of the \l{ConfigurationHandler}. In this case \b Configuration.*/ /*! Returns the name of the \l{ConfigurationHandler}. In this case \b Configuration.*/
@ -243,26 +243,26 @@ JsonReply *ConfigurationHandler::GetConfigurations(const QVariantMap &params) co
QVariantMap returns; QVariantMap returns;
returns.insert("basicConfiguration", JsonTypes::packBasicConfiguration()); returns.insert("basicConfiguration", JsonTypes::packBasicConfiguration());
QVariantList tcpServerConfigs; QVariantList tcpServerConfigs;
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->tcpServerConfigurations()) { foreach (const ServerConfiguration &config, NymeaCore::instance()->configuration()->tcpServerConfigurations()) {
tcpServerConfigs.append(JsonTypes::packServerConfiguration(config)); tcpServerConfigs.append(JsonTypes::packServerConfiguration(config));
} }
returns.insert("tcpServerConfigurations", tcpServerConfigs); returns.insert("tcpServerConfigurations", tcpServerConfigs);
QVariantList webServerConfigs; QVariantList webServerConfigs;
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
webServerConfigs.append(JsonTypes::packWebServerConfiguration(config)); webServerConfigs.append(JsonTypes::packWebServerConfiguration(config));
} }
returns.insert("webServerConfigurations", webServerConfigs); returns.insert("webServerConfigurations", webServerConfigs);
QVariantList webSocketServerConfigs; QVariantList webSocketServerConfigs;
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->webSocketServerConfigurations()) { foreach (const ServerConfiguration &config, NymeaCore::instance()->configuration()->webSocketServerConfigurations()) {
webSocketServerConfigs.append(JsonTypes::packServerConfiguration(config)); webSocketServerConfigs.append(JsonTypes::packServerConfiguration(config));
} }
returns.insert("webSocketServerConfigurations", webSocketServerConfigs); returns.insert("webSocketServerConfigurations", webSocketServerConfigs);
QVariantMap cloudConfig; QVariantMap cloudConfig;
cloudConfig.insert("enabled", GuhCore::instance()->configuration()->cloudEnabled()); cloudConfig.insert("enabled", NymeaCore::instance()->configuration()->cloudEnabled());
returns.insert("cloud", cloudConfig); returns.insert("cloud", cloudConfig);
return createReply(returns); return createReply(returns);
@ -272,7 +272,7 @@ JsonReply *ConfigurationHandler::GetTimeZones(const QVariantMap &params) const
{ {
Q_UNUSED(params) Q_UNUSED(params)
QVariantList timeZones; QVariantList timeZones;
foreach (const QByteArray &timeZoneId, GuhCore::instance()->timeManager()->availableTimeZones()) { foreach (const QByteArray &timeZoneId, NymeaCore::instance()->timeManager()->availableTimeZones()) {
timeZones.append(QString::fromUtf8(timeZoneId)); timeZones.append(QString::fromUtf8(timeZoneId));
} }
@ -285,7 +285,7 @@ JsonReply *ConfigurationHandler::GetAvailableLanguages(const QVariantMap &params
{ {
Q_UNUSED(params) Q_UNUSED(params)
QVariantList languages; QVariantList languages;
foreach (const QString &language, GuhCore::getAvailableLanguages()) { foreach (const QString &language, NymeaCore::getAvailableLanguages()) {
languages.append(language); languages.append(language);
} }
QVariantMap returns; QVariantMap returns;
@ -296,7 +296,7 @@ JsonReply *ConfigurationHandler::GetAvailableLanguages(const QVariantMap &params
JsonReply *ConfigurationHandler::SetServerName(const QVariantMap &params) const JsonReply *ConfigurationHandler::SetServerName(const QVariantMap &params) const
{ {
QString serverName = params.value("serverName").toString(); QString serverName = params.value("serverName").toString();
GuhCore::instance()->configuration()->setServerName(serverName); NymeaCore::instance()->configuration()->setServerName(serverName);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
@ -305,10 +305,10 @@ JsonReply *ConfigurationHandler::SetTimeZone(const QVariantMap &params) const
qCDebug(dcJsonRpc()) << "Setting time zone to" << params.value("timeZone").toString(); qCDebug(dcJsonRpc()) << "Setting time zone to" << params.value("timeZone").toString();
QByteArray timeZone = params.value("timeZone").toString().toUtf8(); QByteArray timeZone = params.value("timeZone").toString().toUtf8();
if (!GuhCore::instance()->timeManager()->setTimeZone(timeZone)) if (!NymeaCore::instance()->timeManager()->setTimeZone(timeZone))
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidTimeZone)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidTimeZone));
GuhCore::instance()->configuration()->setTimeZone(timeZone); NymeaCore::instance()->configuration()->setTimeZone(timeZone);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
@ -317,7 +317,7 @@ JsonReply *ConfigurationHandler::SetLanguage(const QVariantMap &params) const
qCDebug(dcJsonRpc()) << "Setting language to" << params.value("language").toString(); qCDebug(dcJsonRpc()) << "Setting language to" << params.value("language").toString();
QLocale locale(params.value("language").toString()); QLocale locale(params.value("language").toString());
GuhCore::instance()->configuration()->setLocale(locale); NymeaCore::instance()->configuration()->setLocale(locale);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
@ -338,20 +338,17 @@ JsonReply *ConfigurationHandler::SetTcpServerConfiguration(const QVariantMap &pa
qCDebug(dcJsonRpc()) << QString("Configure TCP server %1:%2").arg(config.address.toString()).arg(config.port); qCDebug(dcJsonRpc()) << QString("Configure TCP server %1:%2").arg(config.address.toString()).arg(config.port);
GuhCore::instance()->configuration()->setTcpServerConfiguration(config); NymeaCore::instance()->configuration()->setTcpServerConfiguration(config);
// GuhCore::instance()->tcpServer()->reconfigureServer(config);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
JsonReply *ConfigurationHandler::DeleteTcpServerConfiguration(const QVariantMap &params) const JsonReply *ConfigurationHandler::DeleteTcpServerConfiguration(const QVariantMap &params) const
{ {
QString id = params.value("id").toString(); QString id = params.value("id").toString();
if (id.isEmpty() || !GuhCore::instance()->configuration()->tcpServerConfigurations().contains(id)) { if (id.isEmpty() || !NymeaCore::instance()->configuration()->tcpServerConfigurations().contains(id)) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
} }
GuhCore::instance()->configuration()->removeTcpServerConfiguration(id); NymeaCore::instance()->configuration()->removeTcpServerConfiguration(id);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
@ -372,19 +369,17 @@ JsonReply *ConfigurationHandler::SetWebServerConfiguration(const QVariantMap &pa
qCDebug(dcJsonRpc()) << QString("Configure web server %1:%2").arg(config.address.toString()).arg(config.port); qCDebug(dcJsonRpc()) << QString("Configure web server %1:%2").arg(config.address.toString()).arg(config.port);
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
// GuhCore::instance()->webServer()->reconfigureServer(config);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
JsonReply *ConfigurationHandler::DeleteWebServerConfiguration(const QVariantMap &params) const JsonReply *ConfigurationHandler::DeleteWebServerConfiguration(const QVariantMap &params) const
{ {
QString id = params.value("id").toString(); QString id = params.value("id").toString();
if (id.isEmpty() || !GuhCore::instance()->configuration()->webServerConfigurations().contains(id)) { if (id.isEmpty() || !NymeaCore::instance()->configuration()->webServerConfigurations().contains(id)) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
} }
GuhCore::instance()->configuration()->removeWebServerConfiguration(id); NymeaCore::instance()->configuration()->removeWebServerConfiguration(id);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
@ -404,7 +399,7 @@ JsonReply *ConfigurationHandler::SetWebSocketServerConfiguration(const QVariantM
qCDebug(dcJsonRpc()) << QString("Configure web socket server %1:%2").arg(config.address.toString()).arg(config.port); qCDebug(dcJsonRpc()) << QString("Configure web socket server %1:%2").arg(config.address.toString()).arg(config.port);
GuhCore::instance()->configuration()->setWebSocketServerConfiguration(config); NymeaCore::instance()->configuration()->setWebSocketServerConfiguration(config);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
@ -412,24 +407,24 @@ JsonReply *ConfigurationHandler::SetWebSocketServerConfiguration(const QVariantM
JsonReply *ConfigurationHandler::DeleteWebSocketServerConfiguration(const QVariantMap &params) const JsonReply *ConfigurationHandler::DeleteWebSocketServerConfiguration(const QVariantMap &params) const
{ {
QString id = params.value("id").toString(); QString id = params.value("id").toString();
if (id.isEmpty() || !GuhCore::instance()->configuration()->webSocketServerConfigurations().contains(id)) { if (id.isEmpty() || !NymeaCore::instance()->configuration()->webSocketServerConfigurations().contains(id)) {
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidId));
} }
GuhCore::instance()->configuration()->removeWebSocketServerConfiguration(id); NymeaCore::instance()->configuration()->removeWebSocketServerConfiguration(id);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
JsonReply *ConfigurationHandler::SetCloudEnabled(const QVariantMap &params) const JsonReply *ConfigurationHandler::SetCloudEnabled(const QVariantMap &params) const
{ {
bool enabled = params.value("enabled").toBool(); bool enabled = params.value("enabled").toBool();
GuhCore::instance()->configuration()->setCloudEnabled(enabled); NymeaCore::instance()->configuration()->setCloudEnabled(enabled);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
JsonReply *ConfigurationHandler::SetDebugServerEnabled(const QVariantMap &params) const JsonReply *ConfigurationHandler::SetDebugServerEnabled(const QVariantMap &params) const
{ {
bool enabled = params.value("enabled").toBool(); bool enabled = params.value("enabled").toBool();
GuhCore::instance()->configuration()->setDebugServerEnabled(enabled); NymeaCore::instance()->configuration()->setDebugServerEnabled(enabled);
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
} }
@ -445,7 +440,7 @@ void ConfigurationHandler::onTcpServerConfigurationChanged(const QString &id)
{ {
QVariantMap params; QVariantMap params;
qCDebug(dcJsonRpc()) << "Notification: TCP server configuration changed"; qCDebug(dcJsonRpc()) << "Notification: TCP server configuration changed";
params.insert("tcpServerConfiguration", JsonTypes::packServerConfiguration(GuhCore::instance()->configuration()->tcpServerConfigurations().value(id))); params.insert("tcpServerConfiguration", JsonTypes::packServerConfiguration(NymeaCore::instance()->configuration()->tcpServerConfigurations().value(id)));
emit TcpServerConfigurationChanged(params); emit TcpServerConfigurationChanged(params);
} }
@ -453,7 +448,7 @@ void ConfigurationHandler::onWebServerConfigurationChanged(const QString &id)
{ {
QVariantMap params; QVariantMap params;
qCDebug(dcJsonRpc()) << "Notification: web server configuration changed"; qCDebug(dcJsonRpc()) << "Notification: web server configuration changed";
params.insert("webServerConfiguration", JsonTypes::packWebServerConfiguration(GuhCore::instance()->configuration()->webServerConfigurations().value(id))); params.insert("webServerConfiguration", JsonTypes::packWebServerConfiguration(NymeaCore::instance()->configuration()->webServerConfigurations().value(id)));
emit WebServerConfigurationChanged(params); emit WebServerConfigurationChanged(params);
} }
@ -461,7 +456,7 @@ void ConfigurationHandler::onWebSocketServerConfigurationChanged(const QString &
{ {
QVariantMap params; QVariantMap params;
qCDebug(dcJsonRpc()) << "Notification: web socket server configuration changed"; qCDebug(dcJsonRpc()) << "Notification: web socket server configuration changed";
params.insert("webSocketServerConfiguration", JsonTypes::packServerConfiguration(GuhCore::instance()->configuration()->webSocketServerConfigurations().value(id))); params.insert("webSocketServerConfiguration", JsonTypes::packServerConfiguration(NymeaCore::instance()->configuration()->webSocketServerConfigurations().value(id)));
emit WebSocketServerConfigurationChanged(params); emit WebSocketServerConfigurationChanged(params);
} }
@ -479,7 +474,7 @@ void ConfigurationHandler::onLanguageChanged()
{ {
QVariantMap params; QVariantMap params;
qCDebug(dcJsonRpc()) << "Notification: language configuration changed"; qCDebug(dcJsonRpc()) << "Notification: language configuration changed";
params.insert("language", GuhCore::instance()->configuration()->locale().name()); params.insert("language", NymeaCore::instance()->configuration()->locale().name());
emit LanguageChanged(params); emit LanguageChanged(params);
} }

View File

@ -54,7 +54,7 @@
*/ */
#include "devicehandler.h" #include "devicehandler.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "types/deviceclass.h" #include "types/deviceclass.h"
@ -292,15 +292,15 @@ DeviceHandler::DeviceHandler(QObject *parent) :
params.insert("device", JsonTypes::deviceRef()); params.insert("device", JsonTypes::deviceRef());
setParams("DeviceChanged", params); setParams("DeviceChanged", params);
connect(GuhCore::instance(), &GuhCore::pluginConfigChanged, this, &DeviceHandler::pluginConfigChanged); connect(NymeaCore::instance(), &NymeaCore::pluginConfigChanged, this, &DeviceHandler::pluginConfigChanged);
connect(GuhCore::instance(), &GuhCore::deviceStateChanged, this, &DeviceHandler::deviceStateChanged); connect(NymeaCore::instance(), &NymeaCore::deviceStateChanged, this, &DeviceHandler::deviceStateChanged);
connect(GuhCore::instance(), &GuhCore::deviceRemoved, this, &DeviceHandler::deviceRemovedNotification); connect(NymeaCore::instance(), &NymeaCore::deviceRemoved, this, &DeviceHandler::deviceRemovedNotification);
connect(GuhCore::instance(), &GuhCore::deviceAdded, this, &DeviceHandler::deviceAddedNotification); connect(NymeaCore::instance(), &NymeaCore::deviceAdded, this, &DeviceHandler::deviceAddedNotification);
connect(GuhCore::instance(), &GuhCore::deviceChanged, this, &DeviceHandler::deviceChangedNotification); connect(NymeaCore::instance(), &NymeaCore::deviceChanged, this, &DeviceHandler::deviceChangedNotification);
connect(GuhCore::instance(), &GuhCore::devicesDiscovered, this, &DeviceHandler::devicesDiscovered, Qt::QueuedConnection); connect(NymeaCore::instance(), &NymeaCore::devicesDiscovered, this, &DeviceHandler::devicesDiscovered, Qt::QueuedConnection);
connect(GuhCore::instance(), &GuhCore::deviceSetupFinished, this, &DeviceHandler::deviceSetupFinished); connect(NymeaCore::instance(), &NymeaCore::deviceSetupFinished, this, &DeviceHandler::deviceSetupFinished);
connect(GuhCore::instance(), &GuhCore::deviceReconfigurationFinished, this, &DeviceHandler::deviceReconfigurationFinished); connect(NymeaCore::instance(), &NymeaCore::deviceReconfigurationFinished, this, &DeviceHandler::deviceReconfigurationFinished);
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DeviceHandler::pairingFinished); connect(NymeaCore::instance(), &NymeaCore::pairingFinished, this, &DeviceHandler::pairingFinished);
} }
/*! Returns the name of the \l{DeviceHandler}. In this case \b Devices.*/ /*! Returns the name of the \l{DeviceHandler}. In this case \b Devices.*/
@ -333,7 +333,7 @@ JsonReply *DeviceHandler::GetDiscoveredDevices(const QVariantMap &params) const
ParamList discoveryParams = JsonTypes::unpackParams(params.value("discoveryParams").toList()); ParamList discoveryParams = JsonTypes::unpackParams(params.value("discoveryParams").toList());
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(deviceClassId, discoveryParams); DeviceManager::DeviceError status = NymeaCore::instance()->deviceManager()->discoverDevices(deviceClassId, discoveryParams);
if (status == DeviceManager::DeviceErrorAsync ) { if (status == DeviceManager::DeviceErrorAsync ) {
JsonReply *reply = createAsyncReply("GetDiscoveredDevices"); JsonReply *reply = createAsyncReply("GetDiscoveredDevices");
connect(reply, &JsonReply::finished, [this, deviceClassId](){ m_discoverRequests.remove(deviceClassId); }); connect(reply, &JsonReply::finished, [this, deviceClassId](){ m_discoverRequests.remove(deviceClassId); });
@ -357,7 +357,7 @@ JsonReply *DeviceHandler::GetPluginConfiguration(const QVariantMap &params) cons
{ {
QVariantMap returns; QVariantMap returns;
DevicePlugin *plugin = GuhCore::instance()->deviceManager()->plugin(PluginId(params.value("pluginId").toString())); DevicePlugin *plugin = NymeaCore::instance()->deviceManager()->plugin(PluginId(params.value("pluginId").toString()));
if (!plugin) { if (!plugin) {
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorPluginNotFound)); returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorPluginNotFound));
return createReply(returns); return createReply(returns);
@ -377,7 +377,7 @@ JsonReply* DeviceHandler::SetPluginConfiguration(const QVariantMap &params)
QVariantMap returns; QVariantMap returns;
PluginId pluginId = PluginId(params.value("pluginId").toString()); PluginId pluginId = PluginId(params.value("pluginId").toString());
ParamList pluginParams = JsonTypes::unpackParams(params.value("configuration").toList()); ParamList pluginParams = JsonTypes::unpackParams(params.value("configuration").toList());
DeviceManager::DeviceError result = GuhCore::instance()->deviceManager()->setPluginConfig(pluginId, pluginParams); DeviceManager::DeviceError result = NymeaCore::instance()->deviceManager()->setPluginConfig(pluginId, pluginParams);
returns.insert("deviceError", JsonTypes::deviceErrorToString(result)); returns.insert("deviceError", JsonTypes::deviceErrorToString(result));
return createReply(returns); return createReply(returns);
} }
@ -391,9 +391,9 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap &params)
DeviceId newDeviceId = DeviceId::createDeviceId(); DeviceId newDeviceId = DeviceId::createDeviceId();
DeviceManager::DeviceError status; DeviceManager::DeviceError status;
if (deviceDescriptorId.isNull()) { if (deviceDescriptorId.isNull()) {
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceParams, newDeviceId); status = NymeaCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceParams, newDeviceId);
} else { } else {
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceDescriptorId, newDeviceId); status = NymeaCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceDescriptorId, newDeviceId);
} }
QVariantMap returns; QVariantMap returns;
switch (status) { switch (status) {
@ -417,16 +417,16 @@ JsonReply *DeviceHandler::PairDevice(const QVariantMap &params)
{ {
DeviceClassId deviceClassId(params.value("deviceClassId").toString()); DeviceClassId deviceClassId(params.value("deviceClassId").toString());
QString deviceName = params.value("name").toString(); QString deviceName = params.value("name").toString();
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
DeviceManager::DeviceError status; DeviceManager::DeviceError status;
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId(); PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
if (params.contains("deviceDescriptorId")) { if (params.contains("deviceDescriptorId")) {
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString()); DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceDescriptorId); status = NymeaCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceDescriptorId);
} else { } else {
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList()); ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceParams); status = NymeaCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceParams);
} }
QVariantMap returns; QVariantMap returns;
@ -443,7 +443,7 @@ JsonReply *DeviceHandler::ConfirmPairing(const QVariantMap &params)
{ {
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString()); PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString());
QString secret = params.value("secret").toString(); QString secret = params.value("secret").toString();
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->confirmPairing(pairingTransactionId, secret); DeviceManager::DeviceError status = NymeaCore::instance()->deviceManager()->confirmPairing(pairingTransactionId, secret);
JsonReply *reply = 0; JsonReply *reply = 0;
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {
@ -463,7 +463,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap &params) const
QVariantMap returns; QVariantMap returns;
QVariantList configuredDeviceList; QVariantList configuredDeviceList;
if (params.contains("deviceId")) { if (params.contains("deviceId")) {
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString())); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString()));
if (!device) { if (!device) {
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound)); returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
return createReply(returns); return createReply(returns);
@ -471,7 +471,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap &params) const
configuredDeviceList.append(JsonTypes::packDevice(device)); configuredDeviceList.append(JsonTypes::packDevice(device));
} }
} else { } else {
foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) { foreach (Device *device, NymeaCore::instance()->deviceManager()->configuredDevices()) {
configuredDeviceList.append(JsonTypes::packDevice(device)); configuredDeviceList.append(JsonTypes::packDevice(device));
} }
} }
@ -488,9 +488,9 @@ JsonReply *DeviceHandler::ReconfigureDevice(const QVariantMap &params)
DeviceManager::DeviceError status; DeviceManager::DeviceError status;
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString()); DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
if (deviceDescriptorId.isNull()) { if (deviceDescriptorId.isNull()) {
status = GuhCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceParams); status = NymeaCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceParams);
} else { } else {
status = GuhCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceDescriptorId); status = NymeaCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceDescriptorId);
} }
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {
@ -512,7 +512,7 @@ JsonReply *DeviceHandler::EditDevice(const QVariantMap &params)
qCDebug(dcJsonRpc()) << "Edit device" << deviceId << name; qCDebug(dcJsonRpc()) << "Edit device" << deviceId << name;
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->editDevice(deviceId, name); DeviceManager::DeviceError status = NymeaCore::instance()->deviceManager()->editDevice(deviceId, name);
QVariantMap returns; QVariantMap returns;
returns.insert("deviceError", JsonTypes::deviceErrorToString(status)); returns.insert("deviceError", JsonTypes::deviceErrorToString(status));
@ -527,7 +527,7 @@ JsonReply* DeviceHandler::RemoveConfiguredDevice(const QVariantMap &params)
// global removePolicy has priority // global removePolicy has priority
if (params.contains("removePolicy")) { if (params.contains("removePolicy")) {
RuleEngine::RemovePolicy removePolicy = params.value("removePolicy").toString() == "RemovePolicyCascade" ? RuleEngine::RemovePolicyCascade : RuleEngine::RemovePolicyUpdate; RuleEngine::RemovePolicy removePolicy = params.value("removePolicy").toString() == "RemovePolicyCascade" ? RuleEngine::RemovePolicyCascade : RuleEngine::RemovePolicyUpdate;
DeviceManager::DeviceError status = GuhCore::instance()->removeConfiguredDevice(deviceId, removePolicy); DeviceManager::DeviceError status = NymeaCore::instance()->removeConfiguredDevice(deviceId, removePolicy);
returns.insert("deviceError", JsonTypes::deviceErrorToString(status)); returns.insert("deviceError", JsonTypes::deviceErrorToString(status));
return createReply(returns); return createReply(returns);
} }
@ -539,7 +539,7 @@ JsonReply* DeviceHandler::RemoveConfiguredDevice(const QVariantMap &params)
removePolicyList.insert(ruleId, policy); removePolicyList.insert(ruleId, policy);
} }
QPair<DeviceManager::DeviceError, QList<RuleId> > status = GuhCore::instance()->removeConfiguredDevice(deviceId, removePolicyList); QPair<DeviceManager::DeviceError, QList<RuleId> > status = NymeaCore::instance()->removeConfiguredDevice(deviceId, removePolicyList);
returns.insert("deviceError", JsonTypes::deviceErrorToString(status.first)); returns.insert("deviceError", JsonTypes::deviceErrorToString(status.first));
if (!status.second.isEmpty()) { if (!status.second.isEmpty()) {
@ -558,7 +558,7 @@ JsonReply* DeviceHandler::GetEventTypes(const QVariantMap &params) const
QVariantMap returns; QVariantMap returns;
QVariantList eventList; QVariantList eventList;
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
foreach (const EventType &eventType, deviceClass.eventTypes()) { foreach (const EventType &eventType, deviceClass.eventTypes()) {
eventList.append(JsonTypes::packEventType(eventType)); eventList.append(JsonTypes::packEventType(eventType));
} }
@ -571,7 +571,7 @@ JsonReply* DeviceHandler::GetActionTypes(const QVariantMap &params) const
QVariantMap returns; QVariantMap returns;
QVariantList actionList; QVariantList actionList;
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
foreach (const ActionType &actionType, deviceClass.actionTypes()) { foreach (const ActionType &actionType, deviceClass.actionTypes()) {
actionList.append(JsonTypes::packActionType(actionType)); actionList.append(JsonTypes::packActionType(actionType));
} }
@ -584,7 +584,7 @@ JsonReply* DeviceHandler::GetStateTypes(const QVariantMap &params) const
QVariantMap returns; QVariantMap returns;
QVariantList stateList; QVariantList stateList;
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString())); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(DeviceClassId(params.value("deviceClassId").toString()));
foreach (const StateType &stateType, deviceClass.stateTypes()) { foreach (const StateType &stateType, deviceClass.stateTypes()) {
stateList.append(JsonTypes::packStateType(stateType)); stateList.append(JsonTypes::packStateType(stateType));
} }
@ -596,7 +596,7 @@ JsonReply* DeviceHandler::GetStateValue(const QVariantMap &params) const
{ {
QVariantMap returns; QVariantMap returns;
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString())); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString()));
if (!device) { if (!device) {
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound)); returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
return createReply(returns); return createReply(returns);
@ -616,7 +616,7 @@ JsonReply *DeviceHandler::GetStateValues(const QVariantMap &params) const
{ {
QVariantMap returns; QVariantMap returns;
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString())); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(DeviceId(params.value("deviceId").toString()));
if (!device) { if (!device) {
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound)); returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
return createReply(returns); return createReply(returns);

View File

@ -38,7 +38,7 @@
*/ */
#include "eventhandler.h" #include "eventhandler.h"
#include "guhcore.h" #include "nymeacore.h"
#include "loggingcategories.h" #include "loggingcategories.h"
namespace guhserver { namespace guhserver {
@ -64,7 +64,7 @@ EventHandler::EventHandler(QObject *parent) :
returns.insert("o:eventType", JsonTypes::eventTypeRef()); returns.insert("o:eventType", JsonTypes::eventTypeRef());
setReturns("GetEventType", returns); setReturns("GetEventType", returns);
connect(GuhCore::instance(), &GuhCore::eventTriggered, this, &EventHandler::eventTriggered); connect(NymeaCore::instance(), &NymeaCore::eventTriggered, this, &EventHandler::eventTriggered);
} }
/*! Returns the name of the \l{EventHandler}. In this case \b Events.*/ /*! Returns the name of the \l{EventHandler}. In this case \b Events.*/
@ -84,7 +84,7 @@ JsonReply* EventHandler::GetEventType(const QVariantMap &params) const
{ {
qCDebug(dcJsonRpc) << "asked for event type" << params; qCDebug(dcJsonRpc) << "asked for event type" << params;
EventTypeId eventTypeId(params.value("eventTypeId").toString()); EventTypeId eventTypeId(params.value("eventTypeId").toString());
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) { foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices()) {
foreach (const EventType &eventType, deviceClass.eventTypes()) { foreach (const EventType &eventType, deviceClass.eventTypes()) {
if (eventType.id() == eventTypeId) { if (eventType.id() == eventTypeId) {
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError); QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);

View File

@ -39,7 +39,7 @@
#include "jsonrpcserver.h" #include "jsonrpcserver.h"
#include "jsontypes.h" #include "jsontypes.h"
#include "jsonhandler.h" #include "jsonhandler.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "plugin/deviceplugin.h" #include "plugin/deviceplugin.h"
#include "types/deviceclass.h" #include "types/deviceclass.h"
@ -201,7 +201,7 @@ JsonRPCServer::JsonRPCServer(const QSslConfiguration &sslConfiguration, QObject
QMetaObject::invokeMethod(this, "setup", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "setup", Qt::QueuedConnection);
connect(GuhCore::instance()->userManager(), &UserManager::pushButtonAuthFinished, this, &JsonRPCServer::onPushButtonAuthFinished); connect(NymeaCore::instance()->userManager(), &UserManager::pushButtonAuthFinished, this, &JsonRPCServer::onPushButtonAuthFinished);
} }
/*! Returns the \e namespace of \l{JsonHandler}. */ /*! Returns the \e namespace of \l{JsonHandler}. */
@ -262,7 +262,7 @@ JsonReply *JsonRPCServer::CreateUser(const QVariantMap &params)
QString username = params.value("username").toString(); QString username = params.value("username").toString();
QString password = params.value("password").toString(); QString password = params.value("password").toString();
UserManager::UserError status = GuhCore::instance()->userManager()->createUser(username, password); UserManager::UserError status = NymeaCore::instance()->userManager()->createUser(username, password);
QVariantMap returns; QVariantMap returns;
returns.insert("error", JsonTypes::userErrorToString(status)); returns.insert("error", JsonTypes::userErrorToString(status));
@ -275,7 +275,7 @@ JsonReply *JsonRPCServer::Authenticate(const QVariantMap &params)
QString password = params.value("password").toString(); QString password = params.value("password").toString();
QString deviceName = params.value("deviceName").toString(); QString deviceName = params.value("deviceName").toString();
QByteArray token = GuhCore::instance()->userManager()->authenticate(username, password, deviceName); QByteArray token = NymeaCore::instance()->userManager()->authenticate(username, password, deviceName);
QVariantMap ret; QVariantMap ret;
ret.insert("success", !token.isEmpty()); ret.insert("success", !token.isEmpty());
if (!token.isEmpty()) { if (!token.isEmpty()) {
@ -289,7 +289,7 @@ JsonReply *JsonRPCServer::RequestPushButtonAuth(const QVariantMap &params)
QString deviceName = params.value("deviceName").toString(); QString deviceName = params.value("deviceName").toString();
QUuid clientId = this->property("clientId").toUuid(); QUuid clientId = this->property("clientId").toUuid();
int transactionId = GuhCore::instance()->userManager()->requestPushButtonAuth(deviceName); int transactionId = NymeaCore::instance()->userManager()->requestPushButtonAuth(deviceName);
m_pushButtonTransactions.insert(transactionId, clientId); m_pushButtonTransactions.insert(transactionId, clientId);
QVariantMap data; QVariantMap data;
@ -304,12 +304,12 @@ JsonReply *JsonRPCServer::Tokens(const QVariantMap &params) const
Q_UNUSED(params) Q_UNUSED(params)
QByteArray token = property("token").toByteArray(); QByteArray token = property("token").toByteArray();
QString username = GuhCore::instance()->userManager()->userForToken(token); QString username = NymeaCore::instance()->userManager()->userForToken(token);
if (username.isEmpty()) { if (username.isEmpty()) {
// There *really* should be a user for the token in the DB // There *really* should be a user for the token in the DB
Q_ASSERT(false); Q_ASSERT(false);
} }
QList<TokenInfo> tokens = GuhCore::instance()->userManager()->tokens(username); QList<TokenInfo> tokens = NymeaCore::instance()->userManager()->tokens(username);
QVariantList retList; QVariantList retList;
foreach (const TokenInfo &tokenInfo, tokens) { foreach (const TokenInfo &tokenInfo, tokens) {
retList << JsonTypes::packTokenInfo(tokenInfo); retList << JsonTypes::packTokenInfo(tokenInfo);
@ -322,7 +322,7 @@ JsonReply *JsonRPCServer::Tokens(const QVariantMap &params) const
JsonReply *JsonRPCServer::RemoveToken(const QVariantMap &params) JsonReply *JsonRPCServer::RemoveToken(const QVariantMap &params)
{ {
QUuid tokenId = params.value("tokenId").toUuid(); QUuid tokenId = params.value("tokenId").toUuid();
UserManager::UserError error = GuhCore::instance()->userManager()->removeToken(tokenId); UserManager::UserError error = NymeaCore::instance()->userManager()->removeToken(tokenId);
QVariantMap ret; QVariantMap ret;
ret.insert("error", JsonTypes::userErrorToString(error)); ret.insert("error", JsonTypes::userErrorToString(error));
return createReply(ret); return createReply(ret);
@ -332,7 +332,7 @@ JsonReply *JsonRPCServer::SetupRemoteAccess(const QVariantMap &params)
{ {
QString idToken = params.value("idToken").toString(); QString idToken = params.value("idToken").toString();
QString userId = params.value("userId").toString(); QString userId = params.value("userId").toString();
GuhCore::instance()->cloudManager()->pairDevice(idToken, userId); NymeaCore::instance()->cloudManager()->pairDevice(idToken, userId);
JsonReply *reply = createAsyncReply("SetupRemoteAccess"); JsonReply *reply = createAsyncReply("SetupRemoteAccess");
m_pairingRequests.insert(userId, reply); m_pairingRequests.insert(userId, reply);
connect(reply, &JsonReply::finished, [this, userId](){ connect(reply, &JsonReply::finished, [this, userId](){
@ -344,7 +344,7 @@ JsonReply *JsonRPCServer::SetupRemoteAccess(const QVariantMap &params)
JsonReply *JsonRPCServer::IsCloudConnected(const QVariantMap &params) JsonReply *JsonRPCServer::IsCloudConnected(const QVariantMap &params)
{ {
Q_UNUSED(params) Q_UNUSED(params)
bool connected = GuhCore::instance()->cloudManager()->connected(); bool connected = NymeaCore::instance()->cloudManager()->connected();
QVariantMap data; QVariantMap data;
data.insert("connected", connected); data.insert("connected", connected);
return createReply(data); return createReply(data);
@ -353,7 +353,7 @@ JsonReply *JsonRPCServer::IsCloudConnected(const QVariantMap &params)
JsonReply *JsonRPCServer::KeepAlive(const QVariantMap &params) JsonReply *JsonRPCServer::KeepAlive(const QVariantMap &params)
{ {
QString sessionId = params.value("sessionId").toString(); QString sessionId = params.value("sessionId").toString();
bool result = GuhCore::instance()->cloudManager()->keepAlive(sessionId); bool result = NymeaCore::instance()->cloudManager()->keepAlive(sessionId);
QVariantMap resultMap; QVariantMap resultMap;
resultMap.insert("success", result); resultMap.insert("success", result);
return createReply(resultMap); return createReply(resultMap);
@ -431,14 +431,14 @@ QVariantMap JsonRPCServer::createWelcomeMessage(TransportInterface *interface) c
QVariantMap handshake; QVariantMap handshake;
handshake.insert("id", 0); handshake.insert("id", 0);
handshake.insert("server", "guhIO"); handshake.insert("server", "guhIO");
handshake.insert("name", GuhCore::instance()->configuration()->serverName()); handshake.insert("name", NymeaCore::instance()->configuration()->serverName());
handshake.insert("version", NYMEA_VERSION_STRING); handshake.insert("version", NYMEA_VERSION_STRING);
handshake.insert("uuid", GuhCore::instance()->configuration()->serverUuid().toString()); handshake.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
handshake.insert("language", GuhCore::instance()->configuration()->locale().name()); handshake.insert("language", NymeaCore::instance()->configuration()->locale().name());
handshake.insert("protocol version", JSON_PROTOCOL_VERSION); handshake.insert("protocol version", JSON_PROTOCOL_VERSION);
handshake.insert("initialSetupRequired", (interface->configuration().authenticationEnabled ? GuhCore::instance()->userManager()->users().isEmpty() : false)); handshake.insert("initialSetupRequired", (interface->configuration().authenticationEnabled ? NymeaCore::instance()->userManager()->users().isEmpty() : false));
handshake.insert("authenticationRequired", interface->configuration().authenticationEnabled); handshake.insert("authenticationRequired", interface->configuration().authenticationEnabled);
handshake.insert("pushButtonAuthAvailable", GuhCore::instance()->userManager()->pushButtonAuthAvailable()); handshake.insert("pushButtonAuthAvailable", NymeaCore::instance()->userManager()->pushButtonAuthAvailable());
return handshake; return handshake;
} }
@ -454,8 +454,8 @@ void JsonRPCServer::setup()
registerHandler(new ConfigurationHandler(this)); registerHandler(new ConfigurationHandler(this));
registerHandler(new NetworkManagerHandler(this)); registerHandler(new NetworkManagerHandler(this));
connect(GuhCore::instance()->cloudManager(), &CloudManager::pairingReply, this, &JsonRPCServer::pairingFinished); connect(NymeaCore::instance()->cloudManager(), &CloudManager::pairingReply, this, &JsonRPCServer::pairingFinished);
connect(GuhCore::instance()->cloudManager(), &CloudManager::connectedChanged, this, &JsonRPCServer::onCloudConnectedChanged); connect(NymeaCore::instance()->cloudManager(), &CloudManager::connectedChanged, this, &JsonRPCServer::onCloudConnectedChanged);
} }
void JsonRPCServer::processData(const QUuid &clientId, const QByteArray &data) void JsonRPCServer::processData(const QUuid &clientId, const QByteArray &data)
@ -497,14 +497,14 @@ void JsonRPCServer::processData(const QUuid &clientId, const QByteArray &data)
QStringList authExemptMethodsNoUser = {"Introspect", "Hello", "CreateUser", "RequestPushButtonAuth"}; QStringList authExemptMethodsNoUser = {"Introspect", "Hello", "CreateUser", "RequestPushButtonAuth"};
QStringList authExemptMethodsWithUser = {"Introspect", "Hello", "Authenticate", "RequestPushButtonAuth"}; QStringList authExemptMethodsWithUser = {"Introspect", "Hello", "Authenticate", "RequestPushButtonAuth"};
// if there is no user in the system yet, let's fail unless this is special method for authentication itself // if there is no user in the system yet, let's fail unless this is special method for authentication itself
if (GuhCore::instance()->userManager()->users().isEmpty()) { if (NymeaCore::instance()->userManager()->users().isEmpty()) {
if (!(targetNamespace == "JSONRPC" && authExemptMethodsNoUser.contains(method)) && (token.isEmpty() || !GuhCore::instance()->userManager()->verifyToken(token))) { if (!(targetNamespace == "JSONRPC" && authExemptMethodsNoUser.contains(method)) && (token.isEmpty() || !NymeaCore::instance()->userManager()->verifyToken(token))) {
sendUnauthorizedResponse(interface, clientId, commandId, "Initial setup required. Call CreateUser first."); sendUnauthorizedResponse(interface, clientId, commandId, "Initial setup required. Call CreateUser first.");
return; return;
} }
} else { } else {
// ok, we have a user. if there isn't a valid token, let's fail unless this is a Authenticate, Introspect Hello call // ok, we have a user. if there isn't a valid token, let's fail unless this is a Authenticate, Introspect Hello call
if (!(targetNamespace == "JSONRPC" && authExemptMethodsWithUser.contains(method)) && (token.isEmpty() || !GuhCore::instance()->userManager()->verifyToken(token))) { if (!(targetNamespace == "JSONRPC" && authExemptMethodsWithUser.contains(method)) && (token.isEmpty() || !NymeaCore::instance()->userManager()->verifyToken(token))) {
sendUnauthorizedResponse(interface, clientId, commandId, "Forbidden: Invalid token."); sendUnauthorizedResponse(interface, clientId, commandId, "Forbidden: Invalid token.");
return; return;
} }
@ -676,7 +676,7 @@ void JsonRPCServer::clientDisconnected(const QUuid &clientId)
m_clientTransports.remove(clientId); m_clientTransports.remove(clientId);
m_clientNotifications.remove(clientId); m_clientNotifications.remove(clientId);
if (m_pushButtonTransactions.values().contains(clientId)) { if (m_pushButtonTransactions.values().contains(clientId)) {
GuhCore::instance()->userManager()->cancelPushButtonAuth(m_pushButtonTransactions.key(clientId)); NymeaCore::instance()->userManager()->cancelPushButtonAuth(m_pushButtonTransactions.key(clientId));
} }
} }

View File

@ -52,7 +52,7 @@
#include "plugin/device.h" #include "plugin/device.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "guhcore.h" #include "nymeacore.h"
#include "ruleengine.h" #include "ruleengine.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "logging/logvaluetool.h" #include "logging/logvaluetool.h"
@ -1060,7 +1060,7 @@ QVariantMap JsonTypes::packWirelessNetworkDevice(WirelessNetworkDevice *networkD
QVariantList JsonTypes::packSupportedVendors() QVariantList JsonTypes::packSupportedVendors()
{ {
QVariantList supportedVendors; QVariantList supportedVendors;
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) foreach (const Vendor &vendor, NymeaCore::instance()->deviceManager()->supportedVendors())
supportedVendors.append(packVendor(vendor)); supportedVendors.append(packVendor(vendor));
return supportedVendors; return supportedVendors;
@ -1070,7 +1070,7 @@ QVariantList JsonTypes::packSupportedVendors()
QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId) QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
{ {
QVariantList supportedDeviceList; QVariantList supportedDeviceList;
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices(vendorId)) foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices(vendorId))
supportedDeviceList.append(packDeviceClass(deviceClass)); supportedDeviceList.append(packDeviceClass(deviceClass));
return supportedDeviceList; return supportedDeviceList;
@ -1080,7 +1080,7 @@ QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
QVariantList JsonTypes::packConfiguredDevices() QVariantList JsonTypes::packConfiguredDevices()
{ {
QVariantList configuredDeviceList; QVariantList configuredDeviceList;
foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) foreach (Device *device, NymeaCore::instance()->deviceManager()->configuredDevices())
configuredDeviceList.append(packDevice(device)); configuredDeviceList.append(packDevice(device));
return configuredDeviceList; return configuredDeviceList;
@ -1089,7 +1089,7 @@ QVariantList JsonTypes::packConfiguredDevices()
/*! Returns a variant list of States from the given \a device. */ /*! Returns a variant list of States from the given \a device. */
QVariantList JsonTypes::packDeviceStates(Device *device) QVariantList JsonTypes::packDeviceStates(Device *device)
{ {
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
QVariantList stateValues; QVariantList stateValues;
foreach (const StateType &stateType, deviceClass.stateTypes()) { foreach (const StateType &stateType, deviceClass.stateTypes()) {
QVariantMap stateValue; QVariantMap stateValue;
@ -1114,12 +1114,12 @@ QVariantList JsonTypes::packDeviceDescriptors(const QList<DeviceDescriptor> devi
QVariantMap JsonTypes::packBasicConfiguration() QVariantMap JsonTypes::packBasicConfiguration()
{ {
QVariantMap basicConfiguration; QVariantMap basicConfiguration;
basicConfiguration.insert("serverName", GuhCore::instance()->configuration()->serverName()); basicConfiguration.insert("serverName", NymeaCore::instance()->configuration()->serverName());
basicConfiguration.insert("serverUuid", GuhCore::instance()->configuration()->serverUuid()); basicConfiguration.insert("serverUuid", NymeaCore::instance()->configuration()->serverUuid());
basicConfiguration.insert("serverTime", GuhCore::instance()->timeManager()->currentDateTime().toTime_t()); basicConfiguration.insert("serverTime", NymeaCore::instance()->timeManager()->currentDateTime().toTime_t());
basicConfiguration.insert("timeZone", QString::fromUtf8(GuhCore::instance()->timeManager()->timeZone())); basicConfiguration.insert("timeZone", QString::fromUtf8(NymeaCore::instance()->timeManager()->timeZone()));
basicConfiguration.insert("language", GuhCore::instance()->configuration()->locale().name()); basicConfiguration.insert("language", NymeaCore::instance()->configuration()->locale().name());
basicConfiguration.insert("debugServerEnabled", GuhCore::instance()->configuration()->debugServerEnabled()); basicConfiguration.insert("debugServerEnabled", NymeaCore::instance()->configuration()->debugServerEnabled());
return basicConfiguration; return basicConfiguration;
} }
@ -1146,7 +1146,7 @@ QVariantMap JsonTypes::packWebServerConfiguration(const WebServerConfiguration &
QVariantList JsonTypes::packRuleDescriptions() QVariantList JsonTypes::packRuleDescriptions()
{ {
QVariantList rulesList; QVariantList rulesList;
foreach (const Rule &rule, GuhCore::instance()->ruleEngine()->rules()) foreach (const Rule &rule, NymeaCore::instance()->ruleEngine()->rules())
rulesList.append(JsonTypes::packRuleDescription(rule)); rulesList.append(JsonTypes::packRuleDescription(rule));
return rulesList; return rulesList;
@ -1196,7 +1196,7 @@ QVariantList JsonTypes::packEventTypes(const DeviceClass &deviceClass)
QVariantList JsonTypes::packPlugins() QVariantList JsonTypes::packPlugins()
{ {
QVariantList pluginsList; QVariantList pluginsList;
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) { foreach (DevicePlugin *plugin, NymeaCore::instance()->deviceManager()->plugins()) {
QVariantMap pluginMap = packPlugin(plugin); QVariantMap pluginMap = packPlugin(plugin);
pluginsList.append(pluginMap); pluginsList.append(pluginMap);
} }

View File

@ -46,7 +46,7 @@
#include "logging/logengine.h" #include "logging/logengine.h"
#include "logging/logfilter.h" #include "logging/logfilter.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
namespace guhserver { namespace guhserver {
@ -91,8 +91,8 @@ LoggingHandler::LoggingHandler(QObject *parent) :
"keep to database in the size limits."); "keep to database in the size limits.");
setParams("LogDatabaseUpdated", params); setParams("LogDatabaseUpdated", params);
connect(GuhCore::instance()->logEngine(), &LogEngine::logEntryAdded, this, &LoggingHandler::logEntryAdded); connect(NymeaCore::instance()->logEngine(), &LogEngine::logEntryAdded, this, &LoggingHandler::logEntryAdded);
connect(GuhCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated); connect(NymeaCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated);
} }
/*! Returns the name of the \l{LoggingHandler}. In this case \b Logging.*/ /*! Returns the name of the \l{LoggingHandler}. In this case \b Logging.*/
@ -122,7 +122,7 @@ JsonReply* LoggingHandler::GetLogEntries(const QVariantMap &params) const
LogFilter filter = JsonTypes::unpackLogFilter(params); LogFilter filter = JsonTypes::unpackLogFilter(params);
QVariantList entries; QVariantList entries;
foreach (const LogEntry &entry, GuhCore::instance()->logEngine()->logEntries(filter)) { foreach (const LogEntry &entry, NymeaCore::instance()->logEngine()->logEntries(filter)) {
entries.append(JsonTypes::packLogEntry(entry)); entries.append(JsonTypes::packLogEntry(entry));
} }
QVariantMap returns = statusToReply(Logging::LoggingErrorNoError); QVariantMap returns = statusToReply(Logging::LoggingErrorNoError);

View File

@ -67,7 +67,7 @@
*/ */
#include "guhcore.h" #include "nymeacore.h"
#include "jsontypes.h" #include "jsontypes.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "networkmanagerhandler.h" #include "networkmanagerhandler.h"
@ -182,17 +182,17 @@ NetworkManagerHandler::NetworkManagerHandler(QObject *parent) :
params.insert("wiredNetworkDevice", JsonTypes::wiredNetworkDeviceRef()); params.insert("wiredNetworkDevice", JsonTypes::wiredNetworkDeviceRef());
setParams("WiredNetworkDeviceChanged", params); setParams("WiredNetworkDeviceChanged", params);
connect(GuhCore::instance()->networkManager(), &NetworkManager::stateChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged); connect(NymeaCore::instance()->networkManager(), &NetworkManager::stateChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
connect(GuhCore::instance()->networkManager(), &NetworkManager::networkingEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged); connect(NymeaCore::instance()->networkManager(), &NetworkManager::networkingEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged); connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessDeviceAdded, this, &NetworkManagerHandler::onWirelessNetworkDeviceAdded); connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessDeviceAdded, this, &NetworkManagerHandler::onWirelessNetworkDeviceAdded);
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessDeviceRemoved, this, &NetworkManagerHandler::onWirelessNetworkDeviceRemoved); connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessDeviceRemoved, this, &NetworkManagerHandler::onWirelessNetworkDeviceRemoved);
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessDeviceChanged, this, &NetworkManagerHandler::onWirelessNetworkDeviceChanged); connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessDeviceChanged, this, &NetworkManagerHandler::onWirelessNetworkDeviceChanged);
connect(GuhCore::instance()->networkManager(), &NetworkManager::wiredDeviceAdded, this, &NetworkManagerHandler::onWiredNetworkDeviceAdded); connect(NymeaCore::instance()->networkManager(), &NetworkManager::wiredDeviceAdded, this, &NetworkManagerHandler::onWiredNetworkDeviceAdded);
connect(GuhCore::instance()->networkManager(), &NetworkManager::wiredDeviceRemoved, this, &NetworkManagerHandler::onWiredNetworkDeviceRemoved); connect(NymeaCore::instance()->networkManager(), &NetworkManager::wiredDeviceRemoved, this, &NetworkManagerHandler::onWiredNetworkDeviceRemoved);
connect(GuhCore::instance()->networkManager(), &NetworkManager::wiredDeviceChanged, this, &NetworkManagerHandler::onWiredNetworkDeviceChanged); connect(NymeaCore::instance()->networkManager(), &NetworkManager::wiredDeviceChanged, this, &NetworkManagerHandler::onWiredNetworkDeviceChanged);
} }
/*! Returns the name of the \l{NetworkManagerHandler}. In this case \b NetworkManager. */ /*! Returns the name of the \l{NetworkManagerHandler}. In this case \b NetworkManager. */
@ -206,7 +206,7 @@ JsonReply *NetworkManagerHandler::GetNetworkStatus(const QVariantMap &params)
Q_UNUSED(params); Q_UNUSED(params);
// Check available // Check available
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
// Pack network manager status // Pack network manager status
@ -218,12 +218,12 @@ JsonReply *NetworkManagerHandler::GetNetworkStatus(const QVariantMap &params)
JsonReply *NetworkManagerHandler::EnableNetworking(const QVariantMap &params) JsonReply *NetworkManagerHandler::EnableNetworking(const QVariantMap &params)
{ {
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
bool enable = params.value("enable").toBool(); bool enable = params.value("enable").toBool();
if (!GuhCore::instance()->networkManager()->enableNetworking(enable)) if (!NymeaCore::instance()->networkManager()->enableNetworking(enable))
return createReply(statusToReply(NetworkManager::NetworkManagerErrorUnknownError)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorUnknownError));
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNoError)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNoError));
@ -231,13 +231,13 @@ JsonReply *NetworkManagerHandler::EnableNetworking(const QVariantMap &params)
JsonReply *NetworkManagerHandler::EnableWirelessNetworking(const QVariantMap &params) JsonReply *NetworkManagerHandler::EnableWirelessNetworking(const QVariantMap &params)
{ {
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
if (!GuhCore::instance()->networkManager()->wifiAvailable()) if (!NymeaCore::instance()->networkManager()->wifiAvailable())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable));
if (!GuhCore::instance()->networkManager()->enableWireless(params.value("enable").toBool())) if (!NymeaCore::instance()->networkManager()->enableWireless(params.value("enable").toBool()))
return createReply(statusToReply(NetworkManager::NetworkManagerErrorUnknownError)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorUnknownError));
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNoError)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNoError));
@ -245,24 +245,24 @@ JsonReply *NetworkManagerHandler::EnableWirelessNetworking(const QVariantMap &pa
JsonReply *NetworkManagerHandler::GetWirelessAccessPoints(const QVariantMap &params) JsonReply *NetworkManagerHandler::GetWirelessAccessPoints(const QVariantMap &params)
{ {
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
if (!GuhCore::instance()->networkManager()->wifiAvailable()) if (!NymeaCore::instance()->networkManager()->wifiAvailable())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable));
if (!GuhCore::instance()->networkManager()->networkingEnabled()) if (!NymeaCore::instance()->networkManager()->networkingEnabled())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled));
if (!GuhCore::instance()->networkManager()->wirelessEnabled()) if (!NymeaCore::instance()->networkManager()->wirelessEnabled())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled));
QString interface = params.value("interface").toString(); QString interface = params.value("interface").toString();
if (!GuhCore::instance()->networkManager()->getNetworkDevice(interface)) if (!NymeaCore::instance()->networkManager()->getNetworkDevice(interface))
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound));
foreach (WirelessNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wirelessNetworkDevices()) { foreach (WirelessNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wirelessNetworkDevices()) {
if (networkDevice->interface() == interface) { if (networkDevice->interface() == interface) {
QVariantList wirelessAccessPoints; QVariantList wirelessAccessPoints;
foreach (WirelessAccessPoint *wirelessAccessPoint, networkDevice->accessPoints()) foreach (WirelessAccessPoint *wirelessAccessPoint, networkDevice->accessPoints())
@ -283,15 +283,15 @@ JsonReply *NetworkManagerHandler::GetNetworkDevices(const QVariantMap &params)
{ {
Q_UNUSED(params); Q_UNUSED(params);
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
QVariantList wirelessNetworkDevices; QVariantList wirelessNetworkDevices;
foreach (WirelessNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wirelessNetworkDevices()) foreach (WirelessNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wirelessNetworkDevices())
wirelessNetworkDevices.append(JsonTypes::packWirelessNetworkDevice(networkDevice)); wirelessNetworkDevices.append(JsonTypes::packWirelessNetworkDevice(networkDevice));
QVariantList wiredNetworkDevices; QVariantList wiredNetworkDevices;
foreach (WiredNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wiredNetworkDevices()) foreach (WiredNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wiredNetworkDevices())
wiredNetworkDevices.append(JsonTypes::packWiredNetworkDevice(networkDevice)); wiredNetworkDevices.append(JsonTypes::packWiredNetworkDevice(networkDevice));
QVariantMap returns; QVariantMap returns;
@ -305,25 +305,25 @@ JsonReply *NetworkManagerHandler::ScanWifiNetworks(const QVariantMap &params)
{ {
Q_UNUSED(params); Q_UNUSED(params);
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
if (!GuhCore::instance()->networkManager()->wifiAvailable()) if (!NymeaCore::instance()->networkManager()->wifiAvailable())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable));
if (!GuhCore::instance()->networkManager()->networkingEnabled()) if (!NymeaCore::instance()->networkManager()->networkingEnabled())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled));
if (!GuhCore::instance()->networkManager()->wirelessEnabled()) if (!NymeaCore::instance()->networkManager()->wirelessEnabled())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled));
QString interface = params.value("interface").toString(); QString interface = params.value("interface").toString();
if (!GuhCore::instance()->networkManager()->getNetworkDevice(interface)) if (!NymeaCore::instance()->networkManager()->getNetworkDevice(interface))
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound));
foreach (WirelessNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wirelessNetworkDevices()) { foreach (WirelessNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wirelessNetworkDevices()) {
if (networkDevice->interface() == interface) { if (networkDevice->interface() == interface) {
networkDevice->scanWirelessNetworks(); networkDevice->scanWirelessNetworks();
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNoError)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNoError));
@ -335,16 +335,16 @@ JsonReply *NetworkManagerHandler::ScanWifiNetworks(const QVariantMap &params)
JsonReply *NetworkManagerHandler::ConnectWifiNetwork(const QVariantMap &params) JsonReply *NetworkManagerHandler::ConnectWifiNetwork(const QVariantMap &params)
{ {
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
if (!GuhCore::instance()->networkManager()->wifiAvailable()) if (!NymeaCore::instance()->networkManager()->wifiAvailable())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable));
if (!GuhCore::instance()->networkManager()->networkingEnabled()) if (!NymeaCore::instance()->networkManager()->networkingEnabled())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled));
if (!GuhCore::instance()->networkManager()->wirelessEnabled()) if (!NymeaCore::instance()->networkManager()->wirelessEnabled())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled));
@ -352,16 +352,16 @@ JsonReply *NetworkManagerHandler::ConnectWifiNetwork(const QVariantMap &params)
QString password = params.value("password").toString(); QString password = params.value("password").toString();
QString interface = params.value("interface").toString(); QString interface = params.value("interface").toString();
return createReply(statusToReply(GuhCore::instance()->networkManager()->connectWifi(interface, ssid, password))); return createReply(statusToReply(NymeaCore::instance()->networkManager()->connectWifi(interface, ssid, password)));
} }
JsonReply *NetworkManagerHandler::DisconnectInterface(const QVariantMap &params) JsonReply *NetworkManagerHandler::DisconnectInterface(const QVariantMap &params)
{ {
if (!GuhCore::instance()->networkManager()->available()) if (!NymeaCore::instance()->networkManager()->available())
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
QString interface = params.value("interface").toString(); QString interface = params.value("interface").toString();
NetworkDevice *networkDevice = GuhCore::instance()->networkManager()->getNetworkDevice(interface); NetworkDevice *networkDevice = NymeaCore::instance()->networkManager()->getNetworkDevice(interface);
if (!networkDevice) if (!networkDevice)
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound)); return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound));
@ -372,9 +372,9 @@ JsonReply *NetworkManagerHandler::DisconnectInterface(const QVariantMap &params)
QVariantMap NetworkManagerHandler::packNetworkManagerStatus() QVariantMap NetworkManagerHandler::packNetworkManagerStatus()
{ {
QVariantMap status; QVariantMap status;
status.insert("networkingEnabled", GuhCore::instance()->networkManager()->networkingEnabled()); status.insert("networkingEnabled", NymeaCore::instance()->networkManager()->networkingEnabled());
status.insert("wirelessNetworkingEnabled", GuhCore::instance()->networkManager()->wirelessEnabled()); status.insert("wirelessNetworkingEnabled", NymeaCore::instance()->networkManager()->wirelessEnabled());
status.insert("state", GuhCore::instance()->networkManager()->stateString()); status.insert("state", NymeaCore::instance()->networkManager()->stateString());
return status; return status;
} }

View File

@ -53,7 +53,7 @@
*/ */
#include "ruleshandler.h" #include "ruleshandler.h"
#include "guhcore.h" #include "nymeacore.h"
#include "ruleengine.h" #include "ruleengine.h"
#include "loggingcategories.h" #include "loggingcategories.h"
@ -185,10 +185,10 @@ RulesHandler::RulesHandler(QObject *parent) :
params.insert("rule", JsonTypes::ruleRef()); params.insert("rule", JsonTypes::ruleRef());
setParams("RuleConfigurationChanged", params); setParams("RuleConfigurationChanged", params);
connect(GuhCore::instance(), &GuhCore::ruleAdded, this, &RulesHandler::ruleAddedNotification); connect(NymeaCore::instance(), &NymeaCore::ruleAdded, this, &RulesHandler::ruleAddedNotification);
connect(GuhCore::instance(), &GuhCore::ruleRemoved, this, &RulesHandler::ruleRemovedNotification); connect(NymeaCore::instance(), &NymeaCore::ruleRemoved, this, &RulesHandler::ruleRemovedNotification);
connect(GuhCore::instance(), &GuhCore::ruleActiveChanged, this, &RulesHandler::ruleActiveChangedNotification); connect(NymeaCore::instance(), &NymeaCore::ruleActiveChanged, this, &RulesHandler::ruleActiveChangedNotification);
connect(GuhCore::instance(), &GuhCore::ruleConfigurationChanged, this, &RulesHandler::ruleConfigurationChangedNotification); connect(NymeaCore::instance(), &NymeaCore::ruleConfigurationChanged, this, &RulesHandler::ruleConfigurationChangedNotification);
} }
/*! Returns the name of the \l{RulesHandler}. In this case \b Rules.*/ /*! Returns the name of the \l{RulesHandler}. In this case \b Rules.*/
@ -210,7 +210,7 @@ JsonReply* RulesHandler::GetRules(const QVariantMap &params)
JsonReply *RulesHandler::GetRuleDetails(const QVariantMap &params) JsonReply *RulesHandler::GetRuleDetails(const QVariantMap &params)
{ {
RuleId ruleId = RuleId(params.value("ruleId").toString()); RuleId ruleId = RuleId(params.value("ruleId").toString());
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId); Rule rule = NymeaCore::instance()->ruleEngine()->findRule(ruleId);
if (rule.id().isNull()) { if (rule.id().isNull()) {
return createReply(statusToReply(RuleEngine::RuleErrorRuleNotFound)); return createReply(statusToReply(RuleEngine::RuleErrorRuleNotFound));
} }
@ -224,7 +224,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap &params)
Rule rule = JsonTypes::unpackRule(params); Rule rule = JsonTypes::unpackRule(params);
rule.setId(RuleId::createRuleId()); rule.setId(RuleId::createRuleId());
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->addRule(rule); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->addRule(rule);
QVariantMap returns; QVariantMap returns;
if (status == RuleEngine::RuleErrorNoError) { if (status == RuleEngine::RuleErrorNoError) {
returns.insert("ruleId", rule.id().toString()); returns.insert("ruleId", rule.id().toString());
@ -236,10 +236,10 @@ JsonReply* RulesHandler::AddRule(const QVariantMap &params)
JsonReply *RulesHandler::EditRule(const QVariantMap &params) JsonReply *RulesHandler::EditRule(const QVariantMap &params)
{ {
Rule rule = JsonTypes::unpackRule(params); Rule rule = JsonTypes::unpackRule(params);
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->editRule(rule); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->editRule(rule);
QVariantMap returns; QVariantMap returns;
if (status == RuleEngine::RuleErrorNoError) { if (status == RuleEngine::RuleErrorNoError) {
returns.insert("rule", JsonTypes::packRule(GuhCore::instance()->ruleEngine()->findRule(rule.id()))); returns.insert("rule", JsonTypes::packRule(NymeaCore::instance()->ruleEngine()->findRule(rule.id())));
} }
returns.insert("ruleError", JsonTypes::ruleErrorToString(status)); returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
return createReply(returns); return createReply(returns);
@ -249,7 +249,7 @@ JsonReply* RulesHandler::RemoveRule(const QVariantMap &params)
{ {
QVariantMap returns; QVariantMap returns;
RuleId ruleId(params.value("ruleId").toString()); RuleId ruleId(params.value("ruleId").toString());
RuleEngine::RuleError status = GuhCore::instance()->removeRule(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->removeRule(ruleId);
returns.insert("ruleError", JsonTypes::ruleErrorToString(status)); returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
return createReply(returns); return createReply(returns);
} }
@ -257,7 +257,7 @@ JsonReply* RulesHandler::RemoveRule(const QVariantMap &params)
JsonReply *RulesHandler::FindRules(const QVariantMap &params) JsonReply *RulesHandler::FindRules(const QVariantMap &params)
{ {
DeviceId deviceId = DeviceId(params.value("deviceId").toString()); DeviceId deviceId = DeviceId(params.value("deviceId").toString());
QList<RuleId> rules = GuhCore::instance()->ruleEngine()->findRules(deviceId); QList<RuleId> rules = NymeaCore::instance()->ruleEngine()->findRules(deviceId);
QVariantList rulesList; QVariantList rulesList;
foreach (const RuleId &ruleId, rules) { foreach (const RuleId &ruleId, rules) {
@ -271,19 +271,19 @@ JsonReply *RulesHandler::FindRules(const QVariantMap &params)
JsonReply *RulesHandler::EnableRule(const QVariantMap &params) JsonReply *RulesHandler::EnableRule(const QVariantMap &params)
{ {
return createReply(statusToReply(GuhCore::instance()->ruleEngine()->enableRule(RuleId(params.value("ruleId").toString())))); return createReply(statusToReply(NymeaCore::instance()->ruleEngine()->enableRule(RuleId(params.value("ruleId").toString()))));
} }
JsonReply *RulesHandler::DisableRule(const QVariantMap &params) JsonReply *RulesHandler::DisableRule(const QVariantMap &params)
{ {
return createReply(statusToReply(GuhCore::instance()->ruleEngine()->disableRule(RuleId(params.value("ruleId").toString())))); return createReply(statusToReply(NymeaCore::instance()->ruleEngine()->disableRule(RuleId(params.value("ruleId").toString()))));
} }
JsonReply *RulesHandler::ExecuteActions(const QVariantMap &params) JsonReply *RulesHandler::ExecuteActions(const QVariantMap &params)
{ {
QVariantMap returns; QVariantMap returns;
RuleId ruleId(params.value("ruleId").toString()); RuleId ruleId(params.value("ruleId").toString());
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeActions(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->executeActions(ruleId);
returns.insert("ruleError", JsonTypes::ruleErrorToString(status)); returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
return createReply(returns); return createReply(returns);
} }
@ -292,7 +292,7 @@ JsonReply *RulesHandler::ExecuteExitActions(const QVariantMap &params)
{ {
QVariantMap returns; QVariantMap returns;
RuleId ruleId(params.value("ruleId").toString()); RuleId ruleId(params.value("ruleId").toString());
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeExitActions(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->executeExitActions(ruleId);
returns.insert("ruleError", JsonTypes::ruleErrorToString(status)); returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
return createReply(returns); return createReply(returns);
} }

View File

@ -33,7 +33,7 @@
*/ */
#include "statehandler.h" #include "statehandler.h"
#include "guhcore.h" #include "nymeacore.h"
#include "loggingcategories.h" #include "loggingcategories.h"
namespace guhserver { namespace guhserver {
@ -64,7 +64,7 @@ JsonReply* StateHandler::GetStateType(const QVariantMap &params) const
{ {
qCDebug(dcJsonRpc) << "asked for state type" << params; qCDebug(dcJsonRpc) << "asked for state type" << params;
StateTypeId stateTypeId(params.value("stateTypeId").toString()); StateTypeId stateTypeId(params.value("stateTypeId").toString());
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) { foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices()) {
foreach (const StateType &stateType, deviceClass.stateTypes()) { foreach (const StateType &stateType, deviceClass.stateTypes()) {
if (stateType.id() == stateTypeId) { if (stateType.id() == stateTypeId) {
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError); QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);

View File

@ -15,7 +15,7 @@ RESOURCES += $$top_srcdir/icons.qrc \
$$top_srcdir/data/debug-interface/debug-interface.qrc $$top_srcdir/data/debug-interface/debug-interface.qrc
HEADERS += guhcore.h \ HEADERS += nymeacore.h \
tcpserver.h \ tcpserver.h \
mocktcpserver.h \ mocktcpserver.h \
ruleengine.h \ ruleengine.h \
@ -96,7 +96,7 @@ HEADERS += guhcore.h \
hardware/network/avahi/qtavahiservicebrowserimplementation_p.h \ hardware/network/avahi/qtavahiservicebrowserimplementation_p.h \
debugserverhandler.h debugserverhandler.h
SOURCES += guhcore.cpp \ SOURCES += nymeacore.cpp \
tcpserver.cpp \ tcpserver.cpp \
mocktcpserver.cpp \ mocktcpserver.cpp \
ruleengine.cpp \ ruleengine.cpp \

View File

@ -37,7 +37,7 @@
*/ */
#include "logentry.h" #include "logentry.h"
#include "guhcore.h" #include "nymeacore.h"
#include "jsonrpc/jsontypes.h" #include "jsonrpc/jsontypes.h"
#include <QDebug> #include <QDebug>
@ -58,7 +58,7 @@ LogEntry::LogEntry(QDateTime timestamp, Logging::LoggingLevel level, Logging::Lo
/*! Constructs a \l{LogEntry} with the given \a level, \a source and \a errorCode.*/ /*! Constructs a \l{LogEntry} with the given \a level, \a source and \a errorCode.*/
LogEntry::LogEntry(Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode): LogEntry::LogEntry(Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode):
LogEntry(GuhCore::instance()->timeManager()->currentDateTime(), level, source, errorCode) LogEntry(NymeaCore::instance()->timeManager()->currentDateTime(), level, source, errorCode)
{ {
} }

View File

@ -20,7 +20,6 @@
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h"
#include <QUuid> #include <QUuid>
#include <QHash> #include <QHash>

View File

@ -20,71 +20,71 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*! /*!
\class guhserver::GuhCore \class guhserver::NymeaCore
\brief The main entry point for the Guh Server and the place where all the messages are dispatched. \brief The main entry point for the nymea Server and the place where all the messages are dispatched.
\inmodule core \inmodule core
GuhCore is a singleton instance and the main entry point of the Guh daemon. It is responsible to NymeaCore is a singleton instance and the main entry point of the nymea daemon. It is responsible to
instantiate, set up and connect all the other components. instantiate, set up and connect all the other components.
*/ */
/*! \fn void guhserver::GuhCore::eventTriggered(const Event &event); /*! \fn void guhserver::NymeaCore::eventTriggered(const Event &event);
This signal is emitted when an \a event happend. This signal is emitted when an \a event happend.
*/ */
/*! \fn void guhserver::GuhCore::deviceStateChanged(Device *device, const QUuid &stateTypeId, const QVariant &value); /*! \fn void guhserver::NymeaCore::deviceStateChanged(Device *device, const QUuid &stateTypeId, const QVariant &value);
This signal is emitted when the \l{State} of a \a device changed. The \a stateTypeId parameter describes the This signal is emitted when the \l{State} of a \a device changed. The \a stateTypeId parameter describes the
\l{StateType} and the \a value parameter holds the new value. \l{StateType} and the \a value parameter holds the new value.
*/ */
/*! \fn void guhserver::GuhCore::deviceRemoved(const DeviceId &deviceId); /*! \fn void guhserver::NymeaCore::deviceRemoved(const DeviceId &deviceId);
This signal is emitted when a \l{Device} with the given \a deviceId was removed. This signal is emitted when a \l{Device} with the given \a deviceId was removed.
*/ */
/*! \fn void guhserver::GuhCore::deviceAdded(Device *device); /*! \fn void guhserver::NymeaCore::deviceAdded(Device *device);
This signal is emitted when a \a device was added to the system. This signal is emitted when a \a device was added to the system.
*/ */
/*! \fn void guhserver::GuhCore::deviceChanged(Device *device); /*! \fn void guhserver::NymeaCore::deviceChanged(Device *device);
This signal is emitted when the \l{ParamList}{Params} of a \a device have been changed. This signal is emitted when the \l{ParamList}{Params} of a \a device have been changed.
*/ */
/*! \fn void guhserver::GuhCore::actionExecuted(const ActionId &id, DeviceManager::DeviceError status); /*! \fn void guhserver::NymeaCore::actionExecuted(const ActionId &id, DeviceManager::DeviceError status);
This signal is emitted when the \l{Action} with the given \a id is finished. This signal is emitted when the \l{Action} with the given \a id is finished.
The \a status of the \l{Action} execution will be described as \l{DeviceManager::DeviceError}{DeviceError}. The \a status of the \l{Action} execution will be described as \l{DeviceManager::DeviceError}{DeviceError}.
*/ */
/*! \fn void guhserver::GuhCore::devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> deviceDescriptors); /*! \fn void guhserver::NymeaCore::devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> deviceDescriptors);
This signal is emitted when the discovery of a \a deviceClassId is finished. The \a deviceDescriptors parameter describes the This signal is emitted when the discovery of a \a deviceClassId is finished. The \a deviceDescriptors parameter describes the
list of \l{DeviceDescriptor}{DeviceDescriptors} of all discovered \l{Device}{Devices}. list of \l{DeviceDescriptor}{DeviceDescriptors} of all discovered \l{Device}{Devices}.
\sa DeviceManager::discoverDevices() \sa DeviceManager::discoverDevices()
*/ */
/*! \fn void guhserver::GuhCore::deviceSetupFinished(Device *device, DeviceManager::DeviceError status); /*! \fn void guhserver::NymeaCore::deviceSetupFinished(Device *device, DeviceManager::DeviceError status);
This signal is emitted when the setup of a \a device is finished. The \a status parameter describes the This signal is emitted when the setup of a \a device is finished. The \a status parameter describes the
\l{DeviceManager::DeviceError}{DeviceError} that occurred. \l{DeviceManager::DeviceError}{DeviceError} that occurred.
*/ */
/*! \fn void guhserver::GuhCore::deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status); /*! \fn void guhserver::NymeaCore::deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status);
This signal is emitted when the edit request of a \a device is finished. The \a status of the edit request will be This signal is emitted when the edit request of a \a device is finished. The \a status of the edit request will be
described as \l{DeviceManager::DeviceError}{DeviceError}. described as \l{DeviceManager::DeviceError}{DeviceError}.
*/ */
/*! \fn void guhserver::GuhCore::pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId); /*! \fn void guhserver::NymeaCore::pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId);
The DeviceManager will emit a this Signal when the pairing of a \l{Device} with the \a deviceId and \a pairingTransactionId is finished. The DeviceManager will emit a this Signal when the pairing of a \l{Device} with the \a deviceId and \a pairingTransactionId is finished.
The \a status of the pairing will be described as \l{DeviceManager::DeviceError}{DeviceError}. The \a status of the pairing will be described as \l{DeviceManager::DeviceError}{DeviceError}.
*/ */
/*! \fn void guhserver::GuhCore::ruleRemoved(const RuleId &ruleId); /*! \fn void guhserver::NymeaCore::ruleRemoved(const RuleId &ruleId);
This signal is emitted when a \l{Rule} with the given \a ruleId was removed. This signal is emitted when a \l{Rule} with the given \a ruleId was removed.
*/ */
/*! \fn void guhserver::GuhCore::ruleAdded(const Rule &rule); /*! \fn void guhserver::NymeaCore::ruleAdded(const Rule &rule);
This signal is emitted when a \a rule was added to the system. This signal is emitted when a \a rule was added to the system.
*/ */
/*! \fn void guhserver::GuhCore::ruleConfigurationChanged(const Rule &rule); /*! \fn void guhserver::NymeaCore::ruleConfigurationChanged(const Rule &rule);
This signal is emitted when the configuration of \a rule changed. This signal is emitted when the configuration of \a rule changed.
*/ */
@ -95,7 +95,7 @@
\sa Rule::active() \sa Rule::active()
*/ */
#include "guhcore.h" #include "nymeacore.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "jsonrpc/jsonrpcserver.h" #include "jsonrpc/jsonrpcserver.h"
#include "ruleengine.h" #include "ruleengine.h"
@ -108,19 +108,19 @@
namespace guhserver { namespace guhserver {
GuhCore* GuhCore::s_instance = 0; NymeaCore* NymeaCore::s_instance = 0;
/*! Returns a pointer to the single \l{GuhCore} instance. */ /*! Returns a pointer to the single \l{NymeaCore} instance. */
GuhCore *GuhCore::instance() NymeaCore *NymeaCore::instance()
{ {
if (!s_instance) { if (!s_instance) {
s_instance = new GuhCore(); s_instance = new NymeaCore();
} }
return s_instance; return s_instance;
} }
/*! Destructor of the \l{GuhCore}. */ /*! Destructor of the \l{NymeaCore}. */
GuhCore::~GuhCore() NymeaCore::~NymeaCore()
{ {
m_logger->logSystemEvent(m_timeManager->currentDateTime(), false); m_logger->logSystemEvent(m_timeManager->currentDateTime(), false);
@ -144,8 +144,8 @@ GuhCore::~GuhCore()
delete m_cloudManager; delete m_cloudManager;
} }
/*! Destroyes the \l{GuhCore} instance. */ /*! Destroyes the \l{NymeaCore} instance. */
void GuhCore::destroy() void NymeaCore::destroy()
{ {
if (s_instance) { if (s_instance) {
delete s_instance; delete s_instance;
@ -155,7 +155,7 @@ void GuhCore::destroy()
} }
/*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicyList. */ /*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicyList. */
QPair<DeviceManager::DeviceError, QList<RuleId> > GuhCore::removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList) QPair<DeviceManager::DeviceError, QList<RuleId> > NymeaCore::removeConfiguredDevice(const DeviceId &deviceId, const QHash<RuleId, RuleEngine::RemovePolicy> &removePolicyList)
{ {
// Check if this is a child device // Check if this is a child device
Device *device = m_deviceManager->findConfiguredDevice(deviceId); Device *device = m_deviceManager->findConfiguredDevice(deviceId);
@ -251,7 +251,7 @@ QPair<DeviceManager::DeviceError, QList<RuleId> > GuhCore::removeConfiguredDevic
/*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicy. */ /*! Removes a configured \l{Device} with the given \a deviceId and \a removePolicy. */
DeviceManager::DeviceError GuhCore::removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy) DeviceManager::DeviceError NymeaCore::removeConfiguredDevice(const DeviceId &deviceId, const RuleEngine::RemovePolicy &removePolicy)
{ {
// Check if this is a child device // Check if this is a child device
Device *device = m_deviceManager->findConfiguredDevice(deviceId); Device *device = m_deviceManager->findConfiguredDevice(deviceId);
@ -324,7 +324,7 @@ DeviceManager::DeviceError GuhCore::removeConfiguredDevice(const DeviceId &devic
/*! Calls the metheod DeviceManager::executeAction(\a action). /*! Calls the metheod DeviceManager::executeAction(\a action).
* \sa DeviceManager::executeAction(), */ * \sa DeviceManager::executeAction(), */
DeviceManager::DeviceError GuhCore::executeAction(const Action &action) DeviceManager::DeviceError NymeaCore::executeAction(const Action &action)
{ {
DeviceManager::DeviceError ret = m_deviceManager->executeAction(action); DeviceManager::DeviceError ret = m_deviceManager->executeAction(action);
if (ret == DeviceManager::DeviceErrorNoError) { if (ret == DeviceManager::DeviceErrorNoError) {
@ -338,7 +338,7 @@ DeviceManager::DeviceError GuhCore::executeAction(const Action &action)
} }
/*! Execute the given \a ruleActions. */ /*! Execute the given \a ruleActions. */
void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions) void NymeaCore::executeRuleActions(const QList<RuleAction> ruleActions)
{ {
QList<Action> actions; QList<Action> actions;
foreach (const RuleAction &ruleAction, ruleActions) { foreach (const RuleAction &ruleAction, ruleActions) {
@ -394,7 +394,7 @@ void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions)
/*! Calls the metheod RuleEngine::removeRule(\a id). /*! Calls the metheod RuleEngine::removeRule(\a id).
* \sa RuleEngine, */ * \sa RuleEngine, */
RuleEngine::RuleError GuhCore::removeRule(const RuleId &id) RuleEngine::RuleError NymeaCore::removeRule(const RuleId &id)
{ {
RuleEngine::RuleError removeError = m_ruleEngine->removeRule(id); RuleEngine::RuleError removeError = m_ruleEngine->removeRule(id);
if (removeError == RuleEngine::RuleErrorNoError) if (removeError == RuleEngine::RuleErrorNoError)
@ -403,80 +403,80 @@ RuleEngine::RuleError GuhCore::removeRule(const RuleId &id)
return removeError; return removeError;
} }
/*! Returns a pointer to the \l{GuhConfiguration} instance owned by GuhCore.*/ /*! Returns a pointer to the \l{GuhConfiguration} instance owned by NymeaCore.*/
GuhConfiguration *GuhCore::configuration() const GuhConfiguration *NymeaCore::configuration() const
{ {
return m_configuration; return m_configuration;
} }
/*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/ /*! Returns a pointer to the \l{DeviceManager} instance owned by NymeaCore.*/
DeviceManager *GuhCore::deviceManager() const DeviceManager *NymeaCore::deviceManager() const
{ {
return m_deviceManager; return m_deviceManager;
} }
/*! Returns a pointer to the \l{RuleEngine} instance owned by GuhCore.*/ /*! Returns a pointer to the \l{RuleEngine} instance owned by NymeaCore.*/
RuleEngine *GuhCore::ruleEngine() const RuleEngine *NymeaCore::ruleEngine() const
{ {
return m_ruleEngine; return m_ruleEngine;
} }
/*! Returns a pointer to the \l{TimeManager} instance owned by GuhCore.*/ /*! Returns a pointer to the \l{TimeManager} instance owned by NymeaCore.*/
TimeManager *GuhCore::timeManager() const TimeManager *NymeaCore::timeManager() const
{ {
return m_timeManager; return m_timeManager;
} }
/*! Returns a pointer to the \l{ServerManager} instance owned by GuhCore. */ /*! Returns a pointer to the \l{ServerManager} instance owned by NymeaCore. */
ServerManager *GuhCore::serverManager() const ServerManager *NymeaCore::serverManager() const
{ {
return m_serverManager; return m_serverManager;
} }
/*! Returns the list of available system languages. */ /*! Returns the list of available system languages. */
QStringList GuhCore::getAvailableLanguages() QStringList NymeaCore::getAvailableLanguages()
{ {
// TODO: parse available translation files // TODO: parse available translation files
return QStringList() << "en_US" << "de_DE"; return QStringList() << "en_US" << "de_DE";
} }
/*! Returns a pointer to the \l{BluetoothServer} instance owned by GuhCore. */ /*! Returns a pointer to the \l{BluetoothServer} instance owned by NymeaCore. */
BluetoothServer *GuhCore::bluetoothServer() const BluetoothServer *NymeaCore::bluetoothServer() const
{ {
return m_serverManager->bluetoothServer(); return m_serverManager->bluetoothServer();
} }
/*! Returns a pointer to the \l{NetworkManager} instance owned by GuhCore. */ /*! Returns a pointer to the \l{NetworkManager} instance owned by NymeaCore. */
NetworkManager *GuhCore::networkManager() const NetworkManager *NymeaCore::networkManager() const
{ {
return m_networkManager; return m_networkManager;
} }
UserManager *GuhCore::userManager() const UserManager *NymeaCore::userManager() const
{ {
return m_userManager; return m_userManager;
} }
CloudManager *GuhCore::cloudManager() const CloudManager *NymeaCore::cloudManager() const
{ {
return m_cloudManager; return m_cloudManager;
} }
DebugServerHandler *GuhCore::debugServerHandler() const DebugServerHandler *NymeaCore::debugServerHandler() const
{ {
return m_debugServerHandler; return m_debugServerHandler;
} }
/*! Constructs GuhCore with the given \a parent. This is private. /*! Constructs NymeaCore with the given \a parent. This is private.
Use \l{GuhCore::instance()} to access the single instance.*/ Use \l{NymeaCore::instance()} to access the single instance.*/
GuhCore::GuhCore(QObject *parent) : NymeaCore::NymeaCore(QObject *parent) :
QObject(parent) QObject(parent)
{ {
staticMetaObject.invokeMethod(this, "init", Qt::QueuedConnection); staticMetaObject.invokeMethod(this, "init", Qt::QueuedConnection);
} }
void GuhCore::init() { void NymeaCore::init() {
qCDebug(dcApplication()) << "Loading guh configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName(); qCDebug(dcApplication()) << "Loading guh configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName();
m_configuration = new GuhConfiguration(this); m_configuration = new GuhConfiguration(this);
@ -518,30 +518,30 @@ void GuhCore::init() {
CloudNotifications *cloudNotifications = m_cloudManager->createNotificationsPlugin(); CloudNotifications *cloudNotifications = m_cloudManager->createNotificationsPlugin();
m_deviceManager->registerStaticPlugin(cloudNotifications, cloudNotifications->metaData()); m_deviceManager->registerStaticPlugin(cloudNotifications, cloudNotifications->metaData());
connect(m_configuration, &GuhConfiguration::localeChanged, this, &GuhCore::onLocaleChanged); connect(m_configuration, &GuhConfiguration::localeChanged, this, &NymeaCore::onLocaleChanged);
connect(m_configuration, &GuhConfiguration::cloudEnabledChanged, m_cloudManager, &CloudManager::setEnabled); connect(m_configuration, &GuhConfiguration::cloudEnabledChanged, m_cloudManager, &CloudManager::setEnabled);
connect(m_configuration, &GuhConfiguration::serverNameChanged, m_cloudManager, &CloudManager::setDeviceName); connect(m_configuration, &GuhConfiguration::serverNameChanged, m_cloudManager, &CloudManager::setDeviceName);
connect(m_configuration, &GuhConfiguration::serverNameChanged, m_serverManager, &ServerManager::setServerName); connect(m_configuration, &GuhConfiguration::serverNameChanged, m_serverManager, &ServerManager::setServerName);
connect(m_deviceManager, &DeviceManager::pluginConfigChanged, this, &GuhCore::pluginConfigChanged); connect(m_deviceManager, &DeviceManager::pluginConfigChanged, this, &NymeaCore::pluginConfigChanged);
connect(m_deviceManager, &DeviceManager::eventTriggered, this, &GuhCore::gotEvent); connect(m_deviceManager, &DeviceManager::eventTriggered, this, &NymeaCore::gotEvent);
connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &GuhCore::deviceStateChanged); connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &NymeaCore::deviceStateChanged);
connect(m_deviceManager, &DeviceManager::deviceAdded, this, &GuhCore::deviceAdded); connect(m_deviceManager, &DeviceManager::deviceAdded, this, &NymeaCore::deviceAdded);
connect(m_deviceManager, &DeviceManager::deviceChanged, this, &GuhCore::deviceChanged); connect(m_deviceManager, &DeviceManager::deviceChanged, this, &NymeaCore::deviceChanged);
connect(m_deviceManager, &DeviceManager::deviceRemoved, this, &GuhCore::deviceRemoved); connect(m_deviceManager, &DeviceManager::deviceRemoved, this, &NymeaCore::deviceRemoved);
connect(m_deviceManager, &DeviceManager::deviceDisappeared, this, &GuhCore::onDeviceDisappeared); connect(m_deviceManager, &DeviceManager::deviceDisappeared, this, &NymeaCore::onDeviceDisappeared);
connect(m_deviceManager, &DeviceManager::actionExecutionFinished, this, &GuhCore::actionExecutionFinished); connect(m_deviceManager, &DeviceManager::actionExecutionFinished, this, &NymeaCore::actionExecutionFinished);
connect(m_deviceManager, &DeviceManager::devicesDiscovered, this, &GuhCore::devicesDiscovered); connect(m_deviceManager, &DeviceManager::devicesDiscovered, this, &NymeaCore::devicesDiscovered);
connect(m_deviceManager, &DeviceManager::deviceSetupFinished, this, &GuhCore::deviceSetupFinished); connect(m_deviceManager, &DeviceManager::deviceSetupFinished, this, &NymeaCore::deviceSetupFinished);
connect(m_deviceManager, &DeviceManager::deviceReconfigurationFinished, this, &GuhCore::deviceReconfigurationFinished); connect(m_deviceManager, &DeviceManager::deviceReconfigurationFinished, this, &NymeaCore::deviceReconfigurationFinished);
connect(m_deviceManager, &DeviceManager::pairingFinished, this, &GuhCore::pairingFinished); connect(m_deviceManager, &DeviceManager::pairingFinished, this, &NymeaCore::pairingFinished);
connect(m_deviceManager, &DeviceManager::loaded, this, &GuhCore::deviceManagerLoaded); connect(m_deviceManager, &DeviceManager::loaded, this, &NymeaCore::deviceManagerLoaded);
connect(m_ruleEngine, &RuleEngine::ruleAdded, this, &GuhCore::ruleAdded); connect(m_ruleEngine, &RuleEngine::ruleAdded, this, &NymeaCore::ruleAdded);
connect(m_ruleEngine, &RuleEngine::ruleRemoved, this, &GuhCore::ruleRemoved); connect(m_ruleEngine, &RuleEngine::ruleRemoved, this, &NymeaCore::ruleRemoved);
connect(m_ruleEngine, &RuleEngine::ruleConfigurationChanged, this, &GuhCore::ruleConfigurationChanged); connect(m_ruleEngine, &RuleEngine::ruleConfigurationChanged, this, &NymeaCore::ruleConfigurationChanged);
connect(m_timeManager, &TimeManager::dateTimeChanged, this, &GuhCore::onDateTimeChanged); connect(m_timeManager, &TimeManager::dateTimeChanged, this, &NymeaCore::onDateTimeChanged);
connect(m_timeManager, &TimeManager::tick, m_deviceManager, &DeviceManager::timeTick); connect(m_timeManager, &TimeManager::tick, m_deviceManager, &DeviceManager::timeTick);
m_logger->logSystemEvent(m_timeManager->currentDateTime(), true); m_logger->logSystemEvent(m_timeManager->currentDateTime(), true);
@ -554,7 +554,7 @@ void GuhCore::init() {
/*! Connected to the DeviceManager's emitEvent signal. Events received in /*! Connected to the DeviceManager's emitEvent signal. Events received in
here will be evaluated by the \l{RuleEngine} and the according \l{RuleAction}{RuleActions} are executed.*/ here will be evaluated by the \l{RuleEngine} and the according \l{RuleAction}{RuleActions} are executed.*/
void GuhCore::gotEvent(const Event &event) void NymeaCore::gotEvent(const Event &event)
{ {
m_logger->logEvent(event); m_logger->logEvent(event);
emit eventTriggered(event); emit eventTriggered(event);
@ -610,7 +610,7 @@ void GuhCore::gotEvent(const Event &event)
executeRuleActions(actions); executeRuleActions(actions);
} }
void GuhCore::onDateTimeChanged(const QDateTime &dateTime) void NymeaCore::onDateTimeChanged(const QDateTime &dateTime)
{ {
QList<RuleAction> actions; QList<RuleAction> actions;
foreach (const Rule &rule, m_ruleEngine->evaluateTime(dateTime)) { foreach (const Rule &rule, m_ruleEngine->evaluateTime(dateTime)) {
@ -634,37 +634,37 @@ void GuhCore::onDateTimeChanged(const QDateTime &dateTime)
executeRuleActions(actions); executeRuleActions(actions);
} }
void GuhCore::onLocaleChanged() void NymeaCore::onLocaleChanged()
{ {
m_deviceManager->setLocale(m_configuration->locale()); m_deviceManager->setLocale(m_configuration->locale());
} }
/*! Return the instance of the log engine */ /*! Return the instance of the log engine */
LogEngine* GuhCore::logEngine() const LogEngine* NymeaCore::logEngine() const
{ {
return m_logger; return m_logger;
} }
/*! Returns the pointer to the \l{JsonRPCServer} of this instance. */ /*! Returns the pointer to the \l{JsonRPCServer} of this instance. */
JsonRPCServer *GuhCore::jsonRPCServer() const JsonRPCServer *NymeaCore::jsonRPCServer() const
{ {
return m_serverManager->jsonServer(); return m_serverManager->jsonServer();
} }
/*! Returns the pointer to the \l{RestServer} of this instance. */ /*! Returns the pointer to the \l{RestServer} of this instance. */
RestServer *GuhCore::restServer() const RestServer *NymeaCore::restServer() const
{ {
return m_serverManager->restServer(); return m_serverManager->restServer();
} }
void GuhCore::actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status) void NymeaCore::actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status)
{ {
emit actionExecuted(id, status); emit actionExecuted(id, status);
Action action = m_pendingActions.take(id); Action action = m_pendingActions.take(id);
m_logger->logAction(action, status == DeviceManager::DeviceErrorNoError ? Logging::LoggingLevelInfo : Logging::LoggingLevelAlert, status); m_logger->logAction(action, status == DeviceManager::DeviceErrorNoError ? Logging::LoggingLevelInfo : Logging::LoggingLevelAlert, status);
} }
void GuhCore::onDeviceDisappeared(const DeviceId &deviceId) void NymeaCore::onDeviceDisappeared(const DeviceId &deviceId)
{ {
Device *device = m_deviceManager->findConfiguredDevice(deviceId); Device *device = m_deviceManager->findConfiguredDevice(deviceId);
if (!device) { if (!device) {
@ -718,7 +718,7 @@ void GuhCore::onDeviceDisappeared(const DeviceId &deviceId)
} }
} }
void GuhCore::deviceManagerLoaded() void NymeaCore::deviceManagerLoaded()
{ {
// Do some houskeeping... // Do some houskeeping...
qCDebug(dcApplication()) << "Starting housekeeping..."; qCDebug(dcApplication()) << "Starting housekeeping...";

View File

@ -19,8 +19,8 @@
* * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef GUHCORE_H #ifndef NYMEACORE_H
#define GUHCORE_H #define NYMEACORE_H
#include "rule.h" #include "rule.h"
#include "types/event.h" #include "types/event.h"
@ -50,14 +50,14 @@ class JsonRPCServer;
class LogEngine; class LogEngine;
class NetworkManager; class NetworkManager;
class GuhCore : public QObject class NymeaCore : public QObject
{ {
Q_OBJECT Q_OBJECT
friend class GuhTestBase; friend class GuhTestBase;
public: public:
static GuhCore* instance(); static NymeaCore* instance();
~GuhCore(); ~NymeaCore();
void destroy(); void destroy();
@ -108,8 +108,8 @@ signals:
void ruleConfigurationChanged(const Rule &rule); void ruleConfigurationChanged(const Rule &rule);
private: private:
explicit GuhCore(QObject *parent = 0); explicit NymeaCore(QObject *parent = 0);
static GuhCore *s_instance; static NymeaCore *s_instance;
ServerManager *m_serverManager; ServerManager *m_serverManager;
DeviceManager *m_deviceManager; DeviceManager *m_deviceManager;
@ -138,4 +138,4 @@ private slots:
} }
#endif // GUHCORE_H #endif // NYMEACORE_H

View File

@ -24,6 +24,7 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QDebug> #include <QDebug>
#include <QDBusServiceWatcher> #include <QDBusServiceWatcher>
#include <QDBusMessage>
namespace guhserver { namespace guhserver {

View File

@ -22,6 +22,8 @@
#define PUSHBUTTONDBUSSERVICE_H #define PUSHBUTTONDBUSSERVICE_H
#include <QObject> #include <QObject>
#include <QDBusObjectPath>
#include "usermanager.h" #include "usermanager.h"
#include "guhdbusservice.h" #include "guhdbusservice.h"

View File

@ -37,7 +37,7 @@
#include "deviceclassesresource.h" #include "deviceclassesresource.h"
#include "httprequest.h" #include "httprequest.h"
#include "guhcore.h" #include "nymeacore.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -47,7 +47,7 @@ namespace guhserver {
DeviceClassesResource::DeviceClassesResource(QObject *parent) : DeviceClassesResource::DeviceClassesResource(QObject *parent) :
RestResource(parent) RestResource(parent)
{ {
connect(GuhCore::instance(), &GuhCore::devicesDiscovered, this, &DeviceClassesResource::devicesDiscovered, Qt::QueuedConnection); connect(NymeaCore::instance(), &NymeaCore::devicesDiscovered, this, &DeviceClassesResource::devicesDiscovered, Qt::QueuedConnection);
} }
/*! Returns the name of the \l{RestResource}. In this case \b deviceclasses. /*! Returns the name of the \l{RestResource}. In this case \b deviceclasses.
@ -76,7 +76,7 @@ HttpReply *DeviceClassesResource::proccessRequest(const HttpRequest &request, co
qCWarning(dcRest) << "Could not parse DeviceClassId:" << urlTokens.at(3); qCWarning(dcRest) << "Could not parse DeviceClassId:" << urlTokens.at(3);
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound); return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound);
} }
m_deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId); m_deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
if (!m_deviceClass.isValid()) { if (!m_deviceClass.isValid()) {
qCWarning(dcRest) << "DeviceClassId" << deviceClassId.toString() << "not found"; qCWarning(dcRest) << "DeviceClassId" << deviceClassId.toString() << "not found";
return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceClassNotFound); return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceClassNotFound);
@ -265,7 +265,7 @@ HttpReply *DeviceClassesResource::getDiscoverdDevices(const ParamList &discovery
qCDebug(dcRest) << "Discover devices for DeviceClass" << m_deviceClass.id(); qCDebug(dcRest) << "Discover devices for DeviceClass" << m_deviceClass.id();
qCDebug(dcRest) << discoveryParams; qCDebug(dcRest) << discoveryParams;
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(m_deviceClass.id(), discoveryParams); DeviceManager::DeviceError status = NymeaCore::instance()->deviceManager()->discoverDevices(m_deviceClass.id(), discoveryParams);
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {
HttpReply *reply = createAsyncReply(); HttpReply *reply = createAsyncReply();

View File

@ -40,7 +40,7 @@
#include "httpreply.h" #include "httpreply.h"
#include "httprequest.h" #include "httprequest.h"
#include "jsonrpc/jsontypes.h" #include "jsonrpc/jsontypes.h"
#include "guhcore.h" #include "nymeacore.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -50,10 +50,10 @@ namespace guhserver {
DevicesResource::DevicesResource(QObject *parent) : DevicesResource::DevicesResource(QObject *parent) :
RestResource(parent) RestResource(parent)
{ {
connect(GuhCore::instance(), &GuhCore::actionExecuted, this, &DevicesResource::actionExecuted); connect(NymeaCore::instance(), &NymeaCore::actionExecuted, this, &DevicesResource::actionExecuted);
connect(GuhCore::instance(), &GuhCore::deviceSetupFinished, this, &DevicesResource::deviceSetupFinished); connect(NymeaCore::instance(), &NymeaCore::deviceSetupFinished, this, &DevicesResource::deviceSetupFinished);
connect(GuhCore::instance(), &GuhCore::deviceReconfigurationFinished, this, &DevicesResource::deviceReconfigurationFinished); connect(NymeaCore::instance(), &NymeaCore::deviceReconfigurationFinished, this, &DevicesResource::deviceReconfigurationFinished);
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DevicesResource::pairingFinished); connect(NymeaCore::instance(), &NymeaCore::pairingFinished, this, &DevicesResource::pairingFinished);
} }
/*! Returns the name of the \l{RestResource}. In this case \b devices. /*! Returns the name of the \l{RestResource}. In this case \b devices.
@ -81,7 +81,7 @@ HttpReply *DevicesResource::proccessRequest(const HttpRequest &request, const QS
qCWarning(dcRest) << "Could not parse DeviceId:" << urlTokens.at(3); qCWarning(dcRest) << "Could not parse DeviceId:" << urlTokens.at(3);
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceNotFound); return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceNotFound);
} }
m_device = GuhCore::instance()->deviceManager()->findConfiguredDevice(deviceId); m_device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(deviceId);
if (!m_device) { if (!m_device) {
qCWarning(dcRest) << "Could find any device with DeviceId:" << urlTokens.at(3); qCWarning(dcRest) << "Could find any device with DeviceId:" << urlTokens.at(3);
return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceNotFound); return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceNotFound);
@ -212,7 +212,7 @@ HttpReply *DevicesResource::proccessPostRequest(const HttpRequest &request, cons
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorActionTypeNotFound); return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorActionTypeNotFound);
} }
bool found = false; bool found = false;
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(m_device->deviceClassId()); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(m_device->deviceClassId());
foreach (const ActionType actionType, deviceClass.actionTypes()) { foreach (const ActionType actionType, deviceClass.actionTypes()) {
if (actionType.id() == actionTypeId) { if (actionType.id() == actionTypeId) {
found = true; found = true;
@ -283,7 +283,7 @@ HttpReply *DevicesResource::removeDevice(Device *device, const QVariantMap &para
// global removePolicy has priority // global removePolicy has priority
if (params.contains("removePolicy")) { if (params.contains("removePolicy")) {
RuleEngine::RemovePolicy removePolicy = params.value("removePolicy").toString() == "RemovePolicyCascade" ? RuleEngine::RemovePolicyCascade : RuleEngine::RemovePolicyUpdate; RuleEngine::RemovePolicy removePolicy = params.value("removePolicy").toString() == "RemovePolicyCascade" ? RuleEngine::RemovePolicyCascade : RuleEngine::RemovePolicyUpdate;
DeviceManager::DeviceError result = GuhCore::instance()->removeConfiguredDevice(device->id(), removePolicy); DeviceManager::DeviceError result = NymeaCore::instance()->removeConfiguredDevice(device->id(), removePolicy);
return createDeviceErrorReply(HttpReply::Ok, result); return createDeviceErrorReply(HttpReply::Ok, result);
} }
@ -294,7 +294,7 @@ HttpReply *DevicesResource::removeDevice(Device *device, const QVariantMap &para
removePolicyList.insert(ruleId, policy); removePolicyList.insert(ruleId, policy);
} }
QPair<DeviceManager::DeviceError, QList<RuleId> > status = GuhCore::instance()->removeConfiguredDevice(device->id(), removePolicyList); QPair<DeviceManager::DeviceError, QList<RuleId> > status = NymeaCore::instance()->removeConfiguredDevice(device->id(), removePolicyList);
// if there are offending rules // if there are offending rules
if (!status.second.isEmpty()) { if (!status.second.isEmpty()) {
@ -337,7 +337,7 @@ HttpReply *DevicesResource::executeAction(Device *device, const ActionTypeId &ac
Action action(actionTypeId, device->id()); Action action(actionTypeId, device->id());
action.setParams(actionParams); action.setParams(actionParams);
DeviceManager::DeviceError status = GuhCore::instance()->executeAction(action); DeviceManager::DeviceError status = NymeaCore::instance()->executeAction(action);
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {
HttpReply *reply = createAsyncReply(); HttpReply *reply = createAsyncReply();
m_asyncActionExecutions.insert(action.id(), reply); m_asyncActionExecutions.insert(action.id(), reply);
@ -370,10 +370,10 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
DeviceManager::DeviceError status; DeviceManager::DeviceError status;
if (deviceDescriptorId.isNull()) { if (deviceDescriptorId.isNull()) {
qCDebug(dcRest) << "Adding device" << deviceName << "with" << deviceParams; qCDebug(dcRest) << "Adding device" << deviceName << "with" << deviceParams;
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceParams, newDeviceId); status = NymeaCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceParams, newDeviceId);
} else { } else {
qCDebug(dcRest) << "Adding discovered device" << deviceName << "with DeviceDescriptorId" << deviceDescriptorId.toString(); qCDebug(dcRest) << "Adding discovered device" << deviceName << "with DeviceDescriptorId" << deviceDescriptorId.toString();
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceDescriptorId, newDeviceId); status = NymeaCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceDescriptorId, newDeviceId);
} }
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {
HttpReply *reply = createAsyncReply(); HttpReply *reply = createAsyncReply();
@ -385,7 +385,7 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
if (status != DeviceManager::DeviceErrorNoError) if (status != DeviceManager::DeviceErrorNoError)
return createDeviceErrorReply(HttpReply::InternalServerError, status); return createDeviceErrorReply(HttpReply::InternalServerError, status);
QVariant result = JsonTypes::packDevice(GuhCore::instance()->deviceManager()->findConfiguredDevice(newDeviceId)); QVariant result = JsonTypes::packDevice(NymeaCore::instance()->deviceManager()->findConfiguredDevice(newDeviceId));
HttpReply *reply = createSuccessReply(); HttpReply *reply = createSuccessReply();
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";"); reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
reply->setPayload(QJsonDocument::fromVariant(result).toJson()); reply->setPayload(QJsonDocument::fromVariant(result).toJson());
@ -400,7 +400,7 @@ HttpReply *DevicesResource::editDevice(const QByteArray &payload) const
QVariantMap params = verification.second.toMap(); QVariantMap params = verification.second.toMap();
QString name = params.value("name").toString(); QString name = params.value("name").toString();
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->editDevice(m_device->id(), name); DeviceManager::DeviceError status = NymeaCore::instance()->deviceManager()->editDevice(m_device->id(), name);
if (status != DeviceManager::DeviceErrorNoError) if (status != DeviceManager::DeviceErrorNoError)
return createDeviceErrorReply(HttpReply::BadRequest, status); return createDeviceErrorReply(HttpReply::BadRequest, status);
@ -417,7 +417,7 @@ HttpReply *DevicesResource::pairDevice(const QByteArray &payload) const
QVariantMap params = verification.second.toMap(); QVariantMap params = verification.second.toMap();
DeviceClassId deviceClassId(params.value("deviceClassId").toString()); DeviceClassId deviceClassId(params.value("deviceClassId").toString());
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
if (deviceClassId.isNull()) { if (deviceClassId.isNull()) {
qCWarning(dcRest) << "Could not find deviceClassId" << params.value("deviceClassId").toString(); qCWarning(dcRest) << "Could not find deviceClassId" << params.value("deviceClassId").toString();
@ -432,10 +432,10 @@ HttpReply *DevicesResource::pairDevice(const QByteArray &payload) const
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId(); PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
if (params.contains("deviceDescriptorId")) { if (params.contains("deviceDescriptorId")) {
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString()); DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceDescriptorId); status = NymeaCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceDescriptorId);
} else { } else {
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList()); ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceParams); status = NymeaCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceParams);
} }
if (status != DeviceManager::DeviceErrorNoError) if (status != DeviceManager::DeviceErrorNoError)
@ -461,7 +461,7 @@ HttpReply *DevicesResource::confirmPairDevice(const QByteArray &payload) const
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString()); PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").toString());
QString secret = params.value("secret").toString(); QString secret = params.value("secret").toString();
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->confirmPairing(pairingTransactionId, secret); DeviceManager::DeviceError status = NymeaCore::instance()->deviceManager()->confirmPairing(pairingTransactionId, secret);
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {
HttpReply *reply = createAsyncReply(); HttpReply *reply = createAsyncReply();
@ -490,10 +490,10 @@ HttpReply *DevicesResource::reconfigureDevice(Device *device, const QByteArray &
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString()); DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
if (deviceDescriptorId.isNull()) { if (deviceDescriptorId.isNull()) {
qCDebug(dcRest) << "Reconfigure device with params:" << deviceParams; qCDebug(dcRest) << "Reconfigure device with params:" << deviceParams;
status = GuhCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceParams); status = NymeaCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceParams);
} else { } else {
qCDebug(dcRest) << "Reconfigure device using the new discovered device with descriptorId:" << deviceDescriptorId.toString(); qCDebug(dcRest) << "Reconfigure device using the new discovered device with descriptorId:" << deviceDescriptorId.toString();
status = GuhCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceDescriptorId); status = NymeaCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceDescriptorId);
} }
if (status == DeviceManager::DeviceErrorAsync) { if (status == DeviceManager::DeviceErrorAsync) {

View File

@ -38,7 +38,7 @@
#include "logsresource.h" #include "logsresource.h"
#include "httprequest.h" #include "httprequest.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
#include "logging/logengine.h" #include "logging/logengine.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -108,7 +108,7 @@ HttpReply *LogsResource::getLogEntries(const QString &filterString)
LogFilter filter = JsonTypes::unpackLogFilter(filterMap); LogFilter filter = JsonTypes::unpackLogFilter(filterMap);
QVariantList entries; QVariantList entries;
foreach (const LogEntry &entry, GuhCore::instance()->logEngine()->logEntries(filter)) { foreach (const LogEntry &entry, NymeaCore::instance()->logEngine()->logEntries(filter)) {
entries.append(JsonTypes::packLogEntry(entry)); entries.append(JsonTypes::packLogEntry(entry));
} }
HttpReply *reply = createSuccessReply(); HttpReply *reply = createSuccessReply();

View File

@ -38,7 +38,7 @@
#include "pluginsresource.h" #include "pluginsresource.h"
#include "httprequest.h" #include "httprequest.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -147,7 +147,7 @@ HttpReply *PluginsResource::getPlugin(const PluginId &pluginId) const
{ {
qCDebug(dcRest) << "Get plugin with id" << pluginId; qCDebug(dcRest) << "Get plugin with id" << pluginId;
HttpReply *reply = createSuccessReply(); HttpReply *reply = createSuccessReply();
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) { foreach (DevicePlugin *plugin, NymeaCore::instance()->deviceManager()->plugins()) {
if (plugin->pluginId() == pluginId) { if (plugin->pluginId() == pluginId) {
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";"); reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packPlugin(plugin)).toJson()); reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packPlugin(plugin)).toJson());
@ -193,7 +193,7 @@ HttpReply *PluginsResource::setPluginConfiguration(const PluginId &pluginId, con
QVariantList configuration = verification.second.toList(); QVariantList configuration = verification.second.toList();
ParamList pluginParams = JsonTypes::unpackParams(configuration); ParamList pluginParams = JsonTypes::unpackParams(configuration);
qCDebug(dcRest) << pluginParams; qCDebug(dcRest) << pluginParams;
DeviceManager::DeviceError result = GuhCore::instance()->deviceManager()->setPluginConfig(pluginId, pluginParams); DeviceManager::DeviceError result = NymeaCore::instance()->deviceManager()->setPluginConfig(pluginId, pluginParams);
if (result != DeviceManager::DeviceErrorNoError) if (result != DeviceManager::DeviceErrorNoError)
return createDeviceErrorReply(HttpReply::BadRequest, result); return createDeviceErrorReply(HttpReply::BadRequest, result);
@ -203,7 +203,7 @@ HttpReply *PluginsResource::setPluginConfiguration(const PluginId &pluginId, con
DevicePlugin *PluginsResource::findPlugin(const PluginId &pluginId) const DevicePlugin *PluginsResource::findPlugin(const PluginId &pluginId) const
{ {
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) { foreach (DevicePlugin *plugin, NymeaCore::instance()->deviceManager()->plugins()) {
if (plugin->pluginId() == pluginId) { if (plugin->pluginId() == pluginId) {
return plugin; return plugin;
} }

View File

@ -61,7 +61,6 @@
#include "httprequest.h" #include "httprequest.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "guhcore.h"
#include <QJsonDocument> #include <QJsonDocument>
#include <QVariant> #include <QVariant>

View File

@ -38,7 +38,6 @@
#include "loggingcategories.h" #include "loggingcategories.h"
#include "httprequest.h" #include "httprequest.h"
#include "httpreply.h" #include "httpreply.h"
#include "guhcore.h"
#include <QJsonDocument> #include <QJsonDocument>
#include <QSslConfiguration> #include <QSslConfiguration>

View File

@ -39,7 +39,7 @@
#include "httprequest.h" #include "httprequest.h"
#include "typeutils.h" #include "typeutils.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -75,7 +75,7 @@ HttpReply *RulesResource::proccessRequest(const HttpRequest &request, const QStr
return createRuleErrorReply(HttpReply::BadRequest, RuleEngine::RuleErrorRuleNotFound); return createRuleErrorReply(HttpReply::BadRequest, RuleEngine::RuleErrorRuleNotFound);
} }
if (!GuhCore::instance()->ruleEngine()->findRule(m_ruleId).isValid()) { if (!NymeaCore::instance()->ruleEngine()->findRule(m_ruleId).isValid()) {
qCWarning(dcRest) << "Could not find rule with id" << m_ruleId.toString(); qCWarning(dcRest) << "Could not find rule with id" << m_ruleId.toString();
return createRuleErrorReply(HttpReply::NotFound, RuleEngine::RuleErrorRuleNotFound); return createRuleErrorReply(HttpReply::NotFound, RuleEngine::RuleErrorRuleNotFound);
} }
@ -199,10 +199,10 @@ HttpReply *RulesResource::getRules(const DeviceId &deviceId) const
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packRuleDescriptions()).toJson()); reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packRuleDescriptions()).toJson());
} else { } else {
qCDebug(dcRest) << "Get rule descriptions which contain the device with id" << deviceId.toString(); qCDebug(dcRest) << "Get rule descriptions which contain the device with id" << deviceId.toString();
QList<RuleId> ruleIdsList = GuhCore::instance()->ruleEngine()->findRules(deviceId); QList<RuleId> ruleIdsList = NymeaCore::instance()->ruleEngine()->findRules(deviceId);
QList<Rule> ruleList; QList<Rule> ruleList;
foreach (const RuleId &ruleId, ruleIdsList) { foreach (const RuleId &ruleId, ruleIdsList) {
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId); Rule rule = NymeaCore::instance()->ruleEngine()->findRule(ruleId);
if (rule.isValid()) if (rule.isValid())
ruleList.append(rule); ruleList.append(rule);
} }
@ -217,7 +217,7 @@ HttpReply *RulesResource::getRuleDetails(const RuleId &ruleId) const
qCDebug(dcRest) << "Get rule details"; qCDebug(dcRest) << "Get rule details";
// Note: rule existence already checked // Note: rule existence already checked
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId); Rule rule = NymeaCore::instance()->ruleEngine()->findRule(ruleId);
HttpReply *reply = createSuccessReply(); HttpReply *reply = createSuccessReply();
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";"); reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
@ -229,7 +229,7 @@ HttpReply *RulesResource::removeRule(const RuleId &ruleId) const
{ {
qCDebug(dcRest) << "Remove rule with id" << ruleId.toString(); qCDebug(dcRest) << "Remove rule with id" << ruleId.toString();
RuleEngine::RuleError status = GuhCore::instance()->removeRule(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->removeRule(ruleId);
if (status != RuleEngine::RuleErrorNoError) if (status != RuleEngine::RuleErrorNoError)
return createRuleErrorReply(HttpReply::InternalServerError, status); return createRuleErrorReply(HttpReply::InternalServerError, status);
@ -248,9 +248,9 @@ HttpReply *RulesResource::addRule(const QByteArray &payload) const
Rule rule = JsonTypes::unpackRule(params); Rule rule = JsonTypes::unpackRule(params);
rule.setId(RuleId::createRuleId()); rule.setId(RuleId::createRuleId());
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->addRule(rule); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->addRule(rule);
if (status == RuleEngine::RuleErrorNoError) { if (status == RuleEngine::RuleErrorNoError) {
QVariant returns = JsonTypes::packRule(GuhCore::instance()->ruleEngine()->findRule(rule.id())); QVariant returns = JsonTypes::packRule(NymeaCore::instance()->ruleEngine()->findRule(rule.id()));
HttpReply *reply = createSuccessReply(); HttpReply *reply = createSuccessReply();
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";"); reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
reply->setPayload(QJsonDocument::fromVariant(returns).toJson()); reply->setPayload(QJsonDocument::fromVariant(returns).toJson());
@ -264,7 +264,7 @@ HttpReply *RulesResource::enableRule(const RuleId &ruleId) const
{ {
qCDebug(dcRest) << "Enable rule with id" << ruleId.toString(); qCDebug(dcRest) << "Enable rule with id" << ruleId.toString();
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->enableRule(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->enableRule(ruleId);
if (status != RuleEngine::RuleErrorNoError) if (status != RuleEngine::RuleErrorNoError)
return createRuleErrorReply(HttpReply::InternalServerError, status); return createRuleErrorReply(HttpReply::InternalServerError, status);
@ -275,7 +275,7 @@ HttpReply *RulesResource::disableRule(const RuleId &ruleId) const
{ {
qCDebug(dcRest) << "Disable rule with id" << ruleId.toString(); qCDebug(dcRest) << "Disable rule with id" << ruleId.toString();
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->disableRule(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->disableRule(ruleId);
if (status != RuleEngine::RuleErrorNoError) if (status != RuleEngine::RuleErrorNoError)
return createRuleErrorReply(HttpReply::InternalServerError, status); return createRuleErrorReply(HttpReply::InternalServerError, status);
@ -286,7 +286,7 @@ HttpReply *RulesResource::executeActions(const RuleId &ruleId) const
{ {
qCDebug(dcRest) << "Execute actions of rule with id" << ruleId.toString(); qCDebug(dcRest) << "Execute actions of rule with id" << ruleId.toString();
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeActions(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->executeActions(ruleId);
if (status != RuleEngine::RuleErrorNoError) if (status != RuleEngine::RuleErrorNoError)
return createRuleErrorReply(HttpReply::InternalServerError, status); return createRuleErrorReply(HttpReply::InternalServerError, status);
@ -297,7 +297,7 @@ HttpReply *RulesResource::executeExitActions(const RuleId &ruleId) const
{ {
qCDebug(dcRest) << "Execute exit actions of rule with id" << ruleId.toString(); qCDebug(dcRest) << "Execute exit actions of rule with id" << ruleId.toString();
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeExitActions(ruleId); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->executeExitActions(ruleId);
if (status != RuleEngine::RuleErrorNoError) if (status != RuleEngine::RuleErrorNoError)
return createRuleErrorReply(HttpReply::InternalServerError, status); return createRuleErrorReply(HttpReply::InternalServerError, status);
@ -315,7 +315,7 @@ HttpReply *RulesResource::editRule(const RuleId &ruleId, const QByteArray &paylo
QVariantMap params = verification.second.toMap(); QVariantMap params = verification.second.toMap();
Rule rule = JsonTypes::unpackRule(params); Rule rule = JsonTypes::unpackRule(params);
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->editRule(rule); RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->editRule(rule);
if (status == RuleEngine::RuleErrorNoError) { if (status == RuleEngine::RuleErrorNoError) {
qCDebug(dcRest) << "Edit rule successfully finished"; qCDebug(dcRest) << "Edit rule successfully finished";
return createRuleErrorReply(HttpReply::Ok, status); return createRuleErrorReply(HttpReply::Ok, status);

View File

@ -39,7 +39,7 @@
#include "vendorsresource.h" #include "vendorsresource.h"
#include "httprequest.h" #include "httprequest.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -110,7 +110,7 @@ HttpReply *VendorsResource::getVendors() const
HttpReply *reply = createSuccessReply(); HttpReply *reply = createSuccessReply();
QVariantList vendorsList; QVariantList vendorsList;
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) { foreach (const Vendor &vendor, NymeaCore::instance()->deviceManager()->supportedVendors()) {
vendorsList.append(JsonTypes::packVendor(vendor)); vendorsList.append(JsonTypes::packVendor(vendor));
} }
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";"); reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
@ -121,7 +121,7 @@ HttpReply *VendorsResource::getVendors() const
HttpReply *VendorsResource::getVendor(const VendorId &vendorId) const HttpReply *VendorsResource::getVendor(const VendorId &vendorId) const
{ {
qCDebug(dcRest) << "Get vendor with id" << vendorId; qCDebug(dcRest) << "Get vendor with id" << vendorId;
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) { foreach (const Vendor &vendor, NymeaCore::instance()->deviceManager()->supportedVendors()) {
if (vendor.id() == vendorId) { if (vendor.id() == vendorId) {
HttpReply *reply = createSuccessReply(); HttpReply *reply = createSuccessReply();
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";"); reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");

View File

@ -99,7 +99,7 @@
#include "ruleengine.h" #include "ruleengine.h"
#include "guhcore.h" #include "nymeacore.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "time/calendaritem.h" #include "time/calendaritem.h"
#include "time/repeatingoption.h" #include "time/repeatingoption.h"
@ -119,7 +119,7 @@
namespace guhserver { namespace guhserver {
/*! Constructs the RuleEngine with the given \a parent. Although it wouldn't harm to have multiple RuleEngines, there is one /*! Constructs the RuleEngine with the given \a parent. Although it wouldn't harm to have multiple RuleEngines, there is one
instance available from \l{GuhCore}. This one should be used instead of creating multiple ones. instance available from \l{NymeaCore}. This one should be used instead of creating multiple ones.
*/ */
RuleEngine::RuleEngine(QObject *parent) : RuleEngine::RuleEngine(QObject *parent) :
QObject(parent) QObject(parent)
@ -332,7 +332,7 @@ RuleEngine::~RuleEngine()
*/ */
QList<Rule> RuleEngine::evaluateEvent(const Event &event) QList<Rule> RuleEngine::evaluateEvent(const Event &event)
{ {
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(event.deviceId()); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(event.deviceId());
qCDebug(dcRuleEngineDebug) << "Evaluate event:" << event << device->name() << event.eventTypeId(); qCDebug(dcRuleEngineDebug) << "Evaluate event:" << event << device->name() << event.eventTypeId();
@ -471,14 +471,14 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
if (eventDescriptor.type() == EventDescriptor::TypeDevice) { if (eventDescriptor.type() == EventDescriptor::TypeDevice) {
// check deviceId // check deviceId
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(eventDescriptor.deviceId()); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(eventDescriptor.deviceId());
if (!device) { if (!device) {
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for eventTypeId" << eventDescriptor.eventTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for eventTypeId" << eventDescriptor.eventTypeId();
return RuleErrorDeviceNotFound; return RuleErrorDeviceNotFound;
} }
// Check eventTypeId for this deivce // Check eventTypeId for this deivce
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
bool eventTypeFound = false; bool eventTypeFound = false;
foreach (const EventType &eventType, deviceClass.eventTypes()) { foreach (const EventType &eventType, deviceClass.eventTypes()) {
if (eventType.id() == eventDescriptor.eventTypeId()) { if (eventType.id() == eventDescriptor.eventTypeId()) {
@ -491,7 +491,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
} else { } else {
// Interface based event // Interface based event
Interface iface = GuhCore::instance()->deviceManager()->supportedInterfaces().findByName(eventDescriptor.interface()); Interface iface = NymeaCore::instance()->deviceManager()->supportedInterfaces().findByName(eventDescriptor.interface());
if (!iface.isValid()) { if (!iface.isValid()) {
qWarning(dcRuleEngine()) << "No such interface:" << eventDescriptor.interface(); qWarning(dcRuleEngine()) << "No such interface:" << eventDescriptor.interface();
return RuleErrorInterfaceNotFound; return RuleErrorInterfaceNotFound;
@ -558,13 +558,13 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
return RuleErrorActionTypeNotFound; return RuleErrorActionTypeNotFound;
} }
if (action.type() == RuleAction::TypeDevice) { if (action.type() == RuleAction::TypeDevice) {
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(action.deviceId()); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(action.deviceId());
if (!device) { if (!device) {
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for action with actionTypeId" << action.actionTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for action with actionTypeId" << action.actionTypeId();
return RuleErrorDeviceNotFound; return RuleErrorDeviceNotFound;
} }
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
if (!deviceClass.hasActionType(action.actionTypeId())) { if (!deviceClass.hasActionType(action.actionTypeId())) {
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << action.actionTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << action.actionTypeId();
return RuleErrorActionTypeNotFound; return RuleErrorActionTypeNotFound;
@ -602,7 +602,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
foreach (const ActionType &actionType, deviceClass.actionTypes()) { foreach (const ActionType &actionType, deviceClass.actionTypes()) {
if (actionType.id() == action.actionTypeId()) { if (actionType.id() == action.actionTypeId()) {
ParamList finalParams = action.toAction().params(); ParamList finalParams = action.toAction().params();
DeviceManager::DeviceError paramCheck = GuhCore::instance()->deviceManager()->verifyParams(actionType.paramTypes(), finalParams); DeviceManager::DeviceError paramCheck = NymeaCore::instance()->deviceManager()->verifyParams(actionType.paramTypes(), finalParams);
if (paramCheck != DeviceManager::DeviceErrorNoError) { if (paramCheck != DeviceManager::DeviceErrorNoError) {
qCWarning(dcRuleEngine) << "Cannot create rule. Got an invalid actionParam."; qCWarning(dcRuleEngine) << "Cannot create rule. Got an invalid actionParam.";
return RuleErrorInvalidRuleActionParameter; return RuleErrorInvalidRuleActionParameter;
@ -619,7 +619,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
} else { // Is TypeInterface } else { // Is TypeInterface
Interface iface = GuhCore::instance()->deviceManager()->supportedInterfaces().findByName(action.interface()); Interface iface = NymeaCore::instance()->deviceManager()->supportedInterfaces().findByName(action.interface());
if (!iface.isValid()) { if (!iface.isValid()) {
qCWarning(dcRuleEngine()) << "Cannot create rule. No such interface:" << action.interface(); qCWarning(dcRuleEngine()) << "Cannot create rule. No such interface:" << action.interface();
return RuleError::RuleErrorInterfaceNotFound; return RuleError::RuleErrorInterfaceNotFound;
@ -652,13 +652,13 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
if (ruleAction.type() == RuleAction::TypeDevice) { if (ruleAction.type() == RuleAction::TypeDevice) {
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(ruleAction.deviceId()); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(ruleAction.deviceId());
if (!device) { if (!device) {
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for exit action with actionTypeId" << ruleAction.actionTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for exit action with actionTypeId" << ruleAction.actionTypeId();
return RuleErrorDeviceNotFound; return RuleErrorDeviceNotFound;
} }
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
if (!deviceClass.hasActionType(ruleAction.actionTypeId())) { if (!deviceClass.hasActionType(ruleAction.actionTypeId())) {
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << ruleAction.actionTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << ruleAction.actionTypeId();
return RuleErrorActionTypeNotFound; return RuleErrorActionTypeNotFound;
@ -668,7 +668,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
foreach (const ActionType &actionType, deviceClass.actionTypes()) { foreach (const ActionType &actionType, deviceClass.actionTypes()) {
if (actionType.id() == ruleAction.actionTypeId()) { if (actionType.id() == ruleAction.actionTypeId()) {
ParamList finalParams = ruleAction.toAction().params(); ParamList finalParams = ruleAction.toAction().params();
DeviceManager::DeviceError paramCheck = GuhCore::instance()->deviceManager()->verifyParams(actionType.paramTypes(), finalParams); DeviceManager::DeviceError paramCheck = NymeaCore::instance()->deviceManager()->verifyParams(actionType.paramTypes(), finalParams);
if (paramCheck != DeviceManager::DeviceErrorNoError) { if (paramCheck != DeviceManager::DeviceErrorNoError) {
qCWarning(dcRuleEngine) << "Cannot create rule. Got an invalid exit actionParam."; qCWarning(dcRuleEngine) << "Cannot create rule. Got an invalid exit actionParam.";
return RuleErrorInvalidRuleActionParameter; return RuleErrorInvalidRuleActionParameter;
@ -690,7 +690,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
} else { // Is TypeInterface } else { // Is TypeInterface
Interface iface = GuhCore::instance()->deviceManager()->supportedInterfaces().findByName(ruleAction.interface()); Interface iface = NymeaCore::instance()->deviceManager()->supportedInterfaces().findByName(ruleAction.interface());
if (!iface.isValid()) { if (!iface.isValid()) {
qCWarning(dcRuleEngine()) << "Cannot create rule. No such interface:" << ruleAction.interface(); qCWarning(dcRuleEngine()) << "Cannot create rule. No such interface:" << ruleAction.interface();
return RuleError::RuleErrorInterfaceNotFound; return RuleError::RuleErrorInterfaceNotFound;
@ -831,7 +831,7 @@ RuleEngine::RuleError RuleEngine::enableRule(const RuleId &ruleId)
saveRule(rule); saveRule(rule);
emit ruleConfigurationChanged(rule); emit ruleConfigurationChanged(rule);
GuhCore::instance()->logEngine()->logRuleEnabledChanged(rule, true); NymeaCore::instance()->logEngine()->logRuleEnabledChanged(rule, true);
qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "enabled."; qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "enabled.";
return RuleErrorNoError; return RuleErrorNoError;
@ -857,7 +857,7 @@ RuleEngine::RuleError RuleEngine::disableRule(const RuleId &ruleId)
saveRule(rule); saveRule(rule);
emit ruleConfigurationChanged(rule); emit ruleConfigurationChanged(rule);
GuhCore::instance()->logEngine()->logRuleEnabledChanged(rule, false); NymeaCore::instance()->logEngine()->logRuleEnabledChanged(rule, false);
qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "disabled."; qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "disabled.";
return RuleErrorNoError; return RuleErrorNoError;
} }
@ -892,8 +892,8 @@ RuleEngine::RuleError RuleEngine::executeActions(const RuleId &ruleId)
} }
qCDebug(dcRuleEngine) << "Executing rule actions of rule" << rule.name() << rule.id(); qCDebug(dcRuleEngine) << "Executing rule actions of rule" << rule.name() << rule.id();
GuhCore::instance()->logEngine()->logRuleActionsExecuted(rule); NymeaCore::instance()->logEngine()->logRuleActionsExecuted(rule);
GuhCore::instance()->executeRuleActions(rule.actions()); NymeaCore::instance()->executeRuleActions(rule.actions());
return RuleErrorNoError; return RuleErrorNoError;
} }
@ -924,8 +924,8 @@ RuleEngine::RuleError RuleEngine::executeExitActions(const RuleId &ruleId)
} }
qCDebug(dcRuleEngine) << "Executing rule exit actions of rule" << rule.name() << rule.id(); qCDebug(dcRuleEngine) << "Executing rule exit actions of rule" << rule.name() << rule.id();
GuhCore::instance()->logEngine()->logRuleExitActionsExecuted(rule); NymeaCore::instance()->logEngine()->logRuleExitActionsExecuted(rule);
GuhCore::instance()->executeRuleActions(rule.exitActions()); NymeaCore::instance()->executeRuleActions(rule.exitActions());
return RuleErrorNoError; return RuleErrorNoError;
} }
@ -1087,7 +1087,7 @@ bool RuleEngine::containsEvent(const Rule &rule, const Event &event, const Devic
// If this is a interface based rule, the device must implement the interface // If this is a interface based rule, the device must implement the interface
if (eventDescriptor.type() == EventDescriptor::TypeInterface) { if (eventDescriptor.type() == EventDescriptor::TypeInterface) {
DeviceClass dc = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId); DeviceClass dc = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
if (!dc.interfaces().contains(eventDescriptor.interface())) { if (!dc.interfaces().contains(eventDescriptor.interface())) {
// DeviceClass for this event doesn't implement the interface for this eventDescriptor // DeviceClass for this event doesn't implement the interface for this eventDescriptor
continue; continue;
@ -1173,7 +1173,7 @@ bool RuleEngine::checkEventDescriptors(const QList<EventDescriptor> eventDescrip
QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId, const ParamTypeId &paramTypeId) QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId, const ParamTypeId &paramTypeId)
{ {
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) { foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices()) {
foreach (const ActionType &actionType, deviceClass.actionTypes()) { foreach (const ActionType &actionType, deviceClass.actionTypes()) {
if (actionType.id() == actionTypeId) { if (actionType.id() == actionTypeId) {
foreach (const ParamType &paramType, actionType.paramTypes()) { foreach (const ParamType &paramType, actionType.paramTypes()) {
@ -1190,7 +1190,7 @@ QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId,
QVariant::Type RuleEngine::getEventParamType(const EventTypeId &eventTypeId, const ParamTypeId &paramTypeId) QVariant::Type RuleEngine::getEventParamType(const EventTypeId &eventTypeId, const ParamTypeId &paramTypeId)
{ {
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) { foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices()) {
foreach (const EventType &eventType, deviceClass.eventTypes()) { foreach (const EventType &eventType, deviceClass.eventTypes()) {
if (eventType.id() == eventTypeId) { if (eventType.id() == eventTypeId) {
foreach (const ParamType &paramType, eventType.paramTypes()) { foreach (const ParamType &paramType, eventType.paramTypes()) {

View File

@ -34,7 +34,7 @@
*/ */
#include "servermanager.h" #include "servermanager.h"
#include "guhcore.h" #include "nymeacore.h"
#include "certificategenerator.h" #include "certificategenerator.h"
#include <QSslCertificate> #include <QSslCertificate>
@ -155,7 +155,7 @@ MockTcpServer *ServerManager::mockTcpServer() const
void ServerManager::tcpServerConfigurationChanged(const QString &id) void ServerManager::tcpServerConfigurationChanged(const QString &id)
{ {
ServerConfiguration config = GuhCore::instance()->configuration()->tcpServerConfigurations().value(id); ServerConfiguration config = NymeaCore::instance()->configuration()->tcpServerConfigurations().value(id);
TcpServer *server = m_tcpServers.value(id); TcpServer *server = m_tcpServers.value(id);
if (server) { if (server) {
qDebug(dcConnection) << "Restarting TCP server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled"); qDebug(dcConnection) << "Restarting TCP server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
@ -185,7 +185,7 @@ void ServerManager::tcpServerConfigurationRemoved(const QString &id)
void ServerManager::webSocketServerConfigurationChanged(const QString &id) void ServerManager::webSocketServerConfigurationChanged(const QString &id)
{ {
WebSocketServer *server = m_webSocketServers.value(id); WebSocketServer *server = m_webSocketServers.value(id);
ServerConfiguration config = GuhCore::instance()->configuration()->webSocketServerConfigurations().value(id); ServerConfiguration config = NymeaCore::instance()->configuration()->webSocketServerConfigurations().value(id);
if (server) { if (server) {
qDebug(dcConnection) << "Restarting WebSocket server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled"); qDebug(dcConnection) << "Restarting WebSocket server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
server->stopServer(); server->stopServer();
@ -213,7 +213,7 @@ void ServerManager::webSocketServerConfigurationRemoved(const QString &id)
void ServerManager::webServerConfigurationChanged(const QString &id) void ServerManager::webServerConfigurationChanged(const QString &id)
{ {
WebServerConfiguration config = GuhCore::instance()->configuration()->webServerConfigurations().value(id); WebServerConfiguration config = NymeaCore::instance()->configuration()->webServerConfigurations().value(id);
WebServer *server = m_webServers.value(id); WebServer *server = m_webServers.value(id);
if (server) { if (server) {
qDebug(dcConnection) << "Restarting Web server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled"); qDebug(dcConnection) << "Restarting Web server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");

View File

@ -35,7 +35,7 @@
#include "stateevaluator.h" #include "stateevaluator.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "nymeasettings.h" #include "nymeasettings.h"
@ -100,7 +100,7 @@ void StateEvaluator::setOperatorType(Types::StateOperator operatorType)
bool StateEvaluator::evaluate() const bool StateEvaluator::evaluate() const
{ {
if (m_stateDescriptor.isValid()) { if (m_stateDescriptor.isValid()) {
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId()); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
if (!device) { if (!device) {
qCWarning(dcRuleEngine) << "Device not existing!"; qCWarning(dcRuleEngine) << "Device not existing!";
return false; return false;
@ -220,7 +220,7 @@ StateEvaluator StateEvaluator::loadFromSettings(NymeaSettings &settings, const Q
bool StateEvaluator::isValid() const bool StateEvaluator::isValid() const
{ {
if (m_stateDescriptor.isValid()) { if (m_stateDescriptor.isValid()) {
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId()); Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
if (!device) { if (!device) {
qCWarning(dcRuleEngine) << "State evaluator device does not exist!"; qCWarning(dcRuleEngine) << "State evaluator device does not exist!";
return false; return false;
@ -231,7 +231,7 @@ bool StateEvaluator::isValid() const
return false; return false;
} }
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
foreach (const StateType &stateType, deviceClass.stateTypes()) { foreach (const StateType &stateType, deviceClass.stateTypes()) {
if (stateType.id() == m_stateDescriptor.stateTypeId()) { if (stateType.id() == m_stateDescriptor.stateTypeId()) {

View File

@ -34,7 +34,7 @@
*/ */
#include "tcpserver.h" #include "tcpserver.h"
#include "guhcore.h" #include "nymeacore.h"
#include <QDebug> #include <QDebug>
@ -135,8 +135,8 @@ void TcpServer::resetAvahiService()
txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION); txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION);
txt.insert("serverVersion", NYMEA_VERSION_STRING); txt.insert("serverVersion", NYMEA_VERSION_STRING);
txt.insert("manufacturer", "guh GmbH"); txt.insert("manufacturer", "guh GmbH");
txt.insert("uuid", GuhCore::instance()->configuration()->serverUuid().toString()); txt.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
txt.insert("name", GuhCore::instance()->configuration()->serverName()); txt.insert("name", NymeaCore::instance()->configuration()->serverName());
txt.insert("sslEnabled", configuration().sslEnabled ? "true" : "false"); txt.insert("sslEnabled", configuration().sslEnabled ? "true" : "false");
if (!m_avahiService->registerService(QString("guhIO-tcp-%1").arg(configuration().id), configuration().port, "_jsonrpc._tcp", txt)) { if (!m_avahiService->registerService(QString("guhIO-tcp-%1").arg(configuration().id), configuration().port, "_jsonrpc._tcp", txt)) {
qCWarning(dcTcpServer()) << "Could not register avahi service for" << configuration(); qCWarning(dcTcpServer()) << "Could not register avahi service for" << configuration();

View File

@ -21,8 +21,8 @@
#include "usermanager.h" #include "usermanager.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h"
#include "pushbuttondbusservice.h" #include "pushbuttondbusservice.h"
#include "nymeacore.h"
#include <QUuid> #include <QUuid>
#include <QCryptographicHash> #include <QCryptographicHash>
@ -141,7 +141,7 @@ QByteArray UserManager::authenticate(const QString &username, const QString &pas
.arg(QUuid::createUuid().toString()) .arg(QUuid::createUuid().toString())
.arg(username) .arg(username)
.arg(QString::fromUtf8(token)) .arg(QString::fromUtf8(token))
.arg(GuhCore::instance()->timeManager()->currentDateTime().toString("yyyy-MM-dd hh:mm:ss")) .arg(NymeaCore::instance()->timeManager()->currentDateTime().toString("yyyy-MM-dd hh:mm:ss"))
.arg(deviceName); .arg(deviceName);
m_db.exec(storeTokenQuery); m_db.exec(storeTokenQuery);
@ -297,7 +297,7 @@ void UserManager::onPushButtonPressed()
.arg(QUuid::createUuid().toString()) .arg(QUuid::createUuid().toString())
.arg("") .arg("")
.arg(QString::fromUtf8(token)) .arg(QString::fromUtf8(token))
.arg(GuhCore::instance()->timeManager()->currentDateTime().toString("yyyy-MM-dd hh:mm:ss")) .arg(NymeaCore::instance()->timeManager()->currentDateTime().toString("yyyy-MM-dd hh:mm:ss"))
.arg(m_pushButtonTransaction.second); .arg(m_pushButtonTransaction.second);
m_db.exec(storeTokenQuery); m_db.exec(storeTokenQuery);

View File

@ -73,7 +73,7 @@
#include "webserver.h" #include "webserver.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "guhcore.h" #include "nymeacore.h"
#include "httpreply.h" #include "httpreply.h"
#include "httprequest.h" #include "httprequest.h"
#include "rest/restresource.h" #include "rest/restresource.h"
@ -368,7 +368,7 @@ void WebServer::readClient()
if (request.url().path().startsWith("/debug")) { if (request.url().path().startsWith("/debug")) {
// Check if debug server is enabled // Check if debug server is enabled
if (GuhCore::instance()->configuration()->debugServerEnabled()) { if (NymeaCore::instance()->configuration()->debugServerEnabled()) {
// Verify methods // Verify methods
if (request.method() != HttpRequest::Get && request.method() != HttpRequest::Options) { if (request.method() != HttpRequest::Get && request.method() != HttpRequest::Options) {
HttpReply *reply = RestResource::createErrorReply(HttpReply::MethodNotAllowed); HttpReply *reply = RestResource::createErrorReply(HttpReply::MethodNotAllowed);
@ -379,7 +379,7 @@ void WebServer::readClient()
return; return;
} }
HttpReply *reply = GuhCore::instance()->debugServerHandler()->processDebugRequest(request.url().path()); HttpReply *reply = NymeaCore::instance()->debugServerHandler()->processDebugRequest(request.url().path());
reply->setClientId(clientId); reply->setClientId(clientId);
sendHttpReply(reply); sendHttpReply(reply);
reply->deleteLater(); reply->deleteLater();
@ -532,8 +532,8 @@ void WebServer::resetAvahiService()
txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION); txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION);
txt.insert("serverVersion", NYMEA_VERSION_STRING); txt.insert("serverVersion", NYMEA_VERSION_STRING);
txt.insert("manufacturer", "guh GmbH"); txt.insert("manufacturer", "guh GmbH");
txt.insert("uuid", GuhCore::instance()->configuration()->serverUuid().toString()); txt.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
txt.insert("name", GuhCore::instance()->configuration()->serverName()); txt.insert("name", NymeaCore::instance()->configuration()->serverName());
txt.insert("sslEnabled", m_configuration.sslEnabled ? "true" : "false"); txt.insert("sslEnabled", m_configuration.sslEnabled ? "true" : "false");
if (!m_avahiService->registerService(QString("guhIO-http-%1").arg(m_configuration.id), m_configuration.port, "_http._tcp", txt)) { if (!m_avahiService->registerService(QString("guhIO-http-%1").arg(m_configuration.id), m_configuration.port, "_http._tcp", txt)) {
@ -597,7 +597,7 @@ bool WebServer::stopServer()
QByteArray WebServer::createServerXmlDocument(QHostAddress address) QByteArray WebServer::createServerXmlDocument(QHostAddress address)
{ {
QByteArray uuid = GuhCore::instance()->configuration()->serverUuid().toByteArray(); QByteArray uuid = NymeaCore::instance()->configuration()->serverUuid().toByteArray();
QByteArray data; QByteArray data;
QXmlStreamWriter writer(&data); QXmlStreamWriter writer(&data);
@ -619,7 +619,7 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
ServerConfiguration websocketConfiguration; ServerConfiguration websocketConfiguration;
bool webSocketServerFound = false; bool webSocketServerFound = false;
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->webSocketServerConfigurations()) { foreach (const ServerConfiguration &config, NymeaCore::instance()->configuration()->webSocketServerConfigurations()) {
if (config.address == QHostAddress("0.0.0.0") || config.address == address) { if (config.address == QHostAddress("0.0.0.0") || config.address == address) {
if (!webSocketServerFound) { if (!webSocketServerFound) {
websocketConfiguration = config; websocketConfiguration = config;
@ -640,7 +640,7 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
ServerConfiguration tcpServerConfiguration; ServerConfiguration tcpServerConfiguration;
bool tcpServerFound = false; bool tcpServerFound = false;
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->tcpServerConfigurations()) { foreach (const ServerConfiguration &config, NymeaCore::instance()->configuration()->tcpServerConfigurations()) {
if (config.address == QHostAddress("0.0.0.0") || config.address == address) { if (config.address == QHostAddress("0.0.0.0") || config.address == address) {
if (!tcpServerFound) { if (!tcpServerFound) {
tcpServerConfiguration = config; tcpServerConfiguration = config;
@ -663,7 +663,7 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
writer.writeStartElement("device"); writer.writeStartElement("device");
writer.writeTextElement("deviceType", "urn:schemas-upnp-org:device:Basic:1"); writer.writeTextElement("deviceType", "urn:schemas-upnp-org:device:Basic:1");
writer.writeTextElement("friendlyName", "guhIO"); writer.writeTextElement("friendlyName", NymeaCore::instance()->configuration()->serverName());
writer.writeTextElement("manufacturer", "guh GmbH"); writer.writeTextElement("manufacturer", "guh GmbH");
writer.writeTextElement("manufacturerURL", "http://guh.io"); writer.writeTextElement("manufacturerURL", "http://guh.io");
writer.writeTextElement("modelDescription", "IoT server"); writer.writeTextElement("modelDescription", "IoT server");

View File

@ -48,7 +48,7 @@
*/ */
#include "nymeasettings.h" #include "nymeasettings.h"
#include "guhcore.h" #include "nymeacore.h"
#include "websocketserver.h" #include "websocketserver.h"
#include "loggingcategories.h" #include "loggingcategories.h"
@ -116,8 +116,8 @@ QHash<QString, QString> WebSocketServer::createTxtRecord()
txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION); txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION);
txt.insert("serverVersion", NYMEA_VERSION_STRING); txt.insert("serverVersion", NYMEA_VERSION_STRING);
txt.insert("manufacturer", "guh GmbH"); txt.insert("manufacturer", "guh GmbH");
txt.insert("uuid", GuhCore::instance()->configuration()->serverUuid().toString()); txt.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
txt.insert("name", GuhCore::instance()->configuration()->serverName()); txt.insert("name", NymeaCore::instance()->configuration()->serverName());
txt.insert("sslEnabled", configuration().sslEnabled ? "true" : "false"); txt.insert("sslEnabled", configuration().sslEnabled ? "true" : "false");
return txt; return txt;
} }

View File

@ -152,7 +152,7 @@
/*! \fn void DeviceManager::eventTriggered(const Event &event) /*! \fn void DeviceManager::eventTriggered(const Event &event)
The DeviceManager will emit a \l{Event} described in \a event whenever a Device The DeviceManager will emit a \l{Event} described in \a event whenever a Device
creates one. Normally only \l{guhserver::GuhCore} should connect to this and execute actions creates one. Normally only \l{guhserver::NymeaCore} should connect to this and execute actions
after checking back with the \{guhserver::RulesEngine}. Exceptions might be monitoring interfaces after checking back with the \{guhserver::RulesEngine}. Exceptions might be monitoring interfaces
or similar, but you should never directly react to this in a \l{DevicePlugin}. or similar, but you should never directly react to this in a \l{DevicePlugin}.
*/ */
@ -177,8 +177,8 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QDir> #include <QDir>
/*! Constructs the DeviceManager with the given \a locale and \a parent. There should only be one DeviceManager in the system created by \l{guhserver::GuhCore}. /*! Constructs the DeviceManager with the given \a locale and \a parent. There should only be one DeviceManager in the system created by \l{guhserver::NymeaCore}.
* Use \c guhserver::GuhCore::instance()->deviceManager() instead to access the DeviceManager. */ * Use \c guhserver::NymeaCore::instance()->deviceManager() instead to access the DeviceManager. */
DeviceManager::DeviceManager(HardwareManager *hardwareManager, const QLocale &locale, QObject *parent) : DeviceManager::DeviceManager(HardwareManager *hardwareManager, const QLocale &locale, QObject *parent) :
QObject(parent), QObject(parent),
m_hardwareManager(hardwareManager), m_hardwareManager(hardwareManager),

View File

@ -35,7 +35,7 @@
#include "guhapplication.h" #include "guhapplication.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "guhcore.h" #include "nymeacore.h"
#include <execinfo.h> #include <execinfo.h>
#include <signal.h> #include <signal.h>
@ -190,7 +190,7 @@ static void catchUnixSignals(const std::vector<int>& quitSignals, const std::vec
qCDebug(dcApplication) << "====================================="; qCDebug(dcApplication) << "=====================================";
s_aboutToShutdown = true; s_aboutToShutdown = true;
GuhCore::instance()->destroy(); NymeaCore::instance()->destroy();
if (s_multipleShutdownDetected) if (s_multipleShutdownDetected)
qCDebug(dcApplication) << "Ok, ok, I'm done! :)"; qCDebug(dcApplication) << "Ok, ok, I'm done! :)";

View File

@ -37,6 +37,7 @@
#include <QDir> #include <QDir>
#include "guhservice.h" #include "guhservice.h"
#include "nymeacore.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "loggingcategories.h" #include "loggingcategories.h"
@ -74,7 +75,7 @@ void GuhService::start()
qCDebug(dcApplication) << "nymead" << NYMEA_VERSION_STRING << "started as daemon."; qCDebug(dcApplication) << "nymead" << NYMEA_VERSION_STRING << "started as daemon.";
qCDebug(dcApplication) << "====================================="; qCDebug(dcApplication) << "=====================================";
GuhCore::instance(); NymeaCore::instance();
} }
} }

View File

@ -24,8 +24,6 @@
#include <QCoreApplication> #include <QCoreApplication>
#include "qtservice/qtservice.h" #include "qtservice/qtservice.h"
#include "guhcore.h"
namespace guhserver { namespace guhserver {
class GuhService : public QtService<QCoreApplication> class GuhService : public QtService<QCoreApplication>

View File

@ -35,7 +35,7 @@
#include "stdio.h" #include "stdio.h"
#include "unistd.h" #include "unistd.h"
#include "guhcore.h" #include "nymeacore.h"
#include "guhservice.h" #include "guhservice.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "guhdbusservice.h" #include "guhdbusservice.h"
@ -277,7 +277,7 @@ int main(int argc, char *argv[])
} }
// create core instance // create core instance
GuhCore::instance(); NymeaCore::instance();
int ret = application.exec(); int ret = application.exec();
if (s_logFile.isOpen()) { if (s_logFile.isOpen()) {
s_logFile.close(); s_logFile.close();

View File

@ -20,7 +20,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"

View File

@ -20,9 +20,9 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "nymeacore.h"
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QCoreApplication> #include <QCoreApplication>
@ -342,7 +342,7 @@ void TestConfigurations::testDebugServerConfiguration()
QVERIFY2(basicConfigurationNotificationMap.value("debugServerEnabled").toBool() == newValue, "Notification does not contain the new debugServerEnabled"); QVERIFY2(basicConfigurationNotificationMap.value("debugServerEnabled").toBool() == newValue, "Notification does not contain the new debugServerEnabled");
qDebug() << "TestWebserver starting"; qDebug() << "TestWebserver starting";
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -355,7 +355,7 @@ void TestConfigurations::testDebugServerConfiguration()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
// Webserver request // Webserver request
QNetworkAccessManager nam; QNetworkAccessManager nam;
@ -397,7 +397,7 @@ void TestConfigurations::testDebugServerConfiguration()
QCOMPARE(statusCode, 404); QCOMPARE(statusCode, 404);
reply->deleteLater(); reply->deleteLater();
GuhCore::instance()->configuration()->removeWebServerConfiguration(config.id); NymeaCore::instance()->configuration()->removeWebServerConfiguration(config.id);
disableNotifications(); disableNotifications();
} }

View File

@ -20,7 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "plugin/deviceplugin.h" #include "plugin/deviceplugin.h"
@ -1225,7 +1225,7 @@ void TestDevices::removeAutoDevice()
// First try to make a manually created device disappear. It must not go away // First try to make a manually created device disappear. It must not go away
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); QList<Device*> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
Device *device = devices.first(); Device *device = devices.first();
@ -1236,15 +1236,15 @@ void TestDevices::removeAutoDevice()
spy.wait(); spy.wait();
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
reply->deleteLater(); reply->deleteLater();
QVERIFY2(GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).count() == 1, "Mock device has disappeared even though it shouldn't"); QVERIFY2(NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).count() == 1, "Mock device has disappeared even though it shouldn't");
// Ok, now do the same with an autocreated one. It should go away // Ok, now do the same with an autocreated one. It should go away
devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId); devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one auto-created Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one auto-created Mock Device for this test");
device = devices.first(); device = devices.first();
DeviceClass dc = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); DeviceClass dc = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
// trigger disappear signal in mock device // trigger disappear signal in mock device
spy.clear(); spy.clear();
@ -1256,7 +1256,7 @@ void TestDevices::removeAutoDevice()
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
reply->deleteLater(); reply->deleteLater();
QVERIFY2(GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId).count() == 0, "Mock device has not disappeared even though it should have."); QVERIFY2(NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId).count() == 0, "Mock device has not disappeared even though it should have.");
} }
#include "testdevices.moc" #include "testdevices.moc"

View File

@ -20,7 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
@ -50,11 +50,11 @@ private slots:
void TestEvents::triggerEvent() void TestEvents::triggerEvent()
{ {
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); QList<Device*> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
Device *device = devices.first(); Device *device = devices.first();
QSignalSpy spy(GuhCore::instance(), SIGNAL(eventTriggered(const Event&))); QSignalSpy spy(NymeaCore::instance(), SIGNAL(eventTriggered(const Event&)));
// Setup connection to mock client // Setup connection to mock client
QNetworkAccessManager nam; QNetworkAccessManager nam;
@ -79,11 +79,11 @@ void TestEvents::triggerEvent()
void TestEvents::triggerStateChangeEvent() void TestEvents::triggerStateChangeEvent()
{ {
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); QList<Device*> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
Device *device = devices.first(); Device *device = devices.first();
QSignalSpy spy(GuhCore::instance(), SIGNAL(eventTriggered(const Event&))); QSignalSpy spy(NymeaCore::instance(), SIGNAL(eventTriggered(const Event&)));
// Setup connection to mock client // Setup connection to mock client
QNetworkAccessManager nam; QNetworkAccessManager nam;

View File

@ -21,7 +21,7 @@
#include "guhtestbase.h" #include "guhtestbase.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "guhcore.h" #include "nymeacore.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "loggingcategories.h" #include "loggingcategories.h"
@ -178,21 +178,21 @@ void GuhTestBase::initTestCase()
QLoggingCategory::installFilter(loggingCategoryFilter); QLoggingCategory::installFilter(loggingCategoryFilter);
// Start the server // Start the server
GuhCore::instance(); NymeaCore::instance();
// Wait unitl the server is initialized // Wait unitl the server is initialized
QSignalSpy coreInitializedSpy(GuhCore::instance(), SIGNAL(initialized())); QSignalSpy coreInitializedSpy(NymeaCore::instance(), SIGNAL(initialized()));
coreInitializedSpy.wait(); coreInitializedSpy.wait();
// Wait for the DeviceManager to signal that it has loaded plugins and everything // Wait for the DeviceManager to signal that it has loaded plugins and everything
QSignalSpy deviceManagerSpy(GuhCore::instance()->deviceManager(), SIGNAL(loaded())); QSignalSpy deviceManagerSpy(NymeaCore::instance()->deviceManager(), SIGNAL(loaded()));
QVERIFY(deviceManagerSpy.isValid()); QVERIFY(deviceManagerSpy.isValid());
QVERIFY(deviceManagerSpy.wait()); QVERIFY(deviceManagerSpy.wait());
// Yes, we're intentionally mixing upper/lower case email here... username should not be case sensitive // Yes, we're intentionally mixing upper/lower case email here... username should not be case sensitive
GuhCore::instance()->userManager()->removeUser("dummy@guh.io"); NymeaCore::instance()->userManager()->removeUser("dummy@guh.io");
GuhCore::instance()->userManager()->createUser("dummy@guh.io", "DummyPW1!"); NymeaCore::instance()->userManager()->createUser("dummy@guh.io", "DummyPW1!");
m_apiToken = GuhCore::instance()->userManager()->authenticate("Dummy@guh.io", "DummyPW1!", "testcase"); m_apiToken = NymeaCore::instance()->userManager()->authenticate("Dummy@guh.io", "DummyPW1!", "testcase");
if (MockTcpServer::servers().isEmpty()) { if (MockTcpServer::servers().isEmpty()) {
qWarning() << "no mock tcp server found"; qWarning() << "no mock tcp server found";
@ -216,13 +216,13 @@ void GuhTestBase::initTestCase()
void GuhTestBase::cleanupTestCase() void GuhTestBase::cleanupTestCase()
{ {
GuhCore::instance()->destroy(); NymeaCore::instance()->destroy();
} }
void GuhTestBase::cleanup() void GuhTestBase::cleanup()
{ {
// In case a test deleted the mock device, lets recreate it. // In case a test deleted the mock device, lets recreate it.
if (GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).count() == 0) { if (NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).count() == 0) {
createMockDevice(); createMockDevice();
} }
} }
@ -497,10 +497,10 @@ bool GuhTestBase::disableNotifications()
void GuhTestBase::restartServer() void GuhTestBase::restartServer()
{ {
// Destroy and recreate the core instance... // Destroy and recreate the core instance...
GuhCore::instance()->destroy(); NymeaCore::instance()->destroy();
QSignalSpy coreSpy(GuhCore::instance(), SIGNAL(initialized())); QSignalSpy coreSpy(NymeaCore::instance(), SIGNAL(initialized()));
coreSpy.wait(); coreSpy.wait();
QSignalSpy spy(GuhCore::instance()->deviceManager(), SIGNAL(loaded())); QSignalSpy spy(NymeaCore::instance()->deviceManager(), SIGNAL(loaded()));
spy.wait(); spy.wait();
m_mockTcpServer = MockTcpServer::servers().first(); m_mockTcpServer = MockTcpServer::servers().first();
m_mockTcpServer->clientConnected(m_clientId); m_mockTcpServer->clientConnected(m_clientId);
@ -508,7 +508,7 @@ void GuhTestBase::restartServer()
void GuhTestBase::clearLoggingDatabase() void GuhTestBase::clearLoggingDatabase()
{ {
GuhCore::instance()->logEngine()->clearDatabase(); NymeaCore::instance()->logEngine()->clearDatabase();
} }
void GuhTestBase::createMockDevice() void GuhTestBase::createMockDevice()

View File

@ -20,7 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "../../utils/pushbuttonagent.h" #include "../../utils/pushbuttonagent.h"
@ -166,10 +166,10 @@ void TestJSONRPC::testHandshake()
void TestJSONRPC::testInitialSetup() void TestJSONRPC::testInitialSetup()
{ {
foreach (const QString &user, GuhCore::instance()->userManager()->users()) { foreach (const QString &user, NymeaCore::instance()->userManager()->users()) {
GuhCore::instance()->userManager()->removeUser(user); NymeaCore::instance()->userManager()->removeUser(user);
} }
QCOMPARE(GuhCore::instance()->userManager()->users().count(), 0); QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 0);
QSignalSpy spy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy spy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -223,7 +223,7 @@ void TestJSONRPC::testInitialSetup()
response = jsonDoc.toVariant().toMap(); response = jsonDoc.toVariant().toMap();
qWarning() << "Calling CreateUser on uninitialized instance with invalid user:" << response.value("status").toString() << response.value("params").toMap().value("error").toString(); qWarning() << "Calling CreateUser on uninitialized instance with invalid user:" << response.value("status").toString() << response.value("params").toMap().value("error").toString();
QCOMPARE(response.value("status").toString(), QStringLiteral("success")); QCOMPARE(response.value("status").toString(), QStringLiteral("success"));
QCOMPARE(GuhCore::instance()->userManager()->users().count(), 0); QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 0);
// or when giving a bad password // or when giving a bad password
spy.clear(); spy.clear();
@ -236,7 +236,7 @@ void TestJSONRPC::testInitialSetup()
response = jsonDoc.toVariant().toMap(); response = jsonDoc.toVariant().toMap();
qWarning() << "Calling CreateUser on uninitialized instance with weak password:" << response.value("status").toString() << response.value("params").toMap().value("error").toString(); qWarning() << "Calling CreateUser on uninitialized instance with weak password:" << response.value("status").toString() << response.value("params").toMap().value("error").toString();
QCOMPARE(response.value("status").toString(), QStringLiteral("success")); QCOMPARE(response.value("status").toString(), QStringLiteral("success"));
QCOMPARE(GuhCore::instance()->userManager()->users().count(), 0); QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 0);
// Now lets play by the rules (with an uppercase email) // Now lets play by the rules (with an uppercase email)
spy.clear(); spy.clear();
@ -249,7 +249,7 @@ void TestJSONRPC::testInitialSetup()
response = jsonDoc.toVariant().toMap(); response = jsonDoc.toVariant().toMap();
qWarning() << "Calling CreateUser on uninitialized instance:" << response.value("status").toString() << response.value("error").toString(); qWarning() << "Calling CreateUser on uninitialized instance:" << response.value("status").toString() << response.value("error").toString();
QCOMPARE(response.value("status").toString(), QStringLiteral("success")); QCOMPARE(response.value("status").toString(), QStringLiteral("success"));
QCOMPARE(GuhCore::instance()->userManager()->users().count(), 1); QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 1);
// Calls should still fail, given we didn't get a new token yet // Calls should still fail, given we didn't get a new token yet
spy.clear(); spy.clear();

View File

@ -20,7 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "logging/logentry.h" #include "logging/logentry.h"
@ -202,7 +202,7 @@ void TestLogging::invalidFilter()
void TestLogging::eventLogs() void TestLogging::eventLogs()
{ {
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); QList<Device*> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
Device *device = devices.first(); Device *device = devices.first();

View File

@ -20,7 +20,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "webserver.h" #include "webserver.h"
@ -68,7 +68,7 @@ void TestRestDeviceClasses::initTestCase()
{ {
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -80,7 +80,7 @@ void TestRestDeviceClasses::initTestCase()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
qApp->processEvents(); qApp->processEvents();
} }

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "webserver.h" #include "webserver.h"
@ -77,7 +77,7 @@ private slots:
void TestRestDevices::initTestCase() void TestRestDevices::initTestCase()
{ {
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -89,7 +89,7 @@ void TestRestDevices::initTestCase()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
qApp->processEvents(); qApp->processEvents();
} }
@ -505,7 +505,7 @@ void TestRestDevices::executeAction()
void TestRestDevices::getStateValue_data() void TestRestDevices::getStateValue_data()
{ {
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); QList<Device*> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
Device *device = devices.first(); Device *device = devices.first();

View File

@ -20,7 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "plugin/deviceplugin.h" #include "plugin/deviceplugin.h"
@ -60,7 +60,7 @@ void TestRestLogging::initTestCase()
{ {
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -72,7 +72,7 @@ void TestRestLogging::initTestCase()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
qApp->processEvents(); qApp->processEvents();
} }
@ -144,7 +144,7 @@ void TestRestLogging::invalidFilterJson()
void TestRestLogging::eventLogs() void TestRestLogging::eventLogs()
{ {
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); QList<Device*> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
Device *device = devices.first(); Device *device = devices.first();

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "webserver.h" #include "webserver.h"
@ -61,7 +61,7 @@ void TestRestPlugins::initTestCase()
{ {
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -73,7 +73,7 @@ void TestRestPlugins::initTestCase()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
qApp->processEvents(); qApp->processEvents();
} }

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "webserver.h" #include "webserver.h"
@ -82,7 +82,7 @@ void TestRestRules::initTestCase()
{ {
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -94,7 +94,7 @@ void TestRestRules::initTestCase()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
qApp->processEvents(); qApp->processEvents();
} }

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "webserver.h" #include "webserver.h"
@ -56,7 +56,7 @@ void TestRestVendors::initTestCase()
{ {
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -68,7 +68,7 @@ void TestRestVendors::initTestCase()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
qApp->processEvents(); qApp->processEvents();
} }

View File

@ -20,8 +20,8 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "nymeasettings.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include <QtTest/QtTest> #include <QtTest/QtTest>

View File

@ -20,7 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
@ -58,7 +58,7 @@ void TestStates::getStateTypes()
void TestStates::getStateValue_data() void TestStates::getStateValue_data()
{ {
QList<Device*> devices = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId); QList<Device*> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId);
QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test");
Device *device = devices.first(); Device *device = devices.first();
@ -88,12 +88,12 @@ void TestStates::getStateValue()
void TestStates::save_load_states() void TestStates::save_load_states()
{ {
DeviceClass mockDeviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(mockDeviceClassId); DeviceClass mockDeviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(mockDeviceClassId);
QVERIFY2(mockDeviceClass.getStateType(mockIntStateId).cached(), "Mock int state is not cached (required to be true for this test)"); QVERIFY2(mockDeviceClass.getStateType(mockIntStateId).cached(), "Mock int state is not cached (required to be true for this test)");
QVERIFY2(!mockDeviceClass.getStateType(mockBoolStateId).cached(), "Mock bool state is cached (required to be false for this test)"); QVERIFY2(!mockDeviceClass.getStateType(mockBoolStateId).cached(), "Mock bool state is cached (required to be false for this test)");
Device* device = GuhCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).first(); Device* device = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).first();
int port = device->paramValue(httpportParamTypeId).toInt(); int port = device->paramValue(httpportParamTypeId).toInt();
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));

View File

@ -20,7 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "time/timemanager.h" #include "time/timemanager.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
@ -144,15 +144,15 @@ void TestTimeManager::changeTimeZone()
QFETCH(QByteArray, timeZoneId); QFETCH(QByteArray, timeZoneId);
QFETCH(bool, valid); QFETCH(bool, valid);
QTimeZone currentTimeZone(GuhCore::instance()->timeManager()->timeZone()); QTimeZone currentTimeZone(NymeaCore::instance()->timeManager()->timeZone());
QTimeZone newTimeZone(timeZoneId); QTimeZone newTimeZone(timeZoneId);
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
GuhCore::instance()->timeManager()->setTimeZone(timeZoneId); NymeaCore::instance()->timeManager()->setTimeZone(timeZoneId);
QDateTime newDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime newDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
int offsetOriginal = currentTimeZone.offsetFromUtc(currentDateTime); int offsetOriginal = currentTimeZone.offsetFromUtc(currentDateTime);
int offsetNew = newTimeZone.offsetFromUtc(newDateTime); int offsetNew = newTimeZone.offsetFromUtc(newDateTime);
@ -430,21 +430,21 @@ void TestTimeManager::testCalendarDateTime()
QDateTime oneMinuteBeforeEvent = dateTime.addSecs(-60); QDateTime oneMinuteBeforeEvent = dateTime.addSecs(-60);
GuhCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent); NymeaCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// active unchanged // active unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
cleanupMockHistory(); cleanupMockHistory();
// inactive unchanged // inactive unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// REMOVE rule // REMOVE rule
@ -498,34 +498,34 @@ void TestTimeManager::testCalendarItemHourly()
params.insert("ruleId", ruleId); params.insert("ruleId", ruleId);
response = injectAndWait("Rules.GetRuleDetails", params); response = injectAndWait("Rules.GetRuleDetails", params);
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
QDateTime future = QDateTime(currentDateTime.date(), QTime(8, 4)); QDateTime future = QDateTime(currentDateTime.date(), QTime(8, 4));
// Check if should be enabled always // Check if should be enabled always
if (duration == 60) { if (duration == 60) {
GuhCore::instance()->timeManager()->setTime(future); NymeaCore::instance()->timeManager()->setTime(future);
// Should be active since adding // Should be active since adding
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
} else { } else {
// check the next 24 hours in 8h steps // check the next 24 hours in 8h steps
for (int i = 0; i < 24; i+=8) { for (int i = 0; i < 24; i+=8) {
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(future); NymeaCore::instance()->timeManager()->setTime(future);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 5))); NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 5)));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// active unchanged // active unchanged
GuhCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 7))); NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 7)));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 10))); NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 10)));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
cleanupMockHistory(); cleanupMockHistory();
// inactive unchanged // inactive unchanged
GuhCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 11))); NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 11)));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// 'i' hours "Back to the future" // 'i' hours "Back to the future"
@ -587,35 +587,35 @@ void TestTimeManager::testCalendarItemDaily()
verifyRuleError(response); verifyRuleError(response);
RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString()); RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString());
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
// start with one minute before starttime today // start with one minute before starttime today
QDateTime future = QDateTime(currentDateTime.date(), QTime::fromString(time, "hh:mm").addSecs(-60)); QDateTime future = QDateTime(currentDateTime.date(), QTime::fromString(time, "hh:mm").addSecs(-60));
// if always true // if always true
if (time == "08:00") { if (time == "08:00") {
GuhCore::instance()->timeManager()->setTime(future); NymeaCore::instance()->timeManager()->setTime(future);
// Should be active since adding // Should be active since adding
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
} else { } else {
// check the next 7 days // check the next 7 days
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(future); NymeaCore::instance()->timeManager()->setTime(future);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(future.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// active unchanged // active unchanged
GuhCore::instance()->timeManager()->setTime(future.addSecs(6* 60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(future.addSecs(11 * 60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
cleanupMockHistory(); cleanupMockHistory();
// inactive unchanged // inactive unchanged
GuhCore::instance()->timeManager()->setTime(future.addSecs(12 * 60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// One day "Back to the future" // One day "Back to the future"
future = future.addDays(1); future = future.addDays(1);
@ -691,7 +691,7 @@ void TestTimeManager::testCalendarItemWeekly()
verifyRuleError(response); verifyRuleError(response);
RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString()); RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString());
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
// start with one minute before starttime today // start with one minute before starttime today
QDateTime future = QDateTime(currentDateTime.date(), QTime::fromString(time, "hh:mm").addSecs(-60)); QDateTime future = QDateTime(currentDateTime.date(), QTime::fromString(time, "hh:mm").addSecs(-60));
@ -704,7 +704,7 @@ void TestTimeManager::testCalendarItemWeekly()
// the whole week active (always) // the whole week active (always)
if (repeatingOption.isEmpty()) { if (repeatingOption.isEmpty()) {
GuhCore::instance()->timeManager()->setTime(future); NymeaCore::instance()->timeManager()->setTime(future);
// Should be active since adding // Should be active since adding
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
} else { } else {
@ -713,32 +713,32 @@ void TestTimeManager::testCalendarItemWeekly()
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(future); NymeaCore::instance()->timeManager()->setTime(future);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// Check if today is a weekday // Check if today is a weekday
if (weekDays.contains(future.date().dayOfWeek())) { if (weekDays.contains(future.date().dayOfWeek())) {
// should trigger today // should trigger today
// active // active
GuhCore::instance()->timeManager()->setTime(future.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// active unchanged // active unchanged
GuhCore::instance()->timeManager()->setTime(future.addSecs(6* 60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(future.addSecs(11 * 60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
cleanupMockHistory(); cleanupMockHistory();
// inactive unchanged // inactive unchanged
GuhCore::instance()->timeManager()->setTime(future.addSecs(12 * 60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// One day "Back to the future" // One day "Back to the future"
future = future.addDays(1); future = future.addDays(1);
} else { } else {
// should not trigger today // should not trigger today
GuhCore::instance()->timeManager()->setTime(future.addSecs(6* 60)); NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// One day "Back to the future" // One day "Back to the future"
@ -756,24 +756,24 @@ void TestTimeManager::testCalendarItemWeekly()
} }
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(startDate); NymeaCore::instance()->timeManager()->setTime(startDate);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(startDate.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// still active // still active
GuhCore::instance()->timeManager()->setTime(startDate.addDays(1)); NymeaCore::instance()->timeManager()->setTime(startDate.addDays(1));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// still active // still active
GuhCore::instance()->timeManager()->setTime(startDate.addDays(2)); NymeaCore::instance()->timeManager()->setTime(startDate.addDays(2));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(startDate.addDays(2).addSecs(60)); NymeaCore::instance()->timeManager()->setTime(startDate.addDays(2).addSecs(60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
} }
} }
@ -846,7 +846,7 @@ void TestTimeManager::testCalendarItemMonthly()
verifyRuleError(response); verifyRuleError(response);
RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString()); RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString());
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
QVariantList monthDaysVariant = repeatingOption.value("monthDays").toList(); QVariantList monthDaysVariant = repeatingOption.value("monthDays").toList();
QList<int> monthDays; QList<int> monthDays;
@ -866,25 +866,25 @@ void TestTimeManager::testCalendarItemMonthly()
if (monthDays.contains(dateTime.date().day())) { if (monthDays.contains(dateTime.date().day())) {
// should trigger today // should trigger today
// not active yet // not active yet
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// active unchanged // active unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(6* 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(6* 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(11 * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(11 * 60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
cleanupMockHistory(); cleanupMockHistory();
// inactive unchanged // inactive unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(12 * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(12 * 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
} else { } else {
// should not trigger today // should not trigger today
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
} }
} }
@ -900,20 +900,20 @@ void TestTimeManager::testCalendarItemMonthly()
} }
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(startDate); NymeaCore::instance()->timeManager()->setTime(startDate);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(startDate.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// still active // still active
GuhCore::instance()->timeManager()->setTime(startDate.addDays(3)); NymeaCore::instance()->timeManager()->setTime(startDate.addDays(3));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(startDate.addDays(3).addSecs(60)); NymeaCore::instance()->timeManager()->setTime(startDate.addDays(3).addSecs(60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
} }
@ -986,23 +986,23 @@ void TestTimeManager::testCalendarYearlyDateTime()
QDateTime oneMinuteBeforeEvent = dateTime.addSecs(-60); QDateTime oneMinuteBeforeEvent = dateTime.addSecs(-60);
GuhCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent); NymeaCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
cleanupMockHistory(); cleanupMockHistory();
// active unchanged // active unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
cleanupMockHistory(); cleanupMockHistory();
cleanupMockHistory(); cleanupMockHistory();
// inactive unchanged // inactive unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
@ -1010,23 +1010,23 @@ void TestTimeManager::testCalendarYearlyDateTime()
oneMinuteBeforeEvent = oneMinuteBeforeEvent.addYears(1); oneMinuteBeforeEvent = oneMinuteBeforeEvent.addYears(1);
dateTime = dateTime.addYears(1); dateTime = dateTime.addYears(1);
GuhCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent); NymeaCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// active // active
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
cleanupMockHistory(); cleanupMockHistory();
// active unchanged // active unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// inactive // inactive
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
verifyRuleExecuted(mockActionIdWithParams); verifyRuleExecuted(mockActionIdWithParams);
cleanupMockHistory(); cleanupMockHistory();
// inactive unchanged // inactive unchanged
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
cleanupMockHistory(); cleanupMockHistory();
@ -1100,7 +1100,7 @@ void TestTimeManager::testCalendarItemStates_data()
ruleMap.insert("exitActions", QVariantList() << exitAction); ruleMap.insert("exitActions", QVariantList() << exitAction);
ruleMap.insert("timeDescriptor", createTimeDescriptorCalendar(createCalendarItem("08:00", 10, repeatingOptionDaily))); ruleMap.insert("timeDescriptor", createTimeDescriptorCalendar(createCalendarItem("08:00", 10, repeatingOptionDaily)));
GuhCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(07,59))); NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(07,59)));
QVariant response = injectAndWait("Rules.AddRule", ruleMap); QVariant response = injectAndWait("Rules.AddRule", ruleMap);
verifyRuleError(response); verifyRuleError(response);
@ -1134,7 +1134,7 @@ void TestTimeManager::testCalendarItemStates()
QFETCH(bool, trigger); QFETCH(bool, trigger);
QFETCH(bool, active); QFETCH(bool, active);
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
setBoolState(boolValue); setBoolState(boolValue);
setIntState(intValue); setIntState(intValue);
@ -1178,7 +1178,7 @@ void TestTimeManager::testCalendarItemEvent_data()
ruleMap.insert("eventDescriptors", QVariantList() << eventDescriptor); ruleMap.insert("eventDescriptors", QVariantList() << eventDescriptor);
ruleMap.insert("timeDescriptor", createTimeDescriptorCalendar(createCalendarItem("08:00", 10))); ruleMap.insert("timeDescriptor", createTimeDescriptorCalendar(createCalendarItem("08:00", 10)));
GuhCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59))); NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59)));
QVariant response = injectAndWait("Rules.AddRule", ruleMap); QVariant response = injectAndWait("Rules.AddRule", ruleMap);
verifyRuleError(response); verifyRuleError(response);
@ -1205,7 +1205,7 @@ void TestTimeManager::testCalendarItemEvent()
QFETCH(QDateTime, dateTime); QFETCH(QDateTime, dateTime);
QFETCH(bool, trigger); QFETCH(bool, trigger);
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
// Trigger event // Trigger event
triggerMockEvent1(); triggerMockEvent1();
@ -1222,7 +1222,7 @@ void TestTimeManager::testCalendarItemStatesEvent_data()
{ {
initTimeManager(); initTimeManager();
GuhCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59))); NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59)));
// Action (without params) // Action (without params)
QVariantMap action; QVariantMap action;
@ -1278,7 +1278,7 @@ void TestTimeManager::testCalendarItemStatesEvent()
QFETCH(bool, boolValue); QFETCH(bool, boolValue);
QFETCH(bool, trigger); QFETCH(bool, trigger);
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
setBoolState(boolValue); setBoolState(boolValue);
// Trigger event // Trigger event
@ -1324,17 +1324,17 @@ void TestTimeManager::testEventItemDateTime()
RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString()); RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString());
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-120)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-120));
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
cleanupMockHistory(); cleanupMockHistory();
@ -1383,7 +1383,7 @@ void TestTimeManager::testEventItemHourly()
params.insert("ruleId", ruleId); params.insert("ruleId", ruleId);
response = injectAndWait("Rules.GetRuleDetails", params); response = injectAndWait("Rules.GetRuleDetails", params);
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60)); QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60));
// check the next 24 hours in 8h steps // check the next 24 hours in 8h steps
@ -1392,14 +1392,14 @@ void TestTimeManager::testEventItemHourly()
beforeEventDateTime = beforeEventDateTime.addSecs(i * 60 * 60); beforeEventDateTime = beforeEventDateTime.addSecs(i * 60 * 60);
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
cleanupMockHistory(); cleanupMockHistory();
} }
@ -1456,20 +1456,20 @@ void TestTimeManager::testEventItemDaily()
params.insert("ruleId", ruleId); params.insert("ruleId", ruleId);
response = injectAndWait("Rules.GetRuleDetails", params); response = injectAndWait("Rules.GetRuleDetails", params);
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60)); QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60));
// check the next 2 days // check the next 2 days
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// Back to the future (1 day) // Back to the future (1 day)
@ -1525,7 +1525,7 @@ void TestTimeManager::testEventItemWeekly()
params.insert("ruleId", ruleId); params.insert("ruleId", ruleId);
response = injectAndWait("Rules.GetRuleDetails", params); response = injectAndWait("Rules.GetRuleDetails", params);
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60)); QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60));
QList<int> allowedDays; QList<int> allowedDays;
@ -1538,19 +1538,19 @@ void TestTimeManager::testEventItemWeekly()
// check if today is one of the weekdays // check if today is one of the weekdays
if (allowedDays.contains(beforeEventDateTime.date().dayOfWeek())) { if (allowedDays.contains(beforeEventDateTime.date().dayOfWeek())) {
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
} else { } else {
// not triggering on this weekday // not triggering on this weekday
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
} }
@ -1607,7 +1607,7 @@ void TestTimeManager::testEventItemMonthly()
params.insert("ruleId", ruleId); params.insert("ruleId", ruleId);
response = injectAndWait("Rules.GetRuleDetails", params); response = injectAndWait("Rules.GetRuleDetails", params);
QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); QDateTime currentDateTime = NymeaCore::instance()->timeManager()->currentDateTime();
QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60)); QDateTime beforeEventDateTime = QDateTime(currentDateTime.date(), time.addSecs(-60));
QList<int> allowedDays; QList<int> allowedDays;
@ -1620,18 +1620,18 @@ void TestTimeManager::testEventItemMonthly()
// check if today is one of the month days // check if today is one of the month days
if (allowedDays.contains(beforeEventDateTime.date().day())) { if (allowedDays.contains(beforeEventDateTime.date().day())) {
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
} else { } else {
// not triggering on this weekday // not triggering on this weekday
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
} }
@ -1686,28 +1686,28 @@ void TestTimeManager::testEventItemYearly()
// Tick now, one minute before, on time, one minute after // Tick now, one minute before, on time, one minute after
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// Tick next year, one minute bofore, on time, one minute after // Tick next year, one minute bofore, on time, one minute after
QDateTime nextYear = dateTime.addYears(1); QDateTime nextYear = dateTime.addYears(1);
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(nextYear.addSecs(-60)); NymeaCore::instance()->timeManager()->setTime(nextYear.addSecs(-60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(nextYear); NymeaCore::instance()->timeManager()->setTime(nextYear);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(nextYear.addSecs(60)); NymeaCore::instance()->timeManager()->setTime(nextYear.addSecs(60));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
cleanupMockHistory(); cleanupMockHistory();
@ -1724,7 +1724,7 @@ void TestTimeManager::testEventItemStates_data()
{ {
initTimeManager(); initTimeManager();
GuhCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59))); NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59)));
// Action (without params) // Action (without params)
QVariantMap action; QVariantMap action;
@ -1789,7 +1789,7 @@ void TestTimeManager::testEventItemStates()
setBoolState(boolValue); setBoolState(boolValue);
// Set time // Set time
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
if (trigger) { if (trigger) {
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
@ -1826,16 +1826,16 @@ void TestTimeManager::testEnableDisableTimeRule()
RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString()); RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString());
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-2)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-2));
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-1)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
// not triggering // not triggering
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(1)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(1));
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(2)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(2));
verifyRuleNotExecuted(); verifyRuleNotExecuted();
@ -1846,8 +1846,8 @@ void TestTimeManager::testEnableDisableTimeRule()
verifyRuleError(response); verifyRuleError(response);
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-1)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleNotExecuted(); verifyRuleNotExecuted();
// Now ENABLE the rule again // Now ENABLE the rule again
@ -1856,8 +1856,8 @@ void TestTimeManager::testEnableDisableTimeRule()
verifyRuleError(response); verifyRuleError(response);
// trigger // trigger
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-1)); NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
GuhCore::instance()->timeManager()->setTime(dateTime); NymeaCore::instance()->timeManager()->setTime(dateTime);
verifyRuleExecuted(mockActionIdNoParams); verifyRuleExecuted(mockActionIdNoParams);
cleanupMockHistory(); cleanupMockHistory();
@ -1873,9 +1873,9 @@ void TestTimeManager::initTimeManager()
cleanupMockHistory(); cleanupMockHistory();
removeAllRules(); removeAllRules();
enableNotifications(); enableNotifications();
GuhCore::instance()->timeManager()->stopTimer(); NymeaCore::instance()->timeManager()->stopTimer();
qDebug() << GuhCore::instance()->timeManager()->currentTime().toString(); qDebug() << NymeaCore::instance()->timeManager()->currentTime().toString();
qDebug() << GuhCore::instance()->timeManager()->currentDate().toString(); qDebug() << NymeaCore::instance()->timeManager()->currentDate().toString();
} }
void TestTimeManager::verifyRuleExecuted(const ActionTypeId &actionTypeId) void TestTimeManager::verifyRuleExecuted(const ActionTypeId &actionTypeId)

View File

@ -19,7 +19,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "rest/restresource.h" #include "rest/restresource.h"
@ -84,7 +84,7 @@ void TestWebserver::initTestCase()
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
qDebug() << "TestWebserver starting"; qDebug() << "TestWebserver starting";
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) { foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) { if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333"; qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
return; return;
@ -96,7 +96,7 @@ void TestWebserver::initTestCase()
config.address = QHostAddress("127.0.0.1"); config.address = QHostAddress("127.0.0.1");
config.port = 3333; config.port = 3333;
config.sslEnabled = true; config.sslEnabled = true;
GuhCore::instance()->configuration()->setWebServerConfiguration(config); NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
} }
void TestWebserver::coverageCalls() void TestWebserver::coverageCalls()

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h" #include "guhtestbase.h"
#include "guhcore.h" #include "nymeacore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
#include "webserver.h" #include "webserver.h"
@ -70,7 +70,7 @@ void TestWebSocketServer::initTestCase()
GuhTestBase::initTestCase(); GuhTestBase::initTestCase();
ServerConfiguration config; ServerConfiguration config;
foreach (const ServerConfiguration &c, GuhCore::instance()->configuration()->webSocketServerConfigurations()) { foreach (const ServerConfiguration &c, NymeaCore::instance()->configuration()->webSocketServerConfigurations()) {
if (c.port == 4444 && (c.address == QHostAddress("127.0.0.1") || c.address == QHostAddress("0.0.0.0"))) { if (c.port == 4444 && (c.address == QHostAddress("127.0.0.1") || c.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a websocketserver listening on 127.0.0.1:4444"; qDebug() << "Already have a websocketserver listening on 127.0.0.1:4444";
config = c; config = c;
@ -83,7 +83,7 @@ void TestWebSocketServer::initTestCase()
config.port = 4444; config.port = 4444;
config.sslEnabled = true; config.sslEnabled = true;
config.authenticationEnabled = true; config.authenticationEnabled = true;
GuhCore::instance()->configuration()->setWebSocketServerConfiguration(config); NymeaCore::instance()->configuration()->setWebSocketServerConfiguration(config);
} }