diff --git a/libguh-core/guhcore.cpp b/libguh-core/guhcore.cpp index 8f293c9f..de5fd565 100644 --- a/libguh-core/guhcore.cpp +++ b/libguh-core/guhcore.cpp @@ -319,7 +319,7 @@ void GuhCore::executeRuleActions(const QList ruleActions) { foreach (const RuleAction &ruleAction, ruleActions) { Action action = ruleAction.toAction(); - qCDebug(dcRuleEngine) << "executing action" << ruleAction.actionTypeId() << action.params(); + qCDebug(dcRuleEngine) << "Executing action" << ruleAction.actionTypeId() << action.params(); DeviceManager::DeviceError status = executeAction(action); switch(status) { case DeviceManager::DeviceErrorNoError: @@ -464,6 +464,9 @@ void GuhCore::init() { m_logger->logSystemEvent(m_timeManager->currentDateTime(), true); emit initialized(); + + // Evaluate rules on current time + onDateTimeChanged(m_timeManager->currentDateTime()); } /*! Connected to the DeviceManager's emitEvent signal. Events received in @@ -643,14 +646,18 @@ void GuhCore::deviceManagerLoaded() m_logger->removeDeviceLogs(deviceId); } } - foreach (const DeviceId &deviceId, m_ruleEngine->devicesInRules()) { - if (!m_deviceManager->findConfiguredDevice(deviceId)) { - qCDebug(dcApplication()) << "Cleaning stale rule entries for device id" << deviceId; - foreach (const RuleId &ruleId, m_ruleEngine->findRules(deviceId)) { - m_ruleEngine->removeDeviceFromRule(ruleId, deviceId); - } - } - } + + // FIXME: this removes all timedescriptors + + // foreach (const DeviceId &deviceId, m_ruleEngine->devicesInRules()) { + // if (!m_deviceManager->findConfiguredDevice(deviceId)) { + // qCDebug(dcApplication()) << "Cleaning stale rule entries for device id" << deviceId; + // foreach (const RuleId &ruleId, m_ruleEngine->findRules(deviceId)) { + // m_ruleEngine->removeDeviceFromRule(ruleId, deviceId); + // } + // } + // } + qCDebug(dcApplication()) << "Housekeeping done in" << startTime.msecsTo(QDateTime::currentDateTime()) << "ms."; } diff --git a/libguh-core/jsonrpc/jsonrpcserver.cpp b/libguh-core/jsonrpc/jsonrpcserver.cpp index 3807c676..194d1e9e 100644 --- a/libguh-core/jsonrpc/jsonrpcserver.cpp +++ b/libguh-core/jsonrpc/jsonrpcserver.cpp @@ -377,6 +377,8 @@ void JsonRPCServer::processData(const QUuid &clientId, const QByteArray &data) handler->setProperty("clientId", clientId); handler->setProperty("token", message.value("token").toByteArray()); + qCDebug(dcJsonRpc()) << "Got method" << method.toLatin1().data(); + JsonReply *reply; QMetaObject::invokeMethod(handler, method.toLatin1().data(), Q_RETURN_ARG(JsonReply*, reply), Q_ARG(QVariantMap, params)); if (reply->type() == JsonReply::TypeAsync) { diff --git a/libguh-core/ruleengine.cpp b/libguh-core/ruleengine.cpp index b0138842..f5c365fe 100644 --- a/libguh-core/ruleengine.cpp +++ b/libguh-core/ruleengine.cpp @@ -133,7 +133,7 @@ RuleEngine::RuleEngine(QObject *parent) : bool enabled = settings.value("enabled", true).toBool(); bool executable = settings.value("executable", true).toBool(); - qCDebug(dcRuleEngine) << "Load rule" << name << idString; + qCDebug(dcRuleEngine) << "Loading rule" << name << idString; // Load timeDescriptor TimeDescriptor timeDescriptor; diff --git a/libguh-core/tcpserver.cpp b/libguh-core/tcpserver.cpp index d6fe83f2..f050927b 100644 --- a/libguh-core/tcpserver.cpp +++ b/libguh-core/tcpserver.cpp @@ -57,7 +57,7 @@ TcpServer::TcpServer(const ServerConfiguration &configuration, const QSslConfigu /*! Destructor of this \l{TcpServer}. */ TcpServer::~TcpServer() { - qCDebug(dcApplication) << "Shutting down \"TCP Server\""; + qCDebug(dcApplication) << "Shutting down \"TCP Server\"" << QString("%1://%2:%3").arg((configuration().authenticationEnabled ? "guhs" : "guh")).arg(configuration().address.toString()).arg(configuration().port); stopServer(); } diff --git a/libguh-core/time/calendaritem.cpp b/libguh-core/time/calendaritem.cpp index 518cc345..80ec194d 100644 --- a/libguh-core/time/calendaritem.cpp +++ b/libguh-core/time/calendaritem.cpp @@ -154,17 +154,26 @@ bool CalendarItem::evaluateDaily(const QDateTime &dateTime) const if (duration() >= 1440) return true; - // get todays startTime - QDateTime startDateTime = QDateTime(dateTime.date(), startTime()); + // Get todays startTime + QDateTime startDateTime = dateTime; + startDateTime.setTime(startTime()); QDateTime endDateTime = startDateTime.addSecs(duration() * 60); - // get todays startTime - QDateTime startDateTimeYesterday = QDateTime(dateTime.date().addDays(-1), startTime()); + // Get yesterdays startTime for day overlapping clendaritems + QDateTime startDateTimeYesterday = dateTime.addDays(-1); + startDateTimeYesterday.setTime(startTime()); QDateTime endDateTimeYesterday = startDateTimeYesterday.addSecs(duration() * 60); bool todayValid = dateTime >= startDateTime && dateTime < endDateTime; bool yesterdayValid = dateTime >= startDateTimeYesterday && dateTime < endDateTimeYesterday; + qCDebug(dcRuleEngine()) << "-------------------------------------------------------------------------------"; + qCDebug(dcRuleEngine()) << "Evaluate daily: current time" << dateTime.toString("dd:MM:yyyy hh:mm") << dateTime.toTime_t(); + qCDebug(dcRuleEngine()) << "Evaluate daily: start time" << startDateTime.toString("dd:MM:yyyy hh:mm") << startDateTime.toTime_t(); + qCDebug(dcRuleEngine()) << "Evaluate daily: end time" << endDateTime.toString("dd:MM:yyyy hh:mm") << endDateTime.toTime_t(); + qCDebug(dcRuleEngine()) << "Today valid" << todayValid; + qCDebug(dcRuleEngine()) << "Yesterday valid" << yesterdayValid; + return todayValid || yesterdayValid; } diff --git a/libguh-core/webserver.cpp b/libguh-core/webserver.cpp index 8224f673..5e1890f9 100644 --- a/libguh-core/webserver.cpp +++ b/libguh-core/webserver.cpp @@ -115,7 +115,8 @@ WebServer::WebServer(const WebServerConfiguration &configuration, const QSslConf /*! Destructor of this \l{WebServer}. */ WebServer::~WebServer() { - qCDebug(dcApplication) << "Shutting down \"Webserver\""; + qCDebug(dcApplication) << "Shutting down \"Webserver\"" << QString("%1://%2:%3").arg((m_configuration.authenticationEnabled ? "https" : "http")).arg(m_configuration.address.toString()).arg(m_configuration.port); + this->close(); } diff --git a/libguh-core/websocketserver.cpp b/libguh-core/websocketserver.cpp index 57a38fde..54b33d74 100644 --- a/libguh-core/websocketserver.cpp +++ b/libguh-core/websocketserver.cpp @@ -73,7 +73,7 @@ WebSocketServer::WebSocketServer(const ServerConfiguration &configuration, const /*! Destructor of this \l{WebSocketServer}. */ WebSocketServer::~WebSocketServer() { - qCDebug(dcApplication) << "Shutting down \"Websocket server\""; + qCDebug(dcApplication) << "Shutting down \"Websocket server\"" << QString("%1://%2:%3").arg((configuration().authenticationEnabled ? "wss" : "ws")).arg(configuration().address.toString()).arg(configuration().port); stopServer(); } diff --git a/tests/auto/timemanager/testtimemanager.cpp b/tests/auto/timemanager/testtimemanager.cpp index 9538fb85..ce4b3e29 100644 --- a/tests/auto/timemanager/testtimemanager.cpp +++ b/tests/auto/timemanager/testtimemanager.cpp @@ -213,9 +213,6 @@ void TestTimeManager::loadSaveTimeDescriptor() QVariantMap timeDescriptorMapLoaded = response.toMap().value("params").toMap().value("rule").toMap().value("timeDescriptor").toMap(); - qDebug() << timeDescriptorMapLoaded; - qDebug() << timeDescriptorMap; - QCOMPARE(timeDescriptorMap, timeDescriptorMapLoaded); // REMOVE rule