/*! Return true, if this RuleAction contains a \l{RuleActionParam} which is based on an EventTypeId.*/ bool RuleAction::isEventBased() const { foreach (const RuleActionParam ¶m, m_ruleActionParams) { if (param.eventTypeId() != EventTypeId()) { return true; } } return false; }
void HttpDaemon::readClient() { if (disabled) return; // This slot is called when the client sent data to the server. The // server looks if it was a get request and sends a very simple HTML // document back. QTcpSocket* socket = (QTcpSocket*)sender(); if (socket->canReadLine()) { QByteArray data = socket->readLine(); QStringList tokens = QString(data).split(QRegExp("[ \r\n][ \r\n]*")); qDebug() << "incoming data" << tokens[1]; QUrl url("http://foo.bar" + tokens[1]); QUrlQuery query(url); qDebug() << "query is" << url.path(); if (url.path() == "/setstate") { emit setState(StateTypeId(query.queryItems().first().first), QVariant(query.queryItems().first().second)); } else if (url.path() == "/generateevent") { qDebug() << "got generateevent" << query.queryItemValue("eventtypeid"); emit triggerEvent(EventTypeId(query.queryItemValue("eventtypeid"))); } else if (url.path() == "/actionhistory") { QTextStream os(socket); os.setAutoDetectUnicode(true); os << generateHeader(); for (int i = 0; i < m_actionList.count(); ++i) { os << m_actionList.at(i).first.toString() << '\n'; } socket->close(); return; } else if (url.path() == "/clearactionhistory") { m_actionList.clear(); } if (tokens[0] == "GET") { QTextStream os(socket); os.setAutoDetectUnicode(true); os << generateWebPage(); socket->close(); qDebug() << "Wrote to client"; if (socket->state() == QTcpSocket::UnconnectedState) { delete socket; qDebug() << "Connection closed"; } } } }
\quotefile plugins/deviceplugins/lircd/devicepluginlircd.json */ #include "devicepluginlircd.h" #include "plugin/device.h" #include "devicemanager.h" #include "plugininfo.h" #include "lircdclient.h" #include <QDebug> #include <QStringList> DeviceClassId lircdDeviceClassId = DeviceClassId("5c2bc4cd-ba6c-4052-b6cd-1db83323ea22"); EventTypeId LircKeypressEventTypeId = EventTypeId("8711471a-fa0e-410b-b174-dfc3d2aeffb1"); DevicePluginLircd::DevicePluginLircd() { m_lircClient = new LircClient(this); //m_lircClient->connect(); connect(m_lircClient, &LircClient::buttonPressed, this, &DevicePluginLircd::buttonPressed); } DeviceManager::HardwareResources DevicePluginLircd::requiredHardware() const { return DeviceManager::HardwareResourceNone; } void DevicePluginLircd::buttonPressed(const QString &remoteName, const QString &buttonName, int repeat)