JsonReply *RulesHandler::GetRuleDetails(const QVariantMap ¶ms) { RuleId ruleId = RuleId(params.value("ruleId").toString()); Rule rule = GuhCore::instance()->findRule(ruleId); if (rule.id().isNull()) { return createReply(statusToReply(RuleEngine::RuleErrorRuleNotFound)); } QVariantMap returns = statusToReply(RuleEngine::RuleErrorNoError); returns.insert("rule", JsonTypes::packRule(rule)); return createReply(returns); }
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 EventType &eventType, deviceClass.eventTypes()) { if (eventType.id() == eventTypeId) { QVariantMap data = statusToReply(DeviceManager::DeviceErrorNoError); data.insert("eventType", JsonTypes::packEventType(eventType)); return createReply(data); } } }
void LoggingHandler::logEntryAdded(const LogEntry &logEntry) { qCDebug(dcJsonRpc) << "Notify \"Logging.LogEntryAdded\""; QVariantMap params; params.insert("logEntry", JsonTypes::packLogEntry(logEntry)); emit LogEntryAdded(params); } void LoggingHandler::logDatabaseUpdated() { qCDebug(dcJsonRpc) << "Notify \"Logging.LogDatabaseUpdated\""; emit LogDatabaseUpdated(QVariantMap()); } JsonReply* LoggingHandler::GetLogEntries(const QVariantMap ¶ms) const { qCDebug(dcJsonRpc) << "Asked for log entries" << params; LogFilter filter = JsonTypes::unpackLogFilter(params); QVariantList entries; foreach (const LogEntry &entry, GuhCore::instance()->logEngine()->logEntries(filter)) { entries.append(JsonTypes::packLogEntry(entry)); } QVariantMap returns = statusToReply(Logging::LoggingErrorNoError); returns.insert("logEntries", entries); return createReply(returns); } }