mirror of https://github.com/nymea/nymea.git
guhcore -> nymeacore
parent
dca764fafd
commit
559a8be1f6
|
|
@ -18,7 +18,7 @@
|
|||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "httpreply.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "httprequest.h"
|
||||
|
|
@ -44,7 +44,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||
writer.writeProcessingInstruction("DOCUMENT", "html");
|
||||
writer.writeComment("Auto generated html page from nymea server");
|
||||
writer.writeStartElement("html");
|
||||
writer.writeAttribute("lang", GuhCore::instance()->configuration()->locale().name());
|
||||
writer.writeAttribute("lang", NymeaCore::instance()->configuration()->locale().name());
|
||||
|
||||
// Head
|
||||
writer.writeStartElement("head");
|
||||
|
|
@ -183,7 +183,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||
writer.writeStartElement("tr");
|
||||
//: The server name description in the server infromation section of the debug interface
|
||||
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.writeStartElement("tr");
|
||||
|
|
@ -201,19 +201,19 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||
writer.writeStartElement("tr");
|
||||
//: The language description in the server infromation section of the debug interface
|
||||
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.writeStartElement("tr");
|
||||
//: The timezone description in the server infromation section of the debug interface
|
||||
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.writeStartElement("tr");
|
||||
//: The server id description in the server infromation section of the debug interface
|
||||
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.writeStartElement("tr");
|
||||
|
|
@ -234,7 +234,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||
writer.writeTextElement("td", NymeaSettings(NymeaSettings::SettingsRoleGlobal).logPath());
|
||||
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.writeEndElement(); // tr
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
|
|||
} else {
|
||||
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
|
||||
|
|
@ -517,7 +517,7 @@ QByteArray DebugServerHandler::createErrorXmlDocument(HttpReply::HttpStatusCode
|
|||
writer.writeStartDocument("1.0");
|
||||
writer.writeComment("Live generated html page from nymea");
|
||||
writer.writeStartElement("html");
|
||||
writer.writeAttribute("lang", GuhCore::instance()->configuration()->locale().name());
|
||||
writer.writeAttribute("lang", NymeaCore::instance()->configuration()->locale().name());
|
||||
|
||||
// Head
|
||||
writer.writeStartElement("head");
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhdbusservice.h"
|
||||
#include "usermanager.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
namespace guhserver {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,13 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QDBusConnection>
|
||||
#include "guhcore.h"
|
||||
#include <QDBusContext>
|
||||
|
||||
|
||||
namespace guhserver {
|
||||
|
||||
class UserManager;
|
||||
|
||||
class GuhDBusService : public QObject, public QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void UpnpDiscoveryImplementation::requestDeviceInformation(const QNetworkRequest
|
|||
|
||||
void UpnpDiscoveryImplementation::respondToSearchRequest(QHostAddress host, int port)
|
||||
{
|
||||
// TODO: Once DeviceManager (and with that this can be moved into the server, use GuhCore's configuration manager instead of parsing the config here...
|
||||
// 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);
|
||||
globalSettings.beginGroup("nymead");
|
||||
QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray();
|
||||
|
|
@ -348,7 +348,7 @@ void UpnpDiscoveryImplementation::notificationTimeout()
|
|||
|
||||
void UpnpDiscoveryImplementation::sendByeByeMessage()
|
||||
{
|
||||
// TODO: Once DeviceManager (and with that this can be moved into the server, use GuhCore's configuration manager instead of parsing the config here...
|
||||
// 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);
|
||||
globalSettings.beginGroup("nymead");
|
||||
QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray();
|
||||
|
|
@ -394,7 +394,7 @@ void UpnpDiscoveryImplementation::sendByeByeMessage()
|
|||
|
||||
void UpnpDiscoveryImplementation::sendAliveMessage()
|
||||
{
|
||||
// TODO: Once DeviceManager (and with that this) can be moved into the server, use GuhCore's configuration manager instead of parsing the config here...
|
||||
// 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);
|
||||
globalSettings.beginGroup("nymead");
|
||||
QByteArray uuid = globalSettings.value("uuid", QUuid()).toByteArray();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "plugintimermanagerimplementation.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
namespace guhserver {
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ PluginTimerImplementation::PluginTimerImplementation(int intervall, QObject *par
|
|||
PluginTimer(parent),
|
||||
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
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@
|
|||
|
||||
#include "httpreply.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QPair>
|
||||
|
|
@ -157,7 +157,7 @@ HttpReply::HttpReply(QObject *parent) :
|
|||
// set known headers
|
||||
setHeader(HttpReply::ContentTypeHeader, "text/plain; charset=\"utf-8\";");
|
||||
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::ConnectionHeader, "Keep-Alive");
|
||||
setRawHeader("Access-Control-Allow-Origin","*");
|
||||
|
|
@ -180,7 +180,7 @@ HttpReply::HttpReply(const HttpReply::HttpStatusCode &statusCode, const HttpRepl
|
|||
// set known / default headers
|
||||
setHeader(HttpReply::ContentTypeHeader, "text/plain; charset=\"utf-8\";");
|
||||
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::ConnectionHeader, "Keep-Alive");
|
||||
setRawHeader("Access-Control-Allow-Origin","*");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "actionhandler.h"
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "types/action.h"
|
||||
#include "loggingcategories.h"
|
||||
|
|
@ -62,7 +62,7 @@ ActionHandler::ActionHandler(QObject *parent) :
|
|||
returns.insert("o:actionType", JsonTypes::actionTypeDescription());
|
||||
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.*/
|
||||
|
|
@ -80,7 +80,7 @@ JsonReply* ActionHandler::ExecuteAction(const QVariantMap ¶ms)
|
|||
Action action(actionTypeId, deviceId);
|
||||
action.setParams(actionParams);
|
||||
|
||||
DeviceManager::DeviceError status = GuhCore::instance()->executeAction(action);
|
||||
DeviceManager::DeviceError status = NymeaCore::instance()->executeAction(action);
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
JsonReply *reply = createAsyncReply("ExecuteAction");
|
||||
ActionId id = action.id();
|
||||
|
|
@ -96,7 +96,7 @@ JsonReply *ActionHandler::GetActionType(const QVariantMap ¶ms) const
|
|||
{
|
||||
qCDebug(dcJsonRpc) << "asked for action type" << params;
|
||||
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()) {
|
||||
if (actionType.id() == actionTypeId) {
|
||||
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
|
||||
#include "configurationhandler.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
namespace guhserver {
|
||||
|
||||
|
|
@ -220,15 +220,15 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent):
|
|||
params.insert("enabled", JsonTypes::basicTypeToString(JsonTypes::Bool));
|
||||
setParams("CloudConfigurationChanged", params);
|
||||
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::serverNameChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::timeZoneChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::localeChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::debugServerEnabledChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::tcpServerConfigurationChanged, this, &ConfigurationHandler::onTcpServerConfigurationChanged);
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::webServerConfigurationChanged, this, &ConfigurationHandler::onWebServerConfigurationChanged);
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::webSocketServerConfigurationChanged, this, &ConfigurationHandler::onWebSocketServerConfigurationChanged);
|
||||
connect(GuhCore::instance()->configuration(), &GuhConfiguration::cloudEnabledChanged, this, &ConfigurationHandler::onCloudConfigurationChanged);
|
||||
connect(GuhCore::instance()->deviceManager(), &DeviceManager::languageUpdated, this, &ConfigurationHandler::onLanguageChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::serverNameChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::timeZoneChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::localeChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::debugServerEnabledChanged, this, &ConfigurationHandler::onBasicConfigurationChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::tcpServerConfigurationChanged, this, &ConfigurationHandler::onTcpServerConfigurationChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::webServerConfigurationChanged, this, &ConfigurationHandler::onWebServerConfigurationChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::webSocketServerConfigurationChanged, this, &ConfigurationHandler::onWebSocketServerConfigurationChanged);
|
||||
connect(NymeaCore::instance()->configuration(), &GuhConfiguration::cloudEnabledChanged, this, &ConfigurationHandler::onCloudConfigurationChanged);
|
||||
connect(NymeaCore::instance()->deviceManager(), &DeviceManager::languageUpdated, this, &ConfigurationHandler::onLanguageChanged);
|
||||
}
|
||||
|
||||
/*! Returns the name of the \l{ConfigurationHandler}. In this case \b Configuration.*/
|
||||
|
|
@ -243,26 +243,26 @@ JsonReply *ConfigurationHandler::GetConfigurations(const QVariantMap ¶ms) co
|
|||
QVariantMap returns;
|
||||
returns.insert("basicConfiguration", JsonTypes::packBasicConfiguration());
|
||||
QVariantList tcpServerConfigs;
|
||||
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->tcpServerConfigurations()) {
|
||||
foreach (const ServerConfiguration &config, NymeaCore::instance()->configuration()->tcpServerConfigurations()) {
|
||||
tcpServerConfigs.append(JsonTypes::packServerConfiguration(config));
|
||||
}
|
||||
returns.insert("tcpServerConfigurations", tcpServerConfigs);
|
||||
|
||||
QVariantList webServerConfigs;
|
||||
foreach (const WebServerConfiguration &config, GuhCore::instance()->configuration()->webServerConfigurations()) {
|
||||
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
|
||||
webServerConfigs.append(JsonTypes::packWebServerConfiguration(config));
|
||||
|
||||
}
|
||||
returns.insert("webServerConfigurations", webServerConfigs);
|
||||
|
||||
QVariantList webSocketServerConfigs;
|
||||
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->webSocketServerConfigurations()) {
|
||||
foreach (const ServerConfiguration &config, NymeaCore::instance()->configuration()->webSocketServerConfigurations()) {
|
||||
webSocketServerConfigs.append(JsonTypes::packServerConfiguration(config));
|
||||
}
|
||||
returns.insert("webSocketServerConfigurations", webSocketServerConfigs);
|
||||
|
||||
QVariantMap cloudConfig;
|
||||
cloudConfig.insert("enabled", GuhCore::instance()->configuration()->cloudEnabled());
|
||||
cloudConfig.insert("enabled", NymeaCore::instance()->configuration()->cloudEnabled());
|
||||
returns.insert("cloud", cloudConfig);
|
||||
|
||||
return createReply(returns);
|
||||
|
|
@ -272,7 +272,7 @@ JsonReply *ConfigurationHandler::GetTimeZones(const QVariantMap ¶ms) const
|
|||
{
|
||||
Q_UNUSED(params)
|
||||
QVariantList timeZones;
|
||||
foreach (const QByteArray &timeZoneId, GuhCore::instance()->timeManager()->availableTimeZones()) {
|
||||
foreach (const QByteArray &timeZoneId, NymeaCore::instance()->timeManager()->availableTimeZones()) {
|
||||
timeZones.append(QString::fromUtf8(timeZoneId));
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ JsonReply *ConfigurationHandler::GetAvailableLanguages(const QVariantMap ¶ms
|
|||
{
|
||||
Q_UNUSED(params)
|
||||
QVariantList languages;
|
||||
foreach (const QString &language, GuhCore::getAvailableLanguages()) {
|
||||
foreach (const QString &language, NymeaCore::getAvailableLanguages()) {
|
||||
languages.append(language);
|
||||
}
|
||||
QVariantMap returns;
|
||||
|
|
@ -296,7 +296,7 @@ JsonReply *ConfigurationHandler::GetAvailableLanguages(const QVariantMap ¶ms
|
|||
JsonReply *ConfigurationHandler::SetServerName(const QVariantMap ¶ms) const
|
||||
{
|
||||
QString serverName = params.value("serverName").toString();
|
||||
GuhCore::instance()->configuration()->setServerName(serverName);
|
||||
NymeaCore::instance()->configuration()->setServerName(serverName);
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
||||
|
|
@ -305,10 +305,10 @@ JsonReply *ConfigurationHandler::SetTimeZone(const QVariantMap ¶ms) const
|
|||
qCDebug(dcJsonRpc()) << "Setting time zone to" << params.value("timeZone").toString();
|
||||
|
||||
QByteArray timeZone = params.value("timeZone").toString().toUtf8();
|
||||
if (!GuhCore::instance()->timeManager()->setTimeZone(timeZone))
|
||||
if (!NymeaCore::instance()->timeManager()->setTimeZone(timeZone))
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorInvalidTimeZone));
|
||||
|
||||
GuhCore::instance()->configuration()->setTimeZone(timeZone);
|
||||
NymeaCore::instance()->configuration()->setTimeZone(timeZone);
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ JsonReply *ConfigurationHandler::SetLanguage(const QVariantMap ¶ms) const
|
|||
qCDebug(dcJsonRpc()) << "Setting language to" << 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));
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
GuhCore::instance()->configuration()->setTcpServerConfiguration(config);
|
||||
|
||||
// GuhCore::instance()->tcpServer()->reconfigureServer(config);
|
||||
|
||||
NymeaCore::instance()->configuration()->setTcpServerConfiguration(config);
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
||||
JsonReply *ConfigurationHandler::DeleteTcpServerConfiguration(const QVariantMap ¶ms) const
|
||||
{
|
||||
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));
|
||||
}
|
||||
GuhCore::instance()->configuration()->removeTcpServerConfiguration(id);
|
||||
NymeaCore::instance()->configuration()->removeTcpServerConfiguration(id);
|
||||
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);
|
||||
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
// GuhCore::instance()->webServer()->reconfigureServer(config);
|
||||
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
||||
JsonReply *ConfigurationHandler::DeleteWebServerConfiguration(const QVariantMap ¶ms) const
|
||||
{
|
||||
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));
|
||||
}
|
||||
GuhCore::instance()->configuration()->removeWebServerConfiguration(id);
|
||||
NymeaCore::instance()->configuration()->removeWebServerConfiguration(id);
|
||||
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);
|
||||
|
||||
GuhCore::instance()->configuration()->setWebSocketServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebSocketServerConfiguration(config);
|
||||
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
|
@ -412,24 +407,24 @@ JsonReply *ConfigurationHandler::SetWebSocketServerConfiguration(const QVariantM
|
|||
JsonReply *ConfigurationHandler::DeleteWebSocketServerConfiguration(const QVariantMap ¶ms) const
|
||||
{
|
||||
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));
|
||||
}
|
||||
GuhCore::instance()->configuration()->removeWebSocketServerConfiguration(id);
|
||||
NymeaCore::instance()->configuration()->removeWebSocketServerConfiguration(id);
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
||||
JsonReply *ConfigurationHandler::SetCloudEnabled(const QVariantMap ¶ms) const
|
||||
{
|
||||
bool enabled = params.value("enabled").toBool();
|
||||
GuhCore::instance()->configuration()->setCloudEnabled(enabled);
|
||||
NymeaCore::instance()->configuration()->setCloudEnabled(enabled);
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
||||
JsonReply *ConfigurationHandler::SetDebugServerEnabled(const QVariantMap ¶ms) const
|
||||
{
|
||||
bool enabled = params.value("enabled").toBool();
|
||||
GuhCore::instance()->configuration()->setDebugServerEnabled(enabled);
|
||||
NymeaCore::instance()->configuration()->setDebugServerEnabled(enabled);
|
||||
return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError));
|
||||
}
|
||||
|
||||
|
|
@ -445,7 +440,7 @@ void ConfigurationHandler::onTcpServerConfigurationChanged(const QString &id)
|
|||
{
|
||||
QVariantMap params;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -453,7 +448,7 @@ void ConfigurationHandler::onWebServerConfigurationChanged(const QString &id)
|
|||
{
|
||||
QVariantMap params;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -461,7 +456,7 @@ void ConfigurationHandler::onWebSocketServerConfigurationChanged(const QString &
|
|||
{
|
||||
QVariantMap params;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +474,7 @@ void ConfigurationHandler::onLanguageChanged()
|
|||
{
|
||||
QVariantMap params;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
*/
|
||||
|
||||
#include "devicehandler.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "types/deviceclass.h"
|
||||
|
|
@ -292,15 +292,15 @@ DeviceHandler::DeviceHandler(QObject *parent) :
|
|||
params.insert("device", JsonTypes::deviceRef());
|
||||
setParams("DeviceChanged", params);
|
||||
|
||||
connect(GuhCore::instance(), &GuhCore::pluginConfigChanged, this, &DeviceHandler::pluginConfigChanged);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceStateChanged, this, &DeviceHandler::deviceStateChanged);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceRemoved, this, &DeviceHandler::deviceRemovedNotification);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceAdded, this, &DeviceHandler::deviceAddedNotification);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceChanged, this, &DeviceHandler::deviceChangedNotification);
|
||||
connect(GuhCore::instance(), &GuhCore::devicesDiscovered, this, &DeviceHandler::devicesDiscovered, Qt::QueuedConnection);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceSetupFinished, this, &DeviceHandler::deviceSetupFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceReconfigurationFinished, this, &DeviceHandler::deviceReconfigurationFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DeviceHandler::pairingFinished);
|
||||
connect(NymeaCore::instance(), &NymeaCore::pluginConfigChanged, this, &DeviceHandler::pluginConfigChanged);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceStateChanged, this, &DeviceHandler::deviceStateChanged);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceRemoved, this, &DeviceHandler::deviceRemovedNotification);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceAdded, this, &DeviceHandler::deviceAddedNotification);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceChanged, this, &DeviceHandler::deviceChangedNotification);
|
||||
connect(NymeaCore::instance(), &NymeaCore::devicesDiscovered, this, &DeviceHandler::devicesDiscovered, Qt::QueuedConnection);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceSetupFinished, this, &DeviceHandler::deviceSetupFinished);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceReconfigurationFinished, this, &DeviceHandler::deviceReconfigurationFinished);
|
||||
connect(NymeaCore::instance(), &NymeaCore::pairingFinished, this, &DeviceHandler::pairingFinished);
|
||||
}
|
||||
|
||||
/*! Returns the name of the \l{DeviceHandler}. In this case \b Devices.*/
|
||||
|
|
@ -333,7 +333,7 @@ JsonReply *DeviceHandler::GetDiscoveredDevices(const QVariantMap ¶ms) const
|
|||
|
||||
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 ) {
|
||||
JsonReply *reply = createAsyncReply("GetDiscoveredDevices");
|
||||
connect(reply, &JsonReply::finished, [this, deviceClassId](){ m_discoverRequests.remove(deviceClassId); });
|
||||
|
|
@ -357,7 +357,7 @@ JsonReply *DeviceHandler::GetPluginConfiguration(const QVariantMap ¶ms) cons
|
|||
{
|
||||
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) {
|
||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorPluginNotFound));
|
||||
return createReply(returns);
|
||||
|
|
@ -377,7 +377,7 @@ JsonReply* DeviceHandler::SetPluginConfiguration(const QVariantMap ¶ms)
|
|||
QVariantMap returns;
|
||||
PluginId pluginId = PluginId(params.value("pluginId").toString());
|
||||
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));
|
||||
return createReply(returns);
|
||||
}
|
||||
|
|
@ -391,9 +391,9 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
|||
DeviceId newDeviceId = DeviceId::createDeviceId();
|
||||
DeviceManager::DeviceError status;
|
||||
if (deviceDescriptorId.isNull()) {
|
||||
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceParams, newDeviceId);
|
||||
status = NymeaCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceParams, newDeviceId);
|
||||
} else {
|
||||
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceDescriptorId, newDeviceId);
|
||||
status = NymeaCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceName, deviceDescriptorId, newDeviceId);
|
||||
}
|
||||
QVariantMap returns;
|
||||
switch (status) {
|
||||
|
|
@ -417,16 +417,16 @@ JsonReply *DeviceHandler::PairDevice(const QVariantMap ¶ms)
|
|||
{
|
||||
DeviceClassId deviceClassId(params.value("deviceClassId").toString());
|
||||
QString deviceName = params.value("name").toString();
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
|
||||
DeviceManager::DeviceError status;
|
||||
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
|
||||
if (params.contains("deviceDescriptorId")) {
|
||||
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 {
|
||||
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;
|
||||
|
|
@ -443,7 +443,7 @@ JsonReply *DeviceHandler::ConfirmPairing(const QVariantMap ¶ms)
|
|||
{
|
||||
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").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;
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
|
|
@ -463,7 +463,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap ¶ms) const
|
|||
QVariantMap returns;
|
||||
QVariantList configuredDeviceList;
|
||||
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) {
|
||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
|
||||
return createReply(returns);
|
||||
|
|
@ -471,7 +471,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap ¶ms) const
|
|||
configuredDeviceList.append(JsonTypes::packDevice(device));
|
||||
}
|
||||
} else {
|
||||
foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) {
|
||||
foreach (Device *device, NymeaCore::instance()->deviceManager()->configuredDevices()) {
|
||||
configuredDeviceList.append(JsonTypes::packDevice(device));
|
||||
}
|
||||
}
|
||||
|
|
@ -488,9 +488,9 @@ JsonReply *DeviceHandler::ReconfigureDevice(const QVariantMap ¶ms)
|
|||
DeviceManager::DeviceError status;
|
||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||
if (deviceDescriptorId.isNull()) {
|
||||
status = GuhCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceParams);
|
||||
status = NymeaCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceParams);
|
||||
} else {
|
||||
status = GuhCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceDescriptorId);
|
||||
status = NymeaCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceDescriptorId);
|
||||
}
|
||||
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
|
|
@ -512,7 +512,7 @@ JsonReply *DeviceHandler::EditDevice(const QVariantMap ¶ms)
|
|||
|
||||
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;
|
||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(status));
|
||||
|
|
@ -527,7 +527,7 @@ JsonReply* DeviceHandler::RemoveConfiguredDevice(const QVariantMap ¶ms)
|
|||
// global removePolicy has priority
|
||||
if (params.contains("removePolicy")) {
|
||||
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));
|
||||
return createReply(returns);
|
||||
}
|
||||
|
|
@ -539,7 +539,7 @@ JsonReply* DeviceHandler::RemoveConfiguredDevice(const QVariantMap ¶ms)
|
|||
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));
|
||||
|
||||
if (!status.second.isEmpty()) {
|
||||
|
|
@ -558,7 +558,7 @@ JsonReply* DeviceHandler::GetEventTypes(const QVariantMap ¶ms) const
|
|||
QVariantMap returns;
|
||||
|
||||
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()) {
|
||||
eventList.append(JsonTypes::packEventType(eventType));
|
||||
}
|
||||
|
|
@ -571,7 +571,7 @@ JsonReply* DeviceHandler::GetActionTypes(const QVariantMap ¶ms) const
|
|||
QVariantMap returns;
|
||||
|
||||
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()) {
|
||||
actionList.append(JsonTypes::packActionType(actionType));
|
||||
}
|
||||
|
|
@ -584,7 +584,7 @@ JsonReply* DeviceHandler::GetStateTypes(const QVariantMap ¶ms) const
|
|||
QVariantMap returns;
|
||||
|
||||
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()) {
|
||||
stateList.append(JsonTypes::packStateType(stateType));
|
||||
}
|
||||
|
|
@ -596,7 +596,7 @@ JsonReply* DeviceHandler::GetStateValue(const QVariantMap ¶ms) const
|
|||
{
|
||||
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) {
|
||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
|
||||
return createReply(returns);
|
||||
|
|
@ -616,7 +616,7 @@ JsonReply *DeviceHandler::GetStateValues(const QVariantMap ¶ms) const
|
|||
{
|
||||
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) {
|
||||
returns.insert("deviceError", JsonTypes::deviceErrorToString(DeviceManager::DeviceErrorDeviceNotFound));
|
||||
return createReply(returns);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include "eventhandler.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
namespace guhserver {
|
||||
|
|
@ -64,7 +64,7 @@ EventHandler::EventHandler(QObject *parent) :
|
|||
returns.insert("o:eventType", JsonTypes::eventTypeRef());
|
||||
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.*/
|
||||
|
|
@ -84,7 +84,7 @@ JsonReply* EventHandler::GetEventType(const QVariantMap ¶ms) const
|
|||
{
|
||||
qCDebug(dcJsonRpc) << "asked for event type" << params;
|
||||
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()) {
|
||||
if (eventType.id() == eventTypeId) {
|
||||
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "jsonrpcserver.h"
|
||||
#include "jsontypes.h"
|
||||
#include "jsonhandler.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "types/deviceclass.h"
|
||||
|
|
@ -201,7 +201,7 @@ JsonRPCServer::JsonRPCServer(const QSslConfiguration &sslConfiguration, QObject
|
|||
|
||||
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}. */
|
||||
|
|
@ -262,7 +262,7 @@ JsonReply *JsonRPCServer::CreateUser(const QVariantMap ¶ms)
|
|||
QString username = params.value("username").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;
|
||||
returns.insert("error", JsonTypes::userErrorToString(status));
|
||||
|
|
@ -275,7 +275,7 @@ JsonReply *JsonRPCServer::Authenticate(const QVariantMap ¶ms)
|
|||
QString password = params.value("password").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;
|
||||
ret.insert("success", !token.isEmpty());
|
||||
if (!token.isEmpty()) {
|
||||
|
|
@ -289,7 +289,7 @@ JsonReply *JsonRPCServer::RequestPushButtonAuth(const QVariantMap ¶ms)
|
|||
QString deviceName = params.value("deviceName").toString();
|
||||
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);
|
||||
|
||||
QVariantMap data;
|
||||
|
|
@ -304,12 +304,12 @@ JsonReply *JsonRPCServer::Tokens(const QVariantMap ¶ms) const
|
|||
Q_UNUSED(params)
|
||||
QByteArray token = property("token").toByteArray();
|
||||
|
||||
QString username = GuhCore::instance()->userManager()->userForToken(token);
|
||||
QString username = NymeaCore::instance()->userManager()->userForToken(token);
|
||||
if (username.isEmpty()) {
|
||||
// There *really* should be a user for the token in the DB
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
QList<TokenInfo> tokens = GuhCore::instance()->userManager()->tokens(username);
|
||||
QList<TokenInfo> tokens = NymeaCore::instance()->userManager()->tokens(username);
|
||||
QVariantList retList;
|
||||
foreach (const TokenInfo &tokenInfo, tokens) {
|
||||
retList << JsonTypes::packTokenInfo(tokenInfo);
|
||||
|
|
@ -322,7 +322,7 @@ JsonReply *JsonRPCServer::Tokens(const QVariantMap ¶ms) const
|
|||
JsonReply *JsonRPCServer::RemoveToken(const QVariantMap ¶ms)
|
||||
{
|
||||
QUuid tokenId = params.value("tokenId").toUuid();
|
||||
UserManager::UserError error = GuhCore::instance()->userManager()->removeToken(tokenId);
|
||||
UserManager::UserError error = NymeaCore::instance()->userManager()->removeToken(tokenId);
|
||||
QVariantMap ret;
|
||||
ret.insert("error", JsonTypes::userErrorToString(error));
|
||||
return createReply(ret);
|
||||
|
|
@ -332,7 +332,7 @@ JsonReply *JsonRPCServer::SetupRemoteAccess(const QVariantMap ¶ms)
|
|||
{
|
||||
QString idToken = params.value("idToken").toString();
|
||||
QString userId = params.value("userId").toString();
|
||||
GuhCore::instance()->cloudManager()->pairDevice(idToken, userId);
|
||||
NymeaCore::instance()->cloudManager()->pairDevice(idToken, userId);
|
||||
JsonReply *reply = createAsyncReply("SetupRemoteAccess");
|
||||
m_pairingRequests.insert(userId, reply);
|
||||
connect(reply, &JsonReply::finished, [this, userId](){
|
||||
|
|
@ -344,7 +344,7 @@ JsonReply *JsonRPCServer::SetupRemoteAccess(const QVariantMap ¶ms)
|
|||
JsonReply *JsonRPCServer::IsCloudConnected(const QVariantMap ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
bool connected = GuhCore::instance()->cloudManager()->connected();
|
||||
bool connected = NymeaCore::instance()->cloudManager()->connected();
|
||||
QVariantMap data;
|
||||
data.insert("connected", connected);
|
||||
return createReply(data);
|
||||
|
|
@ -353,7 +353,7 @@ JsonReply *JsonRPCServer::IsCloudConnected(const QVariantMap ¶ms)
|
|||
JsonReply *JsonRPCServer::KeepAlive(const QVariantMap ¶ms)
|
||||
{
|
||||
QString sessionId = params.value("sessionId").toString();
|
||||
bool result = GuhCore::instance()->cloudManager()->keepAlive(sessionId);
|
||||
bool result = NymeaCore::instance()->cloudManager()->keepAlive(sessionId);
|
||||
QVariantMap resultMap;
|
||||
resultMap.insert("success", result);
|
||||
return createReply(resultMap);
|
||||
|
|
@ -431,14 +431,14 @@ QVariantMap JsonRPCServer::createWelcomeMessage(TransportInterface *interface) c
|
|||
QVariantMap handshake;
|
||||
handshake.insert("id", 0);
|
||||
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("uuid", GuhCore::instance()->configuration()->serverUuid().toString());
|
||||
handshake.insert("language", GuhCore::instance()->configuration()->locale().name());
|
||||
handshake.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
|
||||
handshake.insert("language", NymeaCore::instance()->configuration()->locale().name());
|
||||
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("pushButtonAuthAvailable", GuhCore::instance()->userManager()->pushButtonAuthAvailable());
|
||||
handshake.insert("pushButtonAuthAvailable", NymeaCore::instance()->userManager()->pushButtonAuthAvailable());
|
||||
return handshake;
|
||||
}
|
||||
|
||||
|
|
@ -454,8 +454,8 @@ void JsonRPCServer::setup()
|
|||
registerHandler(new ConfigurationHandler(this));
|
||||
registerHandler(new NetworkManagerHandler(this));
|
||||
|
||||
connect(GuhCore::instance()->cloudManager(), &CloudManager::pairingReply, this, &JsonRPCServer::pairingFinished);
|
||||
connect(GuhCore::instance()->cloudManager(), &CloudManager::connectedChanged, this, &JsonRPCServer::onCloudConnectedChanged);
|
||||
connect(NymeaCore::instance()->cloudManager(), &CloudManager::pairingReply, this, &JsonRPCServer::pairingFinished);
|
||||
connect(NymeaCore::instance()->cloudManager(), &CloudManager::connectedChanged, this, &JsonRPCServer::onCloudConnectedChanged);
|
||||
}
|
||||
|
||||
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 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 (GuhCore::instance()->userManager()->users().isEmpty()) {
|
||||
if (!(targetNamespace == "JSONRPC" && authExemptMethodsNoUser.contains(method)) && (token.isEmpty() || !GuhCore::instance()->userManager()->verifyToken(token))) {
|
||||
if (NymeaCore::instance()->userManager()->users().isEmpty()) {
|
||||
if (!(targetNamespace == "JSONRPC" && authExemptMethodsNoUser.contains(method)) && (token.isEmpty() || !NymeaCore::instance()->userManager()->verifyToken(token))) {
|
||||
sendUnauthorizedResponse(interface, clientId, commandId, "Initial setup required. Call CreateUser first.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 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.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -676,7 +676,7 @@ void JsonRPCServer::clientDisconnected(const QUuid &clientId)
|
|||
m_clientTransports.remove(clientId);
|
||||
m_clientNotifications.remove(clientId);
|
||||
if (m_pushButtonTransactions.values().contains(clientId)) {
|
||||
GuhCore::instance()->userManager()->cancelPushButtonAuth(m_pushButtonTransactions.key(clientId));
|
||||
NymeaCore::instance()->userManager()->cancelPushButtonAuth(m_pushButtonTransactions.key(clientId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "ruleengine.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "logging/logvaluetool.h"
|
||||
|
|
@ -1060,7 +1060,7 @@ QVariantMap JsonTypes::packWirelessNetworkDevice(WirelessNetworkDevice *networkD
|
|||
QVariantList JsonTypes::packSupportedVendors()
|
||||
{
|
||||
QVariantList supportedVendors;
|
||||
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors())
|
||||
foreach (const Vendor &vendor, NymeaCore::instance()->deviceManager()->supportedVendors())
|
||||
supportedVendors.append(packVendor(vendor));
|
||||
|
||||
return supportedVendors;
|
||||
|
|
@ -1070,7 +1070,7 @@ QVariantList JsonTypes::packSupportedVendors()
|
|||
QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
||||
{
|
||||
QVariantList supportedDeviceList;
|
||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices(vendorId))
|
||||
foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices(vendorId))
|
||||
supportedDeviceList.append(packDeviceClass(deviceClass));
|
||||
|
||||
return supportedDeviceList;
|
||||
|
|
@ -1080,7 +1080,7 @@ QVariantList JsonTypes::packSupportedDevices(const VendorId &vendorId)
|
|||
QVariantList JsonTypes::packConfiguredDevices()
|
||||
{
|
||||
QVariantList configuredDeviceList;
|
||||
foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices())
|
||||
foreach (Device *device, NymeaCore::instance()->deviceManager()->configuredDevices())
|
||||
configuredDeviceList.append(packDevice(device));
|
||||
|
||||
return configuredDeviceList;
|
||||
|
|
@ -1089,7 +1089,7 @@ QVariantList JsonTypes::packConfiguredDevices()
|
|||
/*! Returns a variant list of States from the given \a device. */
|
||||
QVariantList JsonTypes::packDeviceStates(Device *device)
|
||||
{
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
QVariantList stateValues;
|
||||
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
||||
QVariantMap stateValue;
|
||||
|
|
@ -1114,12 +1114,12 @@ QVariantList JsonTypes::packDeviceDescriptors(const QList<DeviceDescriptor> devi
|
|||
QVariantMap JsonTypes::packBasicConfiguration()
|
||||
{
|
||||
QVariantMap basicConfiguration;
|
||||
basicConfiguration.insert("serverName", GuhCore::instance()->configuration()->serverName());
|
||||
basicConfiguration.insert("serverUuid", GuhCore::instance()->configuration()->serverUuid());
|
||||
basicConfiguration.insert("serverTime", GuhCore::instance()->timeManager()->currentDateTime().toTime_t());
|
||||
basicConfiguration.insert("timeZone", QString::fromUtf8(GuhCore::instance()->timeManager()->timeZone()));
|
||||
basicConfiguration.insert("language", GuhCore::instance()->configuration()->locale().name());
|
||||
basicConfiguration.insert("debugServerEnabled", GuhCore::instance()->configuration()->debugServerEnabled());
|
||||
basicConfiguration.insert("serverName", NymeaCore::instance()->configuration()->serverName());
|
||||
basicConfiguration.insert("serverUuid", NymeaCore::instance()->configuration()->serverUuid());
|
||||
basicConfiguration.insert("serverTime", NymeaCore::instance()->timeManager()->currentDateTime().toTime_t());
|
||||
basicConfiguration.insert("timeZone", QString::fromUtf8(NymeaCore::instance()->timeManager()->timeZone()));
|
||||
basicConfiguration.insert("language", NymeaCore::instance()->configuration()->locale().name());
|
||||
basicConfiguration.insert("debugServerEnabled", NymeaCore::instance()->configuration()->debugServerEnabled());
|
||||
return basicConfiguration;
|
||||
}
|
||||
|
||||
|
|
@ -1146,7 +1146,7 @@ QVariantMap JsonTypes::packWebServerConfiguration(const WebServerConfiguration &
|
|||
QVariantList JsonTypes::packRuleDescriptions()
|
||||
{
|
||||
QVariantList rulesList;
|
||||
foreach (const Rule &rule, GuhCore::instance()->ruleEngine()->rules())
|
||||
foreach (const Rule &rule, NymeaCore::instance()->ruleEngine()->rules())
|
||||
rulesList.append(JsonTypes::packRuleDescription(rule));
|
||||
|
||||
return rulesList;
|
||||
|
|
@ -1196,7 +1196,7 @@ QVariantList JsonTypes::packEventTypes(const DeviceClass &deviceClass)
|
|||
QVariantList JsonTypes::packPlugins()
|
||||
{
|
||||
QVariantList pluginsList;
|
||||
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) {
|
||||
foreach (DevicePlugin *plugin, NymeaCore::instance()->deviceManager()->plugins()) {
|
||||
QVariantMap pluginMap = packPlugin(plugin);
|
||||
pluginsList.append(pluginMap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
#include "logging/logengine.h"
|
||||
#include "logging/logfilter.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
namespace guhserver {
|
||||
|
||||
|
|
@ -91,8 +91,8 @@ LoggingHandler::LoggingHandler(QObject *parent) :
|
|||
"keep to database in the size limits.");
|
||||
setParams("LogDatabaseUpdated", params);
|
||||
|
||||
connect(GuhCore::instance()->logEngine(), &LogEngine::logEntryAdded, this, &LoggingHandler::logEntryAdded);
|
||||
connect(GuhCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated);
|
||||
connect(NymeaCore::instance()->logEngine(), &LogEngine::logEntryAdded, this, &LoggingHandler::logEntryAdded);
|
||||
connect(NymeaCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated);
|
||||
}
|
||||
|
||||
/*! Returns the name of the \l{LoggingHandler}. In this case \b Logging.*/
|
||||
|
|
@ -122,7 +122,7 @@ JsonReply* LoggingHandler::GetLogEntries(const QVariantMap ¶ms) const
|
|||
LogFilter filter = JsonTypes::unpackLogFilter(params);
|
||||
|
||||
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));
|
||||
}
|
||||
QVariantMap returns = statusToReply(Logging::LoggingErrorNoError);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "jsontypes.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "networkmanagerhandler.h"
|
||||
|
|
@ -182,17 +182,17 @@ NetworkManagerHandler::NetworkManagerHandler(QObject *parent) :
|
|||
params.insert("wiredNetworkDevice", JsonTypes::wiredNetworkDeviceRef());
|
||||
setParams("WiredNetworkDeviceChanged", params);
|
||||
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::stateChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::networkingEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::stateChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::networkingEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessEnabledChanged, this, &NetworkManagerHandler::onNetworkManagerStatusChanged);
|
||||
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessDeviceAdded, this, &NetworkManagerHandler::onWirelessNetworkDeviceAdded);
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessDeviceRemoved, this, &NetworkManagerHandler::onWirelessNetworkDeviceRemoved);
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::wirelessDeviceChanged, this, &NetworkManagerHandler::onWirelessNetworkDeviceChanged);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessDeviceAdded, this, &NetworkManagerHandler::onWirelessNetworkDeviceAdded);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessDeviceRemoved, this, &NetworkManagerHandler::onWirelessNetworkDeviceRemoved);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::wirelessDeviceChanged, this, &NetworkManagerHandler::onWirelessNetworkDeviceChanged);
|
||||
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::wiredDeviceAdded, this, &NetworkManagerHandler::onWiredNetworkDeviceAdded);
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::wiredDeviceRemoved, this, &NetworkManagerHandler::onWiredNetworkDeviceRemoved);
|
||||
connect(GuhCore::instance()->networkManager(), &NetworkManager::wiredDeviceChanged, this, &NetworkManagerHandler::onWiredNetworkDeviceChanged);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::wiredDeviceAdded, this, &NetworkManagerHandler::onWiredNetworkDeviceAdded);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::wiredDeviceRemoved, this, &NetworkManagerHandler::onWiredNetworkDeviceRemoved);
|
||||
connect(NymeaCore::instance()->networkManager(), &NetworkManager::wiredDeviceChanged, this, &NetworkManagerHandler::onWiredNetworkDeviceChanged);
|
||||
}
|
||||
|
||||
/*! Returns the name of the \l{NetworkManagerHandler}. In this case \b NetworkManager. */
|
||||
|
|
@ -206,7 +206,7 @@ JsonReply *NetworkManagerHandler::GetNetworkStatus(const QVariantMap ¶ms)
|
|||
Q_UNUSED(params);
|
||||
|
||||
// Check available
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
// Pack network manager status
|
||||
|
|
@ -218,12 +218,12 @@ JsonReply *NetworkManagerHandler::GetNetworkStatus(const QVariantMap ¶ms)
|
|||
|
||||
JsonReply *NetworkManagerHandler::EnableNetworking(const QVariantMap ¶ms)
|
||||
{
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
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::NetworkManagerErrorNoError));
|
||||
|
|
@ -231,13 +231,13 @@ JsonReply *NetworkManagerHandler::EnableNetworking(const QVariantMap ¶ms)
|
|||
|
||||
JsonReply *NetworkManagerHandler::EnableWirelessNetworking(const QVariantMap ¶ms)
|
||||
{
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->wifiAvailable())
|
||||
if (!NymeaCore::instance()->networkManager()->wifiAvailable())
|
||||
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::NetworkManagerErrorNoError));
|
||||
|
|
@ -245,24 +245,24 @@ JsonReply *NetworkManagerHandler::EnableWirelessNetworking(const QVariantMap &pa
|
|||
|
||||
JsonReply *NetworkManagerHandler::GetWirelessAccessPoints(const QVariantMap ¶ms)
|
||||
{
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->wifiAvailable())
|
||||
if (!NymeaCore::instance()->networkManager()->wifiAvailable())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->networkingEnabled())
|
||||
if (!NymeaCore::instance()->networkManager()->networkingEnabled())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->wirelessEnabled())
|
||||
if (!NymeaCore::instance()->networkManager()->wirelessEnabled())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled));
|
||||
|
||||
QString interface = params.value("interface").toString();
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->getNetworkDevice(interface))
|
||||
if (!NymeaCore::instance()->networkManager()->getNetworkDevice(interface))
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound));
|
||||
|
||||
foreach (WirelessNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wirelessNetworkDevices()) {
|
||||
foreach (WirelessNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wirelessNetworkDevices()) {
|
||||
if (networkDevice->interface() == interface) {
|
||||
QVariantList wirelessAccessPoints;
|
||||
foreach (WirelessAccessPoint *wirelessAccessPoint, networkDevice->accessPoints())
|
||||
|
|
@ -283,15 +283,15 @@ JsonReply *NetworkManagerHandler::GetNetworkDevices(const QVariantMap ¶ms)
|
|||
{
|
||||
Q_UNUSED(params);
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
QVariantList wirelessNetworkDevices;
|
||||
foreach (WirelessNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wirelessNetworkDevices())
|
||||
foreach (WirelessNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wirelessNetworkDevices())
|
||||
wirelessNetworkDevices.append(JsonTypes::packWirelessNetworkDevice(networkDevice));
|
||||
|
||||
QVariantList wiredNetworkDevices;
|
||||
foreach (WiredNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wiredNetworkDevices())
|
||||
foreach (WiredNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wiredNetworkDevices())
|
||||
wiredNetworkDevices.append(JsonTypes::packWiredNetworkDevice(networkDevice));
|
||||
|
||||
QVariantMap returns;
|
||||
|
|
@ -305,25 +305,25 @@ JsonReply *NetworkManagerHandler::ScanWifiNetworks(const QVariantMap ¶ms)
|
|||
{
|
||||
Q_UNUSED(params);
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->wifiAvailable())
|
||||
if (!NymeaCore::instance()->networkManager()->wifiAvailable())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->networkingEnabled())
|
||||
if (!NymeaCore::instance()->networkManager()->networkingEnabled())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->wirelessEnabled())
|
||||
if (!NymeaCore::instance()->networkManager()->wirelessEnabled())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled));
|
||||
|
||||
|
||||
QString interface = params.value("interface").toString();
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->getNetworkDevice(interface))
|
||||
if (!NymeaCore::instance()->networkManager()->getNetworkDevice(interface))
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound));
|
||||
|
||||
foreach (WirelessNetworkDevice *networkDevice, GuhCore::instance()->networkManager()->wirelessNetworkDevices()) {
|
||||
foreach (WirelessNetworkDevice *networkDevice, NymeaCore::instance()->networkManager()->wirelessNetworkDevices()) {
|
||||
if (networkDevice->interface() == interface) {
|
||||
networkDevice->scanWirelessNetworks();
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNoError));
|
||||
|
|
@ -335,16 +335,16 @@ JsonReply *NetworkManagerHandler::ScanWifiNetworks(const QVariantMap ¶ms)
|
|||
|
||||
JsonReply *NetworkManagerHandler::ConnectWifiNetwork(const QVariantMap ¶ms)
|
||||
{
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->wifiAvailable())
|
||||
if (!NymeaCore::instance()->networkManager()->wifiAvailable())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNotAvailable));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->networkingEnabled())
|
||||
if (!NymeaCore::instance()->networkManager()->networkingEnabled())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkingDisabled));
|
||||
|
||||
if (!GuhCore::instance()->networkManager()->wirelessEnabled())
|
||||
if (!NymeaCore::instance()->networkManager()->wirelessEnabled())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorWirelessNetworkingDisabled));
|
||||
|
||||
|
||||
|
|
@ -352,16 +352,16 @@ JsonReply *NetworkManagerHandler::ConnectWifiNetwork(const QVariantMap ¶ms)
|
|||
QString password = params.value("password").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 ¶ms)
|
||||
{
|
||||
if (!GuhCore::instance()->networkManager()->available())
|
||||
if (!NymeaCore::instance()->networkManager()->available())
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkManagerNotAvailable));
|
||||
|
||||
QString interface = params.value("interface").toString();
|
||||
NetworkDevice *networkDevice = GuhCore::instance()->networkManager()->getNetworkDevice(interface);
|
||||
NetworkDevice *networkDevice = NymeaCore::instance()->networkManager()->getNetworkDevice(interface);
|
||||
if (!networkDevice)
|
||||
return createReply(statusToReply(NetworkManager::NetworkManagerErrorNetworkInterfaceNotFound));
|
||||
|
||||
|
|
@ -372,9 +372,9 @@ JsonReply *NetworkManagerHandler::DisconnectInterface(const QVariantMap ¶ms)
|
|||
QVariantMap NetworkManagerHandler::packNetworkManagerStatus()
|
||||
{
|
||||
QVariantMap status;
|
||||
status.insert("networkingEnabled", GuhCore::instance()->networkManager()->networkingEnabled());
|
||||
status.insert("wirelessNetworkingEnabled", GuhCore::instance()->networkManager()->wirelessEnabled());
|
||||
status.insert("state", GuhCore::instance()->networkManager()->stateString());
|
||||
status.insert("networkingEnabled", NymeaCore::instance()->networkManager()->networkingEnabled());
|
||||
status.insert("wirelessNetworkingEnabled", NymeaCore::instance()->networkManager()->wirelessEnabled());
|
||||
status.insert("state", NymeaCore::instance()->networkManager()->stateString());
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
*/
|
||||
|
||||
#include "ruleshandler.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "ruleengine.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
|
|
@ -185,10 +185,10 @@ RulesHandler::RulesHandler(QObject *parent) :
|
|||
params.insert("rule", JsonTypes::ruleRef());
|
||||
setParams("RuleConfigurationChanged", params);
|
||||
|
||||
connect(GuhCore::instance(), &GuhCore::ruleAdded, this, &RulesHandler::ruleAddedNotification);
|
||||
connect(GuhCore::instance(), &GuhCore::ruleRemoved, this, &RulesHandler::ruleRemovedNotification);
|
||||
connect(GuhCore::instance(), &GuhCore::ruleActiveChanged, this, &RulesHandler::ruleActiveChangedNotification);
|
||||
connect(GuhCore::instance(), &GuhCore::ruleConfigurationChanged, this, &RulesHandler::ruleConfigurationChangedNotification);
|
||||
connect(NymeaCore::instance(), &NymeaCore::ruleAdded, this, &RulesHandler::ruleAddedNotification);
|
||||
connect(NymeaCore::instance(), &NymeaCore::ruleRemoved, this, &RulesHandler::ruleRemovedNotification);
|
||||
connect(NymeaCore::instance(), &NymeaCore::ruleActiveChanged, this, &RulesHandler::ruleActiveChangedNotification);
|
||||
connect(NymeaCore::instance(), &NymeaCore::ruleConfigurationChanged, this, &RulesHandler::ruleConfigurationChangedNotification);
|
||||
}
|
||||
|
||||
/*! Returns the name of the \l{RulesHandler}. In this case \b Rules.*/
|
||||
|
|
@ -210,7 +210,7 @@ JsonReply* RulesHandler::GetRules(const QVariantMap ¶ms)
|
|||
JsonReply *RulesHandler::GetRuleDetails(const QVariantMap ¶ms)
|
||||
{
|
||||
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()) {
|
||||
return createReply(statusToReply(RuleEngine::RuleErrorRuleNotFound));
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ JsonReply* RulesHandler::AddRule(const QVariantMap ¶ms)
|
|||
Rule rule = JsonTypes::unpackRule(params);
|
||||
rule.setId(RuleId::createRuleId());
|
||||
|
||||
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->addRule(rule);
|
||||
RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->addRule(rule);
|
||||
QVariantMap returns;
|
||||
if (status == RuleEngine::RuleErrorNoError) {
|
||||
returns.insert("ruleId", rule.id().toString());
|
||||
|
|
@ -236,10 +236,10 @@ JsonReply* RulesHandler::AddRule(const QVariantMap ¶ms)
|
|||
JsonReply *RulesHandler::EditRule(const QVariantMap ¶ms)
|
||||
{
|
||||
Rule rule = JsonTypes::unpackRule(params);
|
||||
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->editRule(rule);
|
||||
RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->editRule(rule);
|
||||
QVariantMap returns;
|
||||
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));
|
||||
return createReply(returns);
|
||||
|
|
@ -249,7 +249,7 @@ JsonReply* RulesHandler::RemoveRule(const QVariantMap ¶ms)
|
|||
{
|
||||
QVariantMap returns;
|
||||
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));
|
||||
return createReply(returns);
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ JsonReply* RulesHandler::RemoveRule(const QVariantMap ¶ms)
|
|||
JsonReply *RulesHandler::FindRules(const QVariantMap ¶ms)
|
||||
{
|
||||
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;
|
||||
foreach (const RuleId &ruleId, rules) {
|
||||
|
|
@ -271,19 +271,19 @@ JsonReply *RulesHandler::FindRules(const QVariantMap ¶ms)
|
|||
|
||||
JsonReply *RulesHandler::EnableRule(const QVariantMap ¶ms)
|
||||
{
|
||||
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 ¶ms)
|
||||
{
|
||||
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 ¶ms)
|
||||
{
|
||||
QVariantMap returns;
|
||||
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));
|
||||
return createReply(returns);
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ JsonReply *RulesHandler::ExecuteExitActions(const QVariantMap ¶ms)
|
|||
{
|
||||
QVariantMap returns;
|
||||
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));
|
||||
return createReply(returns);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
|
||||
#include "statehandler.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
namespace guhserver {
|
||||
|
|
@ -64,7 +64,7 @@ JsonReply* StateHandler::GetStateType(const QVariantMap ¶ms) const
|
|||
{
|
||||
qCDebug(dcJsonRpc) << "asked for state type" << params;
|
||||
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()) {
|
||||
if (stateType.id() == stateTypeId) {
|
||||
QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ RESOURCES += $$top_srcdir/icons.qrc \
|
|||
$$top_srcdir/data/debug-interface/debug-interface.qrc
|
||||
|
||||
|
||||
HEADERS += guhcore.h \
|
||||
HEADERS += nymeacore.h \
|
||||
tcpserver.h \
|
||||
mocktcpserver.h \
|
||||
ruleengine.h \
|
||||
|
|
@ -96,7 +96,7 @@ HEADERS += guhcore.h \
|
|||
hardware/network/avahi/qtavahiservicebrowserimplementation_p.h \
|
||||
debugserverhandler.h
|
||||
|
||||
SOURCES += guhcore.cpp \
|
||||
SOURCES += nymeacore.cpp \
|
||||
tcpserver.cpp \
|
||||
mocktcpserver.cpp \
|
||||
ruleengine.cpp \
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include "logentry.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "jsonrpc/jsontypes.h"
|
||||
|
||||
#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.*/
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "mocktcpserver.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
|
||||
#include <QUuid>
|
||||
#include <QHash>
|
||||
|
|
|
|||
|
|
@ -20,71 +20,71 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*!
|
||||
\class guhserver::GuhCore
|
||||
\brief The main entry point for the Guh Server and the place where all the messages are dispatched.
|
||||
\class guhserver::NymeaCore
|
||||
\brief The main entry point for the nymea Server and the place where all the messages are dispatched.
|
||||
|
||||
\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.
|
||||
*/
|
||||
|
||||
/*! \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.
|
||||
*/
|
||||
|
||||
/*! \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
|
||||
\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.
|
||||
*/
|
||||
|
||||
/*! \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.
|
||||
*/
|
||||
|
||||
/*! \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.
|
||||
*/
|
||||
|
||||
/*! \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.
|
||||
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
|
||||
list of \l{DeviceDescriptor}{DeviceDescriptors} of all discovered \l{Device}{Devices}.
|
||||
\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
|
||||
\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
|
||||
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 \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.
|
||||
*/
|
||||
|
||||
/*! \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.
|
||||
*/
|
||||
|
||||
/*! \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.
|
||||
*/
|
||||
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
\sa Rule::active()
|
||||
*/
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "jsonrpc/jsonrpcserver.h"
|
||||
#include "ruleengine.h"
|
||||
|
|
@ -108,19 +108,19 @@
|
|||
|
||||
namespace guhserver {
|
||||
|
||||
GuhCore* GuhCore::s_instance = 0;
|
||||
NymeaCore* NymeaCore::s_instance = 0;
|
||||
|
||||
/*! Returns a pointer to the single \l{GuhCore} instance. */
|
||||
GuhCore *GuhCore::instance()
|
||||
/*! Returns a pointer to the single \l{NymeaCore} instance. */
|
||||
NymeaCore *NymeaCore::instance()
|
||||
{
|
||||
if (!s_instance) {
|
||||
s_instance = new GuhCore();
|
||||
s_instance = new NymeaCore();
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
/*! Destructor of the \l{GuhCore}. */
|
||||
GuhCore::~GuhCore()
|
||||
/*! Destructor of the \l{NymeaCore}. */
|
||||
NymeaCore::~NymeaCore()
|
||||
{
|
||||
m_logger->logSystemEvent(m_timeManager->currentDateTime(), false);
|
||||
|
||||
|
|
@ -144,8 +144,8 @@ GuhCore::~GuhCore()
|
|||
delete m_cloudManager;
|
||||
}
|
||||
|
||||
/*! Destroyes the \l{GuhCore} instance. */
|
||||
void GuhCore::destroy()
|
||||
/*! Destroyes the \l{NymeaCore} instance. */
|
||||
void NymeaCore::destroy()
|
||||
{
|
||||
if (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. */
|
||||
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
|
||||
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. */
|
||||
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
|
||||
Device *device = m_deviceManager->findConfiguredDevice(deviceId);
|
||||
|
|
@ -324,7 +324,7 @@ DeviceManager::DeviceError GuhCore::removeConfiguredDevice(const DeviceId &devic
|
|||
|
||||
/*! Calls the metheod DeviceManager::executeAction(\a action).
|
||||
* \sa DeviceManager::executeAction(), */
|
||||
DeviceManager::DeviceError GuhCore::executeAction(const Action &action)
|
||||
DeviceManager::DeviceError NymeaCore::executeAction(const Action &action)
|
||||
{
|
||||
DeviceManager::DeviceError ret = m_deviceManager->executeAction(action);
|
||||
if (ret == DeviceManager::DeviceErrorNoError) {
|
||||
|
|
@ -338,7 +338,7 @@ DeviceManager::DeviceError GuhCore::executeAction(const Action &action)
|
|||
}
|
||||
|
||||
/*! Execute the given \a ruleActions. */
|
||||
void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions)
|
||||
void NymeaCore::executeRuleActions(const QList<RuleAction> ruleActions)
|
||||
{
|
||||
QList<Action> actions;
|
||||
foreach (const RuleAction &ruleAction, ruleActions) {
|
||||
|
|
@ -394,7 +394,7 @@ void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions)
|
|||
|
||||
/*! Calls the metheod RuleEngine::removeRule(\a id).
|
||||
* \sa RuleEngine, */
|
||||
RuleEngine::RuleError GuhCore::removeRule(const RuleId &id)
|
||||
RuleEngine::RuleError NymeaCore::removeRule(const RuleId &id)
|
||||
{
|
||||
RuleEngine::RuleError removeError = m_ruleEngine->removeRule(id);
|
||||
if (removeError == RuleEngine::RuleErrorNoError)
|
||||
|
|
@ -403,80 +403,80 @@ RuleEngine::RuleError GuhCore::removeRule(const RuleId &id)
|
|||
return removeError;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{GuhConfiguration} instance owned by GuhCore.*/
|
||||
GuhConfiguration *GuhCore::configuration() const
|
||||
/*! Returns a pointer to the \l{GuhConfiguration} instance owned by NymeaCore.*/
|
||||
GuhConfiguration *NymeaCore::configuration() const
|
||||
{
|
||||
return m_configuration;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/
|
||||
DeviceManager *GuhCore::deviceManager() const
|
||||
/*! Returns a pointer to the \l{DeviceManager} instance owned by NymeaCore.*/
|
||||
DeviceManager *NymeaCore::deviceManager() const
|
||||
{
|
||||
return m_deviceManager;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{RuleEngine} instance owned by GuhCore.*/
|
||||
RuleEngine *GuhCore::ruleEngine() const
|
||||
/*! Returns a pointer to the \l{RuleEngine} instance owned by NymeaCore.*/
|
||||
RuleEngine *NymeaCore::ruleEngine() const
|
||||
{
|
||||
return m_ruleEngine;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{TimeManager} instance owned by GuhCore.*/
|
||||
TimeManager *GuhCore::timeManager() const
|
||||
/*! Returns a pointer to the \l{TimeManager} instance owned by NymeaCore.*/
|
||||
TimeManager *NymeaCore::timeManager() const
|
||||
{
|
||||
return m_timeManager;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{ServerManager} instance owned by GuhCore. */
|
||||
ServerManager *GuhCore::serverManager() const
|
||||
/*! Returns a pointer to the \l{ServerManager} instance owned by NymeaCore. */
|
||||
ServerManager *NymeaCore::serverManager() const
|
||||
{
|
||||
return m_serverManager;
|
||||
}
|
||||
|
||||
/*! Returns the list of available system languages. */
|
||||
QStringList GuhCore::getAvailableLanguages()
|
||||
QStringList NymeaCore::getAvailableLanguages()
|
||||
{
|
||||
// TODO: parse available translation files
|
||||
return QStringList() << "en_US" << "de_DE";
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{BluetoothServer} instance owned by GuhCore. */
|
||||
BluetoothServer *GuhCore::bluetoothServer() const
|
||||
/*! Returns a pointer to the \l{BluetoothServer} instance owned by NymeaCore. */
|
||||
BluetoothServer *NymeaCore::bluetoothServer() const
|
||||
{
|
||||
return m_serverManager->bluetoothServer();
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{NetworkManager} instance owned by GuhCore. */
|
||||
NetworkManager *GuhCore::networkManager() const
|
||||
/*! Returns a pointer to the \l{NetworkManager} instance owned by NymeaCore. */
|
||||
NetworkManager *NymeaCore::networkManager() const
|
||||
{
|
||||
return m_networkManager;
|
||||
}
|
||||
|
||||
UserManager *GuhCore::userManager() const
|
||||
UserManager *NymeaCore::userManager() const
|
||||
{
|
||||
return m_userManager;
|
||||
}
|
||||
|
||||
CloudManager *GuhCore::cloudManager() const
|
||||
CloudManager *NymeaCore::cloudManager() const
|
||||
{
|
||||
return m_cloudManager;
|
||||
}
|
||||
|
||||
DebugServerHandler *GuhCore::debugServerHandler() const
|
||||
DebugServerHandler *NymeaCore::debugServerHandler() const
|
||||
{
|
||||
return m_debugServerHandler;
|
||||
}
|
||||
|
||||
|
||||
/*! Constructs GuhCore with the given \a parent. This is private.
|
||||
Use \l{GuhCore::instance()} to access the single instance.*/
|
||||
GuhCore::GuhCore(QObject *parent) :
|
||||
/*! Constructs NymeaCore with the given \a parent. This is private.
|
||||
Use \l{NymeaCore::instance()} to access the single instance.*/
|
||||
NymeaCore::NymeaCore(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
staticMetaObject.invokeMethod(this, "init", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void GuhCore::init() {
|
||||
void NymeaCore::init() {
|
||||
qCDebug(dcApplication()) << "Loading guh configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName();
|
||||
m_configuration = new GuhConfiguration(this);
|
||||
|
||||
|
|
@ -518,30 +518,30 @@ void GuhCore::init() {
|
|||
CloudNotifications *cloudNotifications = m_cloudManager->createNotificationsPlugin();
|
||||
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::serverNameChanged, m_cloudManager, &CloudManager::setDeviceName);
|
||||
connect(m_configuration, &GuhConfiguration::serverNameChanged, m_serverManager, &ServerManager::setServerName);
|
||||
|
||||
connect(m_deviceManager, &DeviceManager::pluginConfigChanged, this, &GuhCore::pluginConfigChanged);
|
||||
connect(m_deviceManager, &DeviceManager::eventTriggered, this, &GuhCore::gotEvent);
|
||||
connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &GuhCore::deviceStateChanged);
|
||||
connect(m_deviceManager, &DeviceManager::deviceAdded, this, &GuhCore::deviceAdded);
|
||||
connect(m_deviceManager, &DeviceManager::deviceChanged, this, &GuhCore::deviceChanged);
|
||||
connect(m_deviceManager, &DeviceManager::deviceRemoved, this, &GuhCore::deviceRemoved);
|
||||
connect(m_deviceManager, &DeviceManager::deviceDisappeared, this, &GuhCore::onDeviceDisappeared);
|
||||
connect(m_deviceManager, &DeviceManager::actionExecutionFinished, this, &GuhCore::actionExecutionFinished);
|
||||
connect(m_deviceManager, &DeviceManager::devicesDiscovered, this, &GuhCore::devicesDiscovered);
|
||||
connect(m_deviceManager, &DeviceManager::deviceSetupFinished, this, &GuhCore::deviceSetupFinished);
|
||||
connect(m_deviceManager, &DeviceManager::deviceReconfigurationFinished, this, &GuhCore::deviceReconfigurationFinished);
|
||||
connect(m_deviceManager, &DeviceManager::pairingFinished, this, &GuhCore::pairingFinished);
|
||||
connect(m_deviceManager, &DeviceManager::loaded, this, &GuhCore::deviceManagerLoaded);
|
||||
connect(m_deviceManager, &DeviceManager::pluginConfigChanged, this, &NymeaCore::pluginConfigChanged);
|
||||
connect(m_deviceManager, &DeviceManager::eventTriggered, this, &NymeaCore::gotEvent);
|
||||
connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &NymeaCore::deviceStateChanged);
|
||||
connect(m_deviceManager, &DeviceManager::deviceAdded, this, &NymeaCore::deviceAdded);
|
||||
connect(m_deviceManager, &DeviceManager::deviceChanged, this, &NymeaCore::deviceChanged);
|
||||
connect(m_deviceManager, &DeviceManager::deviceRemoved, this, &NymeaCore::deviceRemoved);
|
||||
connect(m_deviceManager, &DeviceManager::deviceDisappeared, this, &NymeaCore::onDeviceDisappeared);
|
||||
connect(m_deviceManager, &DeviceManager::actionExecutionFinished, this, &NymeaCore::actionExecutionFinished);
|
||||
connect(m_deviceManager, &DeviceManager::devicesDiscovered, this, &NymeaCore::devicesDiscovered);
|
||||
connect(m_deviceManager, &DeviceManager::deviceSetupFinished, this, &NymeaCore::deviceSetupFinished);
|
||||
connect(m_deviceManager, &DeviceManager::deviceReconfigurationFinished, this, &NymeaCore::deviceReconfigurationFinished);
|
||||
connect(m_deviceManager, &DeviceManager::pairingFinished, this, &NymeaCore::pairingFinished);
|
||||
connect(m_deviceManager, &DeviceManager::loaded, this, &NymeaCore::deviceManagerLoaded);
|
||||
|
||||
connect(m_ruleEngine, &RuleEngine::ruleAdded, this, &GuhCore::ruleAdded);
|
||||
connect(m_ruleEngine, &RuleEngine::ruleRemoved, this, &GuhCore::ruleRemoved);
|
||||
connect(m_ruleEngine, &RuleEngine::ruleConfigurationChanged, this, &GuhCore::ruleConfigurationChanged);
|
||||
connect(m_ruleEngine, &RuleEngine::ruleAdded, this, &NymeaCore::ruleAdded);
|
||||
connect(m_ruleEngine, &RuleEngine::ruleRemoved, this, &NymeaCore::ruleRemoved);
|
||||
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);
|
||||
|
||||
m_logger->logSystemEvent(m_timeManager->currentDateTime(), true);
|
||||
|
|
@ -554,7 +554,7 @@ void GuhCore::init() {
|
|||
|
||||
/*! 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.*/
|
||||
void GuhCore::gotEvent(const Event &event)
|
||||
void NymeaCore::gotEvent(const Event &event)
|
||||
{
|
||||
m_logger->logEvent(event);
|
||||
emit eventTriggered(event);
|
||||
|
|
@ -610,7 +610,7 @@ void GuhCore::gotEvent(const Event &event)
|
|||
executeRuleActions(actions);
|
||||
}
|
||||
|
||||
void GuhCore::onDateTimeChanged(const QDateTime &dateTime)
|
||||
void NymeaCore::onDateTimeChanged(const QDateTime &dateTime)
|
||||
{
|
||||
QList<RuleAction> actions;
|
||||
foreach (const Rule &rule, m_ruleEngine->evaluateTime(dateTime)) {
|
||||
|
|
@ -634,37 +634,37 @@ void GuhCore::onDateTimeChanged(const QDateTime &dateTime)
|
|||
executeRuleActions(actions);
|
||||
}
|
||||
|
||||
void GuhCore::onLocaleChanged()
|
||||
void NymeaCore::onLocaleChanged()
|
||||
{
|
||||
m_deviceManager->setLocale(m_configuration->locale());
|
||||
}
|
||||
|
||||
/*! Return the instance of the log engine */
|
||||
LogEngine* GuhCore::logEngine() const
|
||||
LogEngine* NymeaCore::logEngine() const
|
||||
{
|
||||
return m_logger;
|
||||
}
|
||||
|
||||
/*! Returns the pointer to the \l{JsonRPCServer} of this instance. */
|
||||
JsonRPCServer *GuhCore::jsonRPCServer() const
|
||||
JsonRPCServer *NymeaCore::jsonRPCServer() const
|
||||
{
|
||||
return m_serverManager->jsonServer();
|
||||
}
|
||||
|
||||
/*! Returns the pointer to the \l{RestServer} of this instance. */
|
||||
RestServer *GuhCore::restServer() const
|
||||
RestServer *NymeaCore::restServer() const
|
||||
{
|
||||
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);
|
||||
Action action = m_pendingActions.take(id);
|
||||
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);
|
||||
if (!device) {
|
||||
|
|
@ -718,7 +718,7 @@ void GuhCore::onDeviceDisappeared(const DeviceId &deviceId)
|
|||
}
|
||||
}
|
||||
|
||||
void GuhCore::deviceManagerLoaded()
|
||||
void NymeaCore::deviceManagerLoaded()
|
||||
{
|
||||
// Do some houskeeping...
|
||||
qCDebug(dcApplication()) << "Starting housekeeping...";
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef GUHCORE_H
|
||||
#define GUHCORE_H
|
||||
#ifndef NYMEACORE_H
|
||||
#define NYMEACORE_H
|
||||
|
||||
#include "rule.h"
|
||||
#include "types/event.h"
|
||||
|
|
@ -50,14 +50,14 @@ class JsonRPCServer;
|
|||
class LogEngine;
|
||||
class NetworkManager;
|
||||
|
||||
class GuhCore : public QObject
|
||||
class NymeaCore : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class GuhTestBase;
|
||||
|
||||
public:
|
||||
static GuhCore* instance();
|
||||
~GuhCore();
|
||||
static NymeaCore* instance();
|
||||
~NymeaCore();
|
||||
|
||||
void destroy();
|
||||
|
||||
|
|
@ -108,8 +108,8 @@ signals:
|
|||
void ruleConfigurationChanged(const Rule &rule);
|
||||
|
||||
private:
|
||||
explicit GuhCore(QObject *parent = 0);
|
||||
static GuhCore *s_instance;
|
||||
explicit NymeaCore(QObject *parent = 0);
|
||||
static NymeaCore *s_instance;
|
||||
|
||||
ServerManager *m_serverManager;
|
||||
DeviceManager *m_deviceManager;
|
||||
|
|
@ -138,4 +138,4 @@ private slots:
|
|||
|
||||
}
|
||||
|
||||
#endif // GUHCORE_H
|
||||
#endif // NYMEACORE_H
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include <QDBusConnection>
|
||||
#include <QDebug>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QDBusMessage>
|
||||
|
||||
namespace guhserver {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#define PUSHBUTTONDBUSSERVICE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusObjectPath>
|
||||
|
||||
#include "usermanager.h"
|
||||
#include "guhdbusservice.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "deviceclassesresource.h"
|
||||
#include "httprequest.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ namespace guhserver {
|
|||
DeviceClassesResource::DeviceClassesResource(QObject *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.
|
||||
|
|
@ -76,7 +76,7 @@ HttpReply *DeviceClassesResource::proccessRequest(const HttpRequest &request, co
|
|||
qCWarning(dcRest) << "Could not parse DeviceClassId:" << urlTokens.at(3);
|
||||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound);
|
||||
}
|
||||
m_deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
m_deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
if (!m_deviceClass.isValid()) {
|
||||
qCWarning(dcRest) << "DeviceClassId" << deviceClassId.toString() << "not found";
|
||||
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) << 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) {
|
||||
HttpReply *reply = createAsyncReply();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#include "httpreply.h"
|
||||
#include "httprequest.h"
|
||||
#include "jsonrpc/jsontypes.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ namespace guhserver {
|
|||
DevicesResource::DevicesResource(QObject *parent) :
|
||||
RestResource(parent)
|
||||
{
|
||||
connect(GuhCore::instance(), &GuhCore::actionExecuted, this, &DevicesResource::actionExecuted);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceSetupFinished, this, &DevicesResource::deviceSetupFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceReconfigurationFinished, this, &DevicesResource::deviceReconfigurationFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DevicesResource::pairingFinished);
|
||||
connect(NymeaCore::instance(), &NymeaCore::actionExecuted, this, &DevicesResource::actionExecuted);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceSetupFinished, this, &DevicesResource::deviceSetupFinished);
|
||||
connect(NymeaCore::instance(), &NymeaCore::deviceReconfigurationFinished, this, &DevicesResource::deviceReconfigurationFinished);
|
||||
connect(NymeaCore::instance(), &NymeaCore::pairingFinished, this, &DevicesResource::pairingFinished);
|
||||
}
|
||||
|
||||
/*! 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);
|
||||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceNotFound);
|
||||
}
|
||||
m_device = GuhCore::instance()->deviceManager()->findConfiguredDevice(deviceId);
|
||||
m_device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(deviceId);
|
||||
if (!m_device) {
|
||||
qCWarning(dcRest) << "Could find any device with DeviceId:" << urlTokens.at(3);
|
||||
return createDeviceErrorReply(HttpReply::NotFound, DeviceManager::DeviceErrorDeviceNotFound);
|
||||
|
|
@ -212,7 +212,7 @@ HttpReply *DevicesResource::proccessPostRequest(const HttpRequest &request, cons
|
|||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorActionTypeNotFound);
|
||||
}
|
||||
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()) {
|
||||
if (actionType.id() == actionTypeId) {
|
||||
found = true;
|
||||
|
|
@ -283,7 +283,7 @@ HttpReply *DevicesResource::removeDevice(Device *device, const QVariantMap ¶
|
|||
// global removePolicy has priority
|
||||
if (params.contains("removePolicy")) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ HttpReply *DevicesResource::removeDevice(Device *device, const QVariantMap ¶
|
|||
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 (!status.second.isEmpty()) {
|
||||
|
|
@ -337,7 +337,7 @@ HttpReply *DevicesResource::executeAction(Device *device, const ActionTypeId &ac
|
|||
Action action(actionTypeId, device->id());
|
||||
action.setParams(actionParams);
|
||||
|
||||
DeviceManager::DeviceError status = GuhCore::instance()->executeAction(action);
|
||||
DeviceManager::DeviceError status = NymeaCore::instance()->executeAction(action);
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
HttpReply *reply = createAsyncReply();
|
||||
m_asyncActionExecutions.insert(action.id(), reply);
|
||||
|
|
@ -370,10 +370,10 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
|
|||
DeviceManager::DeviceError status;
|
||||
if (deviceDescriptorId.isNull()) {
|
||||
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 {
|
||||
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) {
|
||||
HttpReply *reply = createAsyncReply();
|
||||
|
|
@ -385,7 +385,7 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
|
|||
if (status != DeviceManager::DeviceErrorNoError)
|
||||
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();
|
||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||
reply->setPayload(QJsonDocument::fromVariant(result).toJson());
|
||||
|
|
@ -400,7 +400,7 @@ HttpReply *DevicesResource::editDevice(const QByteArray &payload) const
|
|||
|
||||
QVariantMap params = verification.second.toMap();
|
||||
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)
|
||||
return createDeviceErrorReply(HttpReply::BadRequest, status);
|
||||
|
|
@ -417,7 +417,7 @@ HttpReply *DevicesResource::pairDevice(const QByteArray &payload) const
|
|||
QVariantMap params = verification.second.toMap();
|
||||
|
||||
DeviceClassId deviceClassId(params.value("deviceClassId").toString());
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
|
||||
if (deviceClassId.isNull()) {
|
||||
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();
|
||||
if (params.contains("deviceDescriptorId")) {
|
||||
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 {
|
||||
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)
|
||||
|
|
@ -461,7 +461,7 @@ HttpReply *DevicesResource::confirmPairDevice(const QByteArray &payload) const
|
|||
|
||||
PairingTransactionId pairingTransactionId = PairingTransactionId(params.value("pairingTransactionId").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) {
|
||||
HttpReply *reply = createAsyncReply();
|
||||
|
|
@ -490,10 +490,10 @@ HttpReply *DevicesResource::reconfigureDevice(Device *device, const QByteArray &
|
|||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||
if (deviceDescriptorId.isNull()) {
|
||||
qCDebug(dcRest) << "Reconfigure device with params:" << deviceParams;
|
||||
status = GuhCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceParams);
|
||||
status = NymeaCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceParams);
|
||||
} else {
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#include "logsresource.h"
|
||||
#include "httprequest.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "logging/logengine.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
|
@ -108,7 +108,7 @@ HttpReply *LogsResource::getLogEntries(const QString &filterString)
|
|||
LogFilter filter = JsonTypes::unpackLogFilter(filterMap);
|
||||
|
||||
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));
|
||||
}
|
||||
HttpReply *reply = createSuccessReply();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#include "pluginsresource.h"
|
||||
#include "httprequest.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ HttpReply *PluginsResource::getPlugin(const PluginId &pluginId) const
|
|||
{
|
||||
qCDebug(dcRest) << "Get plugin with id" << pluginId;
|
||||
HttpReply *reply = createSuccessReply();
|
||||
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) {
|
||||
foreach (DevicePlugin *plugin, NymeaCore::instance()->deviceManager()->plugins()) {
|
||||
if (plugin->pluginId() == pluginId) {
|
||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packPlugin(plugin)).toJson());
|
||||
|
|
@ -193,7 +193,7 @@ HttpReply *PluginsResource::setPluginConfiguration(const PluginId &pluginId, con
|
|||
QVariantList configuration = verification.second.toList();
|
||||
ParamList pluginParams = JsonTypes::unpackParams(configuration);
|
||||
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)
|
||||
return createDeviceErrorReply(HttpReply::BadRequest, result);
|
||||
|
|
@ -203,7 +203,7 @@ HttpReply *PluginsResource::setPluginConfiguration(const PluginId &pluginId, con
|
|||
|
||||
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) {
|
||||
return plugin;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@
|
|||
#include "httprequest.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "devicemanager.h"
|
||||
#include "guhcore.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QVariant>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
#include "loggingcategories.h"
|
||||
#include "httprequest.h"
|
||||
#include "httpreply.h"
|
||||
#include "guhcore.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QSslConfiguration>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "httprequest.h"
|
||||
#include "typeutils.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ HttpReply *RulesResource::proccessRequest(const HttpRequest &request, const QStr
|
|||
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();
|
||||
return createRuleErrorReply(HttpReply::NotFound, RuleEngine::RuleErrorRuleNotFound);
|
||||
}
|
||||
|
|
@ -199,10 +199,10 @@ HttpReply *RulesResource::getRules(const DeviceId &deviceId) const
|
|||
reply->setPayload(QJsonDocument::fromVariant(JsonTypes::packRuleDescriptions()).toJson());
|
||||
} else {
|
||||
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;
|
||||
foreach (const RuleId &ruleId, ruleIdsList) {
|
||||
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId);
|
||||
Rule rule = NymeaCore::instance()->ruleEngine()->findRule(ruleId);
|
||||
if (rule.isValid())
|
||||
ruleList.append(rule);
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ HttpReply *RulesResource::getRuleDetails(const RuleId &ruleId) const
|
|||
qCDebug(dcRest) << "Get rule details";
|
||||
|
||||
// Note: rule existence already checked
|
||||
Rule rule = GuhCore::instance()->ruleEngine()->findRule(ruleId);
|
||||
Rule rule = NymeaCore::instance()->ruleEngine()->findRule(ruleId);
|
||||
|
||||
HttpReply *reply = createSuccessReply();
|
||||
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();
|
||||
|
||||
RuleEngine::RuleError status = GuhCore::instance()->removeRule(ruleId);
|
||||
RuleEngine::RuleError status = NymeaCore::instance()->removeRule(ruleId);
|
||||
if (status != RuleEngine::RuleErrorNoError)
|
||||
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||
|
||||
|
|
@ -248,9 +248,9 @@ HttpReply *RulesResource::addRule(const QByteArray &payload) const
|
|||
Rule rule = JsonTypes::unpackRule(params);
|
||||
rule.setId(RuleId::createRuleId());
|
||||
|
||||
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->addRule(rule);
|
||||
RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->addRule(rule);
|
||||
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();
|
||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||
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();
|
||||
|
||||
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->enableRule(ruleId);
|
||||
RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->enableRule(ruleId);
|
||||
if (status != RuleEngine::RuleErrorNoError)
|
||||
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ HttpReply *RulesResource::disableRule(const RuleId &ruleId) const
|
|||
{
|
||||
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)
|
||||
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();
|
||||
|
||||
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeActions(ruleId);
|
||||
RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->executeActions(ruleId);
|
||||
if (status != RuleEngine::RuleErrorNoError)
|
||||
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();
|
||||
|
||||
RuleEngine::RuleError status = GuhCore::instance()->ruleEngine()->executeExitActions(ruleId);
|
||||
RuleEngine::RuleError status = NymeaCore::instance()->ruleEngine()->executeExitActions(ruleId);
|
||||
if (status != RuleEngine::RuleErrorNoError)
|
||||
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ HttpReply *RulesResource::editRule(const RuleId &ruleId, const QByteArray &paylo
|
|||
QVariantMap params = verification.second.toMap();
|
||||
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) {
|
||||
qCDebug(dcRest) << "Edit rule successfully finished";
|
||||
return createRuleErrorReply(HttpReply::Ok, status);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "vendorsresource.h"
|
||||
#include "httprequest.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ HttpReply *VendorsResource::getVendors() const
|
|||
HttpReply *reply = createSuccessReply();
|
||||
|
||||
QVariantList vendorsList;
|
||||
foreach (const Vendor &vendor, GuhCore::instance()->deviceManager()->supportedVendors()) {
|
||||
foreach (const Vendor &vendor, NymeaCore::instance()->deviceManager()->supportedVendors()) {
|
||||
vendorsList.append(JsonTypes::packVendor(vendor));
|
||||
}
|
||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||
|
|
@ -121,7 +121,7 @@ HttpReply *VendorsResource::getVendors() const
|
|||
HttpReply *VendorsResource::getVendor(const VendorId &vendorId) const
|
||||
{
|
||||
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) {
|
||||
HttpReply *reply = createSuccessReply();
|
||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
|
||||
|
||||
#include "ruleengine.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "time/calendaritem.h"
|
||||
#include "time/repeatingoption.h"
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
namespace guhserver {
|
||||
|
||||
/*! 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) :
|
||||
QObject(parent)
|
||||
|
|
@ -332,7 +332,7 @@ RuleEngine::~RuleEngine()
|
|||
*/
|
||||
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();
|
||||
|
||||
|
|
@ -471,14 +471,14 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
}
|
||||
if (eventDescriptor.type() == EventDescriptor::TypeDevice) {
|
||||
// check deviceId
|
||||
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(eventDescriptor.deviceId());
|
||||
Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(eventDescriptor.deviceId());
|
||||
if (!device) {
|
||||
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for eventTypeId" << eventDescriptor.eventTypeId();
|
||||
return RuleErrorDeviceNotFound;
|
||||
}
|
||||
|
||||
// Check eventTypeId for this deivce
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
bool eventTypeFound = false;
|
||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||
if (eventType.id() == eventDescriptor.eventTypeId()) {
|
||||
|
|
@ -491,7 +491,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
}
|
||||
} else {
|
||||
// Interface based event
|
||||
Interface iface = GuhCore::instance()->deviceManager()->supportedInterfaces().findByName(eventDescriptor.interface());
|
||||
Interface iface = NymeaCore::instance()->deviceManager()->supportedInterfaces().findByName(eventDescriptor.interface());
|
||||
if (!iface.isValid()) {
|
||||
qWarning(dcRuleEngine()) << "No such interface:" << eventDescriptor.interface();
|
||||
return RuleErrorInterfaceNotFound;
|
||||
|
|
@ -558,13 +558,13 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
return RuleErrorActionTypeNotFound;
|
||||
}
|
||||
if (action.type() == RuleAction::TypeDevice) {
|
||||
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(action.deviceId());
|
||||
Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(action.deviceId());
|
||||
if (!device) {
|
||||
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for action with actionTypeId" << action.actionTypeId();
|
||||
return RuleErrorDeviceNotFound;
|
||||
}
|
||||
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
if (!deviceClass.hasActionType(action.actionTypeId())) {
|
||||
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << action.actionTypeId();
|
||||
return RuleErrorActionTypeNotFound;
|
||||
|
|
@ -602,7 +602,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
||||
if (actionType.id() == action.actionTypeId()) {
|
||||
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) {
|
||||
qCWarning(dcRuleEngine) << "Cannot create rule. Got an invalid actionParam.";
|
||||
return RuleErrorInvalidRuleActionParameter;
|
||||
|
|
@ -619,7 +619,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
}
|
||||
|
||||
} else { // Is TypeInterface
|
||||
Interface iface = GuhCore::instance()->deviceManager()->supportedInterfaces().findByName(action.interface());
|
||||
Interface iface = NymeaCore::instance()->deviceManager()->supportedInterfaces().findByName(action.interface());
|
||||
if (!iface.isValid()) {
|
||||
qCWarning(dcRuleEngine()) << "Cannot create rule. No such interface:" << action.interface();
|
||||
return RuleError::RuleErrorInterfaceNotFound;
|
||||
|
|
@ -652,13 +652,13 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
}
|
||||
|
||||
if (ruleAction.type() == RuleAction::TypeDevice) {
|
||||
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(ruleAction.deviceId());
|
||||
Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(ruleAction.deviceId());
|
||||
if (!device) {
|
||||
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for exit action with actionTypeId" << ruleAction.actionTypeId();
|
||||
return RuleErrorDeviceNotFound;
|
||||
}
|
||||
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
if (!deviceClass.hasActionType(ruleAction.actionTypeId())) {
|
||||
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + device->name() + " has no action type:" << ruleAction.actionTypeId();
|
||||
return RuleErrorActionTypeNotFound;
|
||||
|
|
@ -668,7 +668,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
||||
if (actionType.id() == ruleAction.actionTypeId()) {
|
||||
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) {
|
||||
qCWarning(dcRuleEngine) << "Cannot create rule. Got an invalid exit actionParam.";
|
||||
return RuleErrorInvalidRuleActionParameter;
|
||||
|
|
@ -690,7 +690,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
|
|||
}
|
||||
|
||||
} else { // Is TypeInterface
|
||||
Interface iface = GuhCore::instance()->deviceManager()->supportedInterfaces().findByName(ruleAction.interface());
|
||||
Interface iface = NymeaCore::instance()->deviceManager()->supportedInterfaces().findByName(ruleAction.interface());
|
||||
if (!iface.isValid()) {
|
||||
qCWarning(dcRuleEngine()) << "Cannot create rule. No such interface:" << ruleAction.interface();
|
||||
return RuleError::RuleErrorInterfaceNotFound;
|
||||
|
|
@ -831,7 +831,7 @@ RuleEngine::RuleError RuleEngine::enableRule(const RuleId &ruleId)
|
|||
saveRule(rule);
|
||||
emit ruleConfigurationChanged(rule);
|
||||
|
||||
GuhCore::instance()->logEngine()->logRuleEnabledChanged(rule, true);
|
||||
NymeaCore::instance()->logEngine()->logRuleEnabledChanged(rule, true);
|
||||
qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "enabled.";
|
||||
|
||||
return RuleErrorNoError;
|
||||
|
|
@ -857,7 +857,7 @@ RuleEngine::RuleError RuleEngine::disableRule(const RuleId &ruleId)
|
|||
saveRule(rule);
|
||||
emit ruleConfigurationChanged(rule);
|
||||
|
||||
GuhCore::instance()->logEngine()->logRuleEnabledChanged(rule, false);
|
||||
NymeaCore::instance()->logEngine()->logRuleEnabledChanged(rule, false);
|
||||
qCDebug(dcRuleEngine()) << "Rule" << rule.name() << rule.id() << "disabled.";
|
||||
return RuleErrorNoError;
|
||||
}
|
||||
|
|
@ -892,8 +892,8 @@ RuleEngine::RuleError RuleEngine::executeActions(const RuleId &ruleId)
|
|||
}
|
||||
|
||||
qCDebug(dcRuleEngine) << "Executing rule actions of rule" << rule.name() << rule.id();
|
||||
GuhCore::instance()->logEngine()->logRuleActionsExecuted(rule);
|
||||
GuhCore::instance()->executeRuleActions(rule.actions());
|
||||
NymeaCore::instance()->logEngine()->logRuleActionsExecuted(rule);
|
||||
NymeaCore::instance()->executeRuleActions(rule.actions());
|
||||
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();
|
||||
GuhCore::instance()->logEngine()->logRuleExitActionsExecuted(rule);
|
||||
GuhCore::instance()->executeRuleActions(rule.exitActions());
|
||||
NymeaCore::instance()->logEngine()->logRuleExitActionsExecuted(rule);
|
||||
NymeaCore::instance()->executeRuleActions(rule.exitActions());
|
||||
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 (eventDescriptor.type() == EventDescriptor::TypeInterface) {
|
||||
DeviceClass dc = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
DeviceClass dc = NymeaCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
if (!dc.interfaces().contains(eventDescriptor.interface())) {
|
||||
// DeviceClass for this event doesn't implement the interface for this eventDescriptor
|
||||
continue;
|
||||
|
|
@ -1173,7 +1173,7 @@ bool RuleEngine::checkEventDescriptors(const QList<EventDescriptor> eventDescrip
|
|||
|
||||
QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId, const ParamTypeId ¶mTypeId)
|
||||
{
|
||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||
foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices()) {
|
||||
foreach (const ActionType &actionType, deviceClass.actionTypes()) {
|
||||
if (actionType.id() == actionTypeId) {
|
||||
foreach (const ParamType ¶mType, actionType.paramTypes()) {
|
||||
|
|
@ -1190,7 +1190,7 @@ QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId,
|
|||
|
||||
QVariant::Type RuleEngine::getEventParamType(const EventTypeId &eventTypeId, const ParamTypeId ¶mTypeId)
|
||||
{
|
||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||
foreach (const DeviceClass &deviceClass, NymeaCore::instance()->deviceManager()->supportedDevices()) {
|
||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||
if (eventType.id() == eventTypeId) {
|
||||
foreach (const ParamType ¶mType, eventType.paramTypes()) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include "servermanager.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "certificategenerator.h"
|
||||
|
||||
#include <QSslCertificate>
|
||||
|
|
@ -155,7 +155,7 @@ MockTcpServer *ServerManager::mockTcpServer() const
|
|||
|
||||
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);
|
||||
if (server) {
|
||||
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)
|
||||
{
|
||||
WebSocketServer *server = m_webSocketServers.value(id);
|
||||
ServerConfiguration config = GuhCore::instance()->configuration()->webSocketServerConfigurations().value(id);
|
||||
ServerConfiguration config = NymeaCore::instance()->configuration()->webSocketServerConfigurations().value(id);
|
||||
if (server) {
|
||||
qDebug(dcConnection) << "Restarting WebSocket server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
||||
server->stopServer();
|
||||
|
|
@ -213,7 +213,7 @@ void ServerManager::webSocketServerConfigurationRemoved(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);
|
||||
if (server) {
|
||||
qDebug(dcConnection) << "Restarting Web server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
#include "stateevaluator.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "nymeasettings.h"
|
||||
|
|
@ -100,7 +100,7 @@ void StateEvaluator::setOperatorType(Types::StateOperator operatorType)
|
|||
bool StateEvaluator::evaluate() const
|
||||
{
|
||||
if (m_stateDescriptor.isValid()) {
|
||||
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
||||
Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
||||
if (!device) {
|
||||
qCWarning(dcRuleEngine) << "Device not existing!";
|
||||
return false;
|
||||
|
|
@ -220,7 +220,7 @@ StateEvaluator StateEvaluator::loadFromSettings(NymeaSettings &settings, const Q
|
|||
bool StateEvaluator::isValid() const
|
||||
{
|
||||
if (m_stateDescriptor.isValid()) {
|
||||
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
||||
Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId());
|
||||
if (!device) {
|
||||
qCWarning(dcRuleEngine) << "State evaluator device does not exist!";
|
||||
return false;
|
||||
|
|
@ -231,7 +231,7 @@ bool StateEvaluator::isValid() const
|
|||
return false;
|
||||
}
|
||||
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
foreach (const StateType &stateType, deviceClass.stateTypes()) {
|
||||
if (stateType.id() == m_stateDescriptor.stateTypeId()) {
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include "tcpserver.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
|
@ -135,8 +135,8 @@ void TcpServer::resetAvahiService()
|
|||
txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION);
|
||||
txt.insert("serverVersion", NYMEA_VERSION_STRING);
|
||||
txt.insert("manufacturer", "guh GmbH");
|
||||
txt.insert("uuid", GuhCore::instance()->configuration()->serverUuid().toString());
|
||||
txt.insert("name", GuhCore::instance()->configuration()->serverName());
|
||||
txt.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
|
||||
txt.insert("name", NymeaCore::instance()->configuration()->serverName());
|
||||
txt.insert("sslEnabled", configuration().sslEnabled ? "true" : "false");
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
#include "usermanager.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "pushbuttondbusservice.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QUuid>
|
||||
#include <QCryptographicHash>
|
||||
|
|
@ -141,7 +141,7 @@ QByteArray UserManager::authenticate(const QString &username, const QString &pas
|
|||
.arg(QUuid::createUuid().toString())
|
||||
.arg(username)
|
||||
.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);
|
||||
|
||||
m_db.exec(storeTokenQuery);
|
||||
|
|
@ -297,7 +297,7 @@ void UserManager::onPushButtonPressed()
|
|||
.arg(QUuid::createUuid().toString())
|
||||
.arg("")
|
||||
.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);
|
||||
|
||||
m_db.exec(storeTokenQuery);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
#include "webserver.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "httpreply.h"
|
||||
#include "httprequest.h"
|
||||
#include "rest/restresource.h"
|
||||
|
|
@ -368,7 +368,7 @@ void WebServer::readClient()
|
|||
if (request.url().path().startsWith("/debug")) {
|
||||
|
||||
// Check if debug server is enabled
|
||||
if (GuhCore::instance()->configuration()->debugServerEnabled()) {
|
||||
if (NymeaCore::instance()->configuration()->debugServerEnabled()) {
|
||||
// Verify methods
|
||||
if (request.method() != HttpRequest::Get && request.method() != HttpRequest::Options) {
|
||||
HttpReply *reply = RestResource::createErrorReply(HttpReply::MethodNotAllowed);
|
||||
|
|
@ -379,7 +379,7 @@ void WebServer::readClient()
|
|||
return;
|
||||
}
|
||||
|
||||
HttpReply *reply = GuhCore::instance()->debugServerHandler()->processDebugRequest(request.url().path());
|
||||
HttpReply *reply = NymeaCore::instance()->debugServerHandler()->processDebugRequest(request.url().path());
|
||||
reply->setClientId(clientId);
|
||||
sendHttpReply(reply);
|
||||
reply->deleteLater();
|
||||
|
|
@ -532,8 +532,8 @@ void WebServer::resetAvahiService()
|
|||
txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION);
|
||||
txt.insert("serverVersion", NYMEA_VERSION_STRING);
|
||||
txt.insert("manufacturer", "guh GmbH");
|
||||
txt.insert("uuid", GuhCore::instance()->configuration()->serverUuid().toString());
|
||||
txt.insert("name", GuhCore::instance()->configuration()->serverName());
|
||||
txt.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
|
||||
txt.insert("name", NymeaCore::instance()->configuration()->serverName());
|
||||
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)) {
|
||||
|
|
@ -597,7 +597,7 @@ bool WebServer::stopServer()
|
|||
|
||||
QByteArray WebServer::createServerXmlDocument(QHostAddress address)
|
||||
{
|
||||
QByteArray uuid = GuhCore::instance()->configuration()->serverUuid().toByteArray();
|
||||
QByteArray uuid = NymeaCore::instance()->configuration()->serverUuid().toByteArray();
|
||||
|
||||
QByteArray data;
|
||||
QXmlStreamWriter writer(&data);
|
||||
|
|
@ -619,7 +619,7 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
|
|||
|
||||
ServerConfiguration websocketConfiguration;
|
||||
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 (!webSocketServerFound) {
|
||||
websocketConfiguration = config;
|
||||
|
|
@ -640,7 +640,7 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
|
|||
|
||||
ServerConfiguration tcpServerConfiguration;
|
||||
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 (!tcpServerFound) {
|
||||
tcpServerConfiguration = config;
|
||||
|
|
@ -663,7 +663,7 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
|
|||
|
||||
writer.writeStartElement("device");
|
||||
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("manufacturerURL", "http://guh.io");
|
||||
writer.writeTextElement("modelDescription", "IoT server");
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
*/
|
||||
|
||||
#include "nymeasettings.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "websocketserver.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
|
|
@ -116,8 +116,8 @@ QHash<QString, QString> WebSocketServer::createTxtRecord()
|
|||
txt.insert("jsonrpcVersion", JSON_PROTOCOL_VERSION);
|
||||
txt.insert("serverVersion", NYMEA_VERSION_STRING);
|
||||
txt.insert("manufacturer", "guh GmbH");
|
||||
txt.insert("uuid", GuhCore::instance()->configuration()->serverUuid().toString());
|
||||
txt.insert("name", GuhCore::instance()->configuration()->serverName());
|
||||
txt.insert("uuid", NymeaCore::instance()->configuration()->serverUuid().toString());
|
||||
txt.insert("name", NymeaCore::instance()->configuration()->serverName());
|
||||
txt.insert("sslEnabled", configuration().sslEnabled ? "true" : "false");
|
||||
return txt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@
|
|||
|
||||
/*! \fn void DeviceManager::eventTriggered(const Event &event)
|
||||
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
|
||||
or similar, but you should never directly react to this in a \l{DevicePlugin}.
|
||||
*/
|
||||
|
|
@ -177,8 +177,8 @@
|
|||
#include <QStandardPaths>
|
||||
#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}.
|
||||
* Use \c guhserver::GuhCore::instance()->deviceManager() instead to access the DeviceManager. */
|
||||
/*! 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::NymeaCore::instance()->deviceManager() instead to access the DeviceManager. */
|
||||
DeviceManager::DeviceManager(HardwareManager *hardwareManager, const QLocale &locale, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_hardwareManager(hardwareManager),
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "guhapplication.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
|
|
@ -190,7 +190,7 @@ static void catchUnixSignals(const std::vector<int>& quitSignals, const std::vec
|
|||
qCDebug(dcApplication) << "=====================================";
|
||||
|
||||
s_aboutToShutdown = true;
|
||||
GuhCore::instance()->destroy();
|
||||
NymeaCore::instance()->destroy();
|
||||
|
||||
if (s_multipleShutdownDetected)
|
||||
qCDebug(dcApplication) << "Ok, ok, I'm done! :)";
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include <QDir>
|
||||
|
||||
#include "guhservice.h"
|
||||
#include "nymeacore.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
|
|
@ -74,7 +75,7 @@ void GuhService::start()
|
|||
|
||||
qCDebug(dcApplication) << "nymead" << NYMEA_VERSION_STRING << "started as daemon.";
|
||||
qCDebug(dcApplication) << "=====================================";
|
||||
GuhCore::instance();
|
||||
NymeaCore::instance();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@
|
|||
#include <QCoreApplication>
|
||||
#include "qtservice/qtservice.h"
|
||||
|
||||
#include "guhcore.h"
|
||||
|
||||
namespace guhserver {
|
||||
|
||||
class GuhService : public QtService<QCoreApplication>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "stdio.h"
|
||||
#include "unistd.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "guhservice.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "guhdbusservice.h"
|
||||
|
|
@ -277,7 +277,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
// create core instance
|
||||
GuhCore::instance();
|
||||
NymeaCore::instance();
|
||||
int ret = application.exec();
|
||||
if (s_logFile.isOpen()) {
|
||||
s_logFile.close();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "nymeacore.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QCoreApplication>
|
||||
|
|
@ -342,7 +342,7 @@ void TestConfigurations::testDebugServerConfiguration()
|
|||
QVERIFY2(basicConfigurationNotificationMap.value("debugServerEnabled").toBool() == newValue, "Notification does not contain the new debugServerEnabled");
|
||||
|
||||
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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -355,7 +355,7 @@ void TestConfigurations::testDebugServerConfiguration()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
|
||||
// Webserver request
|
||||
QNetworkAccessManager nam;
|
||||
|
|
@ -397,7 +397,7 @@ void TestConfigurations::testDebugServerConfiguration()
|
|||
QCOMPARE(statusCode, 404);
|
||||
reply->deleteLater();
|
||||
|
||||
GuhCore::instance()->configuration()->removeWebServerConfiguration(config.id);
|
||||
NymeaCore::instance()->configuration()->removeWebServerConfiguration(config.id);
|
||||
|
||||
disableNotifications();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "nymeasettings.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
|
||||
|
||||
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");
|
||||
Device *device = devices.first();
|
||||
|
||||
|
|
@ -1236,15 +1236,15 @@ void TestDevices::removeAutoDevice()
|
|||
spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
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
|
||||
|
||||
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");
|
||||
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
|
||||
spy.clear();
|
||||
|
|
@ -1256,7 +1256,7 @@ void TestDevices::removeAutoDevice()
|
|||
QCOMPARE(spy.count(), 1);
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
|
|
@ -50,11 +50,11 @@ private slots:
|
|||
|
||||
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");
|
||||
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
|
||||
QNetworkAccessManager nam;
|
||||
|
|
@ -79,11 +79,11 @@ void TestEvents::triggerEvent()
|
|||
|
||||
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");
|
||||
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
|
||||
QNetworkAccessManager nam;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "guhtestbase.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "devicemanager.h"
|
||||
#include "loggingcategories.h"
|
||||
|
|
@ -178,21 +178,21 @@ void GuhTestBase::initTestCase()
|
|||
QLoggingCategory::installFilter(loggingCategoryFilter);
|
||||
|
||||
// Start the server
|
||||
GuhCore::instance();
|
||||
NymeaCore::instance();
|
||||
|
||||
// Wait unitl the server is initialized
|
||||
QSignalSpy coreInitializedSpy(GuhCore::instance(), SIGNAL(initialized()));
|
||||
QSignalSpy coreInitializedSpy(NymeaCore::instance(), SIGNAL(initialized()));
|
||||
coreInitializedSpy.wait();
|
||||
|
||||
// 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.wait());
|
||||
|
||||
// Yes, we're intentionally mixing upper/lower case email here... username should not be case sensitive
|
||||
GuhCore::instance()->userManager()->removeUser("dummy@guh.io");
|
||||
GuhCore::instance()->userManager()->createUser("dummy@guh.io", "DummyPW1!");
|
||||
m_apiToken = GuhCore::instance()->userManager()->authenticate("Dummy@guh.io", "DummyPW1!", "testcase");
|
||||
NymeaCore::instance()->userManager()->removeUser("dummy@guh.io");
|
||||
NymeaCore::instance()->userManager()->createUser("dummy@guh.io", "DummyPW1!");
|
||||
m_apiToken = NymeaCore::instance()->userManager()->authenticate("Dummy@guh.io", "DummyPW1!", "testcase");
|
||||
|
||||
if (MockTcpServer::servers().isEmpty()) {
|
||||
qWarning() << "no mock tcp server found";
|
||||
|
|
@ -216,13 +216,13 @@ void GuhTestBase::initTestCase()
|
|||
|
||||
void GuhTestBase::cleanupTestCase()
|
||||
{
|
||||
GuhCore::instance()->destroy();
|
||||
NymeaCore::instance()->destroy();
|
||||
}
|
||||
|
||||
void GuhTestBase::cleanup()
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -497,10 +497,10 @@ bool GuhTestBase::disableNotifications()
|
|||
void GuhTestBase::restartServer()
|
||||
{
|
||||
// Destroy and recreate the core instance...
|
||||
GuhCore::instance()->destroy();
|
||||
QSignalSpy coreSpy(GuhCore::instance(), SIGNAL(initialized()));
|
||||
NymeaCore::instance()->destroy();
|
||||
QSignalSpy coreSpy(NymeaCore::instance(), SIGNAL(initialized()));
|
||||
coreSpy.wait();
|
||||
QSignalSpy spy(GuhCore::instance()->deviceManager(), SIGNAL(loaded()));
|
||||
QSignalSpy spy(NymeaCore::instance()->deviceManager(), SIGNAL(loaded()));
|
||||
spy.wait();
|
||||
m_mockTcpServer = MockTcpServer::servers().first();
|
||||
m_mockTcpServer->clientConnected(m_clientId);
|
||||
|
|
@ -508,7 +508,7 @@ void GuhTestBase::restartServer()
|
|||
|
||||
void GuhTestBase::clearLoggingDatabase()
|
||||
{
|
||||
GuhCore::instance()->logEngine()->clearDatabase();
|
||||
NymeaCore::instance()->logEngine()->clearDatabase();
|
||||
}
|
||||
|
||||
void GuhTestBase::createMockDevice()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "../../utils/pushbuttonagent.h"
|
||||
|
|
@ -166,10 +166,10 @@ void TestJSONRPC::testHandshake()
|
|||
|
||||
void TestJSONRPC::testInitialSetup()
|
||||
{
|
||||
foreach (const QString &user, GuhCore::instance()->userManager()->users()) {
|
||||
GuhCore::instance()->userManager()->removeUser(user);
|
||||
foreach (const QString &user, NymeaCore::instance()->userManager()->users()) {
|
||||
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)));
|
||||
QVERIFY(spy.isValid());
|
||||
|
|
@ -223,7 +223,7 @@ void TestJSONRPC::testInitialSetup()
|
|||
response = jsonDoc.toVariant().toMap();
|
||||
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(GuhCore::instance()->userManager()->users().count(), 0);
|
||||
QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 0);
|
||||
|
||||
// or when giving a bad password
|
||||
spy.clear();
|
||||
|
|
@ -236,7 +236,7 @@ void TestJSONRPC::testInitialSetup()
|
|||
response = jsonDoc.toVariant().toMap();
|
||||
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(GuhCore::instance()->userManager()->users().count(), 0);
|
||||
QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 0);
|
||||
|
||||
// Now lets play by the rules (with an uppercase email)
|
||||
spy.clear();
|
||||
|
|
@ -249,7 +249,7 @@ void TestJSONRPC::testInitialSetup()
|
|||
response = jsonDoc.toVariant().toMap();
|
||||
qWarning() << "Calling CreateUser on uninitialized instance:" << response.value("status").toString() << response.value("error").toString();
|
||||
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
|
||||
spy.clear();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "logging/logentry.h"
|
||||
|
|
@ -202,7 +202,7 @@ void TestLogging::invalidFilter()
|
|||
|
||||
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");
|
||||
Device *device = devices.first();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "webserver.h"
|
||||
|
|
@ -68,7 +68,7 @@ void TestRestDeviceClasses::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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -80,7 +80,7 @@ void TestRestDeviceClasses::initTestCase()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "webserver.h"
|
||||
|
|
@ -77,7 +77,7 @@ private slots:
|
|||
void TestRestDevices::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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -89,7 +89,7 @@ void TestRestDevices::initTestCase()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
|
@ -505,7 +505,7 @@ void TestRestDevices::executeAction()
|
|||
|
||||
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");
|
||||
Device *device = devices.first();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ void TestRestLogging::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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -72,7 +72,7 @@ void TestRestLogging::initTestCase()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ void TestRestLogging::invalidFilterJson()
|
|||
|
||||
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");
|
||||
Device *device = devices.first();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "webserver.h"
|
||||
|
|
@ -61,7 +61,7 @@ void TestRestPlugins::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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -73,7 +73,7 @@ void TestRestPlugins::initTestCase()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "webserver.h"
|
||||
|
|
@ -82,7 +82,7 @@ void TestRestRules::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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -94,7 +94,7 @@ void TestRestRules::initTestCase()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "webserver.h"
|
||||
|
|
@ -56,7 +56,7 @@ void TestRestVendors::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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -68,7 +68,7 @@ void TestRestVendors::initTestCase()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "nymeasettings.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ void TestStates::getStateTypes()
|
|||
|
||||
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");
|
||||
Device *device = devices.first();
|
||||
|
||||
|
|
@ -88,12 +88,12 @@ void TestStates::getStateValue()
|
|||
|
||||
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(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();
|
||||
QNetworkAccessManager nam;
|
||||
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "time/timemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
|
@ -144,15 +144,15 @@ void TestTimeManager::changeTimeZone()
|
|||
QFETCH(QByteArray, timeZoneId);
|
||||
QFETCH(bool, valid);
|
||||
|
||||
QTimeZone currentTimeZone(GuhCore::instance()->timeManager()->timeZone());
|
||||
QTimeZone currentTimeZone(NymeaCore::instance()->timeManager()->timeZone());
|
||||
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 offsetNew = newTimeZone.offsetFromUtc(newDateTime);
|
||||
|
|
@ -430,21 +430,21 @@ void TestTimeManager::testCalendarDateTime()
|
|||
|
||||
QDateTime oneMinuteBeforeEvent = dateTime.addSecs(-60);
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
|
||||
NymeaCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// REMOVE rule
|
||||
|
|
@ -498,34 +498,34 @@ void TestTimeManager::testCalendarItemHourly()
|
|||
params.insert("ruleId", ruleId);
|
||||
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));
|
||||
|
||||
// Check if should be enabled always
|
||||
if (duration == 60) {
|
||||
GuhCore::instance()->timeManager()->setTime(future);
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
// Should be active since adding
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
} else {
|
||||
// check the next 24 hours in 8h steps
|
||||
for (int i = 0; i < 24; i+=8) {
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(future);
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
verifyRuleNotExecuted();
|
||||
// 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);
|
||||
cleanupMockHistory();
|
||||
// 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();
|
||||
// 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);
|
||||
cleanupMockHistory();
|
||||
// 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();
|
||||
|
||||
// 'i' hours "Back to the future"
|
||||
|
|
@ -587,35 +587,35 @@ void TestTimeManager::testCalendarItemDaily()
|
|||
verifyRuleError(response);
|
||||
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
|
||||
QDateTime future = QDateTime(currentDateTime.date(), QTime::fromString(time, "hh:mm").addSecs(-60));
|
||||
|
||||
// if always true
|
||||
if (time == "08:00") {
|
||||
GuhCore::instance()->timeManager()->setTime(future);
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
// Should be active since adding
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
} else {
|
||||
// check the next 7 days
|
||||
for (int i = 0; i < 7; i++) {
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(future);
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
|
||||
verifyRuleNotExecuted();
|
||||
// One day "Back to the future"
|
||||
future = future.addDays(1);
|
||||
|
|
@ -691,7 +691,7 @@ void TestTimeManager::testCalendarItemWeekly()
|
|||
verifyRuleError(response);
|
||||
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
|
||||
QDateTime future = QDateTime(currentDateTime.date(), QTime::fromString(time, "hh:mm").addSecs(-60));
|
||||
|
|
@ -704,7 +704,7 @@ void TestTimeManager::testCalendarItemWeekly()
|
|||
|
||||
// the whole week active (always)
|
||||
if (repeatingOption.isEmpty()) {
|
||||
GuhCore::instance()->timeManager()->setTime(future);
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
// Should be active since adding
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
} else {
|
||||
|
|
@ -713,32 +713,32 @@ void TestTimeManager::testCalendarItemWeekly()
|
|||
for (int i = 0; i < 7; i++) {
|
||||
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(future);
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// Check if today is a weekday
|
||||
if (weekDays.contains(future.date().dayOfWeek())) {
|
||||
// should trigger today
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// One day "Back to the future"
|
||||
future = future.addDays(1);
|
||||
} else {
|
||||
// should not trigger today
|
||||
GuhCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// One day "Back to the future"
|
||||
|
|
@ -756,24 +756,24 @@ void TestTimeManager::testCalendarItemWeekly()
|
|||
}
|
||||
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(startDate);
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate);
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(startDate.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
|
||||
// still active
|
||||
GuhCore::instance()->timeManager()->setTime(startDate.addDays(1));
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(1));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// still active
|
||||
GuhCore::instance()->timeManager()->setTime(startDate.addDays(2));
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(2));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(startDate.addDays(2).addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(2).addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
}
|
||||
}
|
||||
|
|
@ -846,7 +846,7 @@ void TestTimeManager::testCalendarItemMonthly()
|
|||
verifyRuleError(response);
|
||||
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();
|
||||
QList<int> monthDays;
|
||||
|
|
@ -866,25 +866,25 @@ void TestTimeManager::testCalendarItemMonthly()
|
|||
if (monthDays.contains(dateTime.date().day())) {
|
||||
// should trigger today
|
||||
// not active yet
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(6* 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(6* 60));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(11 * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(11 * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(12 * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(12 * 60));
|
||||
verifyRuleNotExecuted();
|
||||
} else {
|
||||
// should not trigger today
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
verifyRuleNotExecuted();
|
||||
}
|
||||
}
|
||||
|
|
@ -900,20 +900,20 @@ void TestTimeManager::testCalendarItemMonthly()
|
|||
}
|
||||
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(startDate);
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate);
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(startDate.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
|
||||
// still active
|
||||
GuhCore::instance()->timeManager()->setTime(startDate.addDays(3));
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(3));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(startDate.addDays(3).addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(3).addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
}
|
||||
|
||||
|
|
@ -986,23 +986,23 @@ void TestTimeManager::testCalendarYearlyDateTime()
|
|||
|
||||
QDateTime oneMinuteBeforeEvent = dateTime.addSecs(-60);
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
|
||||
NymeaCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
cleanupMockHistory();
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
|
||||
|
|
@ -1010,23 +1010,23 @@ void TestTimeManager::testCalendarYearlyDateTime()
|
|||
oneMinuteBeforeEvent = oneMinuteBeforeEvent.addYears(1);
|
||||
dateTime = dateTime.addYears(1);
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
|
||||
NymeaCore::instance()->timeManager()->setTime(oneMinuteBeforeEvent);
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
cleanupMockHistory();
|
||||
|
||||
// inactive unchanged
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
cleanupMockHistory();
|
||||
|
|
@ -1100,7 +1100,7 @@ void TestTimeManager::testCalendarItemStates_data()
|
|||
ruleMap.insert("exitActions", QVariantList() << exitAction);
|
||||
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);
|
||||
verifyRuleError(response);
|
||||
|
|
@ -1134,7 +1134,7 @@ void TestTimeManager::testCalendarItemStates()
|
|||
QFETCH(bool, trigger);
|
||||
QFETCH(bool, active);
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
setBoolState(boolValue);
|
||||
setIntState(intValue);
|
||||
|
||||
|
|
@ -1178,7 +1178,7 @@ void TestTimeManager::testCalendarItemEvent_data()
|
|||
ruleMap.insert("eventDescriptors", QVariantList() << eventDescriptor);
|
||||
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);
|
||||
verifyRuleError(response);
|
||||
|
|
@ -1205,7 +1205,7 @@ void TestTimeManager::testCalendarItemEvent()
|
|||
QFETCH(QDateTime, dateTime);
|
||||
QFETCH(bool, trigger);
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
|
||||
// Trigger event
|
||||
triggerMockEvent1();
|
||||
|
|
@ -1222,7 +1222,7 @@ void TestTimeManager::testCalendarItemStatesEvent_data()
|
|||
{
|
||||
initTimeManager();
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59)));
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59)));
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap action;
|
||||
|
|
@ -1278,7 +1278,7 @@ void TestTimeManager::testCalendarItemStatesEvent()
|
|||
QFETCH(bool, boolValue);
|
||||
QFETCH(bool, trigger);
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
setBoolState(boolValue);
|
||||
|
||||
// Trigger event
|
||||
|
|
@ -1324,17 +1324,17 @@ void TestTimeManager::testEventItemDateTime()
|
|||
RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString());
|
||||
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-120));
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-120));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
cleanupMockHistory();
|
||||
|
|
@ -1383,7 +1383,7 @@ void TestTimeManager::testEventItemHourly()
|
|||
params.insert("ruleId", ruleId);
|
||||
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));
|
||||
|
||||
// check the next 24 hours in 8h steps
|
||||
|
|
@ -1392,14 +1392,14 @@ void TestTimeManager::testEventItemHourly()
|
|||
beforeEventDateTime = beforeEventDateTime.addSecs(i * 60 * 60);
|
||||
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
verifyRuleNotExecuted();
|
||||
cleanupMockHistory();
|
||||
}
|
||||
|
|
@ -1456,20 +1456,20 @@ void TestTimeManager::testEventItemDaily()
|
|||
params.insert("ruleId", ruleId);
|
||||
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));
|
||||
|
||||
// check the next 2 days
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// Back to the future (1 day)
|
||||
|
|
@ -1525,7 +1525,7 @@ void TestTimeManager::testEventItemWeekly()
|
|||
params.insert("ruleId", ruleId);
|
||||
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));
|
||||
|
||||
QList<int> allowedDays;
|
||||
|
|
@ -1538,19 +1538,19 @@ void TestTimeManager::testEventItemWeekly()
|
|||
// check if today is one of the weekdays
|
||||
if (allowedDays.contains(beforeEventDateTime.date().dayOfWeek())) {
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
} else {
|
||||
// not triggering on this weekday
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleNotExecuted();
|
||||
}
|
||||
|
||||
|
|
@ -1607,7 +1607,7 @@ void TestTimeManager::testEventItemMonthly()
|
|||
params.insert("ruleId", ruleId);
|
||||
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));
|
||||
|
||||
QList<int> allowedDays;
|
||||
|
|
@ -1620,18 +1620,18 @@ void TestTimeManager::testEventItemMonthly()
|
|||
// check if today is one of the month days
|
||||
if (allowedDays.contains(beforeEventDateTime.date().day())) {
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime);
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
verifyRuleNotExecuted();
|
||||
} else {
|
||||
// not triggering on this weekday
|
||||
GuhCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleNotExecuted();
|
||||
}
|
||||
|
||||
|
|
@ -1686,28 +1686,28 @@ void TestTimeManager::testEventItemYearly()
|
|||
// Tick now, one minute before, on time, one minute after
|
||||
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-60));
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// Tick next year, one minute bofore, on time, one minute after
|
||||
QDateTime nextYear = dateTime.addYears(1);
|
||||
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(nextYear.addSecs(-60));
|
||||
NymeaCore::instance()->timeManager()->setTime(nextYear.addSecs(-60));
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(nextYear);
|
||||
NymeaCore::instance()->timeManager()->setTime(nextYear);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(nextYear.addSecs(60));
|
||||
NymeaCore::instance()->timeManager()->setTime(nextYear.addSecs(60));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
cleanupMockHistory();
|
||||
|
|
@ -1724,7 +1724,7 @@ void TestTimeManager::testEventItemStates_data()
|
|||
{
|
||||
initTimeManager();
|
||||
|
||||
GuhCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59)));
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(7,59)));
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap action;
|
||||
|
|
@ -1789,7 +1789,7 @@ void TestTimeManager::testEventItemStates()
|
|||
setBoolState(boolValue);
|
||||
|
||||
// Set time
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
|
||||
if (trigger) {
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
|
|
@ -1826,16 +1826,16 @@ void TestTimeManager::testEnableDisableTimeRule()
|
|||
RuleId ruleId = RuleId(response.toMap().value("params").toMap().value("ruleId").toString());
|
||||
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-2));
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-2));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(1));
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(2));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(1));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(2));
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
|
||||
|
|
@ -1846,8 +1846,8 @@ void TestTimeManager::testEnableDisableTimeRule()
|
|||
verifyRuleError(response);
|
||||
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleNotExecuted();
|
||||
|
||||
// Now ENABLE the rule again
|
||||
|
|
@ -1856,8 +1856,8 @@ void TestTimeManager::testEnableDisableTimeRule()
|
|||
verifyRuleError(response);
|
||||
|
||||
// trigger
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
|
||||
GuhCore::instance()->timeManager()->setTime(dateTime);
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
cleanupMockHistory();
|
||||
|
||||
|
|
@ -1873,9 +1873,9 @@ void TestTimeManager::initTimeManager()
|
|||
cleanupMockHistory();
|
||||
removeAllRules();
|
||||
enableNotifications();
|
||||
GuhCore::instance()->timeManager()->stopTimer();
|
||||
qDebug() << GuhCore::instance()->timeManager()->currentTime().toString();
|
||||
qDebug() << GuhCore::instance()->timeManager()->currentDate().toString();
|
||||
NymeaCore::instance()->timeManager()->stopTimer();
|
||||
qDebug() << NymeaCore::instance()->timeManager()->currentTime().toString();
|
||||
qDebug() << NymeaCore::instance()->timeManager()->currentDate().toString();
|
||||
}
|
||||
|
||||
void TestTimeManager::verifyRuleExecuted(const ActionTypeId &actionTypeId)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "rest/restresource.h"
|
||||
|
|
@ -84,7 +84,7 @@ void TestWebserver::initTestCase()
|
|||
GuhTestBase::initTestCase();
|
||||
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"))) {
|
||||
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";
|
||||
return;
|
||||
|
|
@ -96,7 +96,7 @@ void TestWebserver::initTestCase()
|
|||
config.address = QHostAddress("127.0.0.1");
|
||||
config.port = 3333;
|
||||
config.sslEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebServerConfiguration(config);
|
||||
}
|
||||
|
||||
void TestWebserver::coverageCalls()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "nymeacore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
#include "webserver.h"
|
||||
|
|
@ -70,7 +70,7 @@ void TestWebSocketServer::initTestCase()
|
|||
GuhTestBase::initTestCase();
|
||||
|
||||
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"))) {
|
||||
qDebug() << "Already have a websocketserver listening on 127.0.0.1:4444";
|
||||
config = c;
|
||||
|
|
@ -83,7 +83,7 @@ void TestWebSocketServer::initTestCase()
|
|||
config.port = 4444;
|
||||
config.sslEnabled = true;
|
||||
config.authenticationEnabled = true;
|
||||
GuhCore::instance()->configuration()->setWebSocketServerConfiguration(config);
|
||||
NymeaCore::instance()->configuration()->setWebSocketServerConfiguration(config);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue