add guhserver namespace to server
This commit is contained in:
parent
523b954933
commit
91afe4f29e
@ -112,6 +112,9 @@
|
|||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "plugin/device.h"
|
#include "plugin/device.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
GuhCore* GuhCore::s_instance = 0;
|
GuhCore* GuhCore::s_instance = 0;
|
||||||
|
|
||||||
/*! Returns a pointer to the single \l{GuhCore} instance. */
|
/*! Returns a pointer to the single \l{GuhCore} instance. */
|
||||||
@ -517,3 +520,5 @@ void GuhCore::actionExecutionFinished(const ActionId &id, DeviceManager::DeviceE
|
|||||||
Action action = m_pendingActions.take(id);
|
Action action = m_pendingActions.take(id);
|
||||||
m_logger->logAction(action, status == DeviceManager::DeviceErrorNoError ? Logging::LoggingLevelInfo : Logging::LoggingLevelAlert, status);
|
m_logger->logAction(action, status == DeviceManager::DeviceErrorNoError ? Logging::LoggingLevelInfo : Logging::LoggingLevelAlert, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "rule.h"
|
#include "rule.h"
|
||||||
#include "types/event.h"
|
#include "types/event.h"
|
||||||
|
#include "plugin/device.h"
|
||||||
|
#include "plugin/deviceplugin.h"
|
||||||
#include "plugin/deviceclass.h"
|
#include "plugin/deviceclass.h"
|
||||||
#include "plugin/devicedescriptor.h"
|
#include "plugin/devicedescriptor.h"
|
||||||
|
|
||||||
@ -33,8 +35,9 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class JsonRPCServer;
|
class JsonRPCServer;
|
||||||
class Device;
|
|
||||||
class LogEngine;
|
class LogEngine;
|
||||||
|
|
||||||
class GuhCore : public QObject
|
class GuhCore : public QObject
|
||||||
@ -131,4 +134,6 @@ private slots:
|
|||||||
friend class GuhTestBase;
|
friend class GuhTestBase;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // GUHCORE_H
|
#endif // GUHCORE_H
|
||||||
|
|||||||
@ -22,6 +22,8 @@
|
|||||||
#include "guhservice.h"
|
#include "guhservice.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
GuhService::GuhService(int argc, char **argv):
|
GuhService::GuhService(int argc, char **argv):
|
||||||
QtService<QCoreApplication>(argc, argv, "guh daemon")
|
QtService<QCoreApplication>(argc, argv, "guh daemon")
|
||||||
{
|
{
|
||||||
@ -44,3 +46,5 @@ void GuhService::start()
|
|||||||
{
|
{
|
||||||
GuhCore::instance()->setRunningMode(GuhCore::RunningModeService);
|
GuhCore::instance()->setRunningMode(GuhCore::RunningModeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class GuhService : public QtService<QCoreApplication>
|
class GuhService : public QtService<QCoreApplication>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -37,4 +39,6 @@ protected:
|
|||||||
void start();
|
void start();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // GUHSERVICE_H
|
#endif // GUHSERVICE_H
|
||||||
|
|||||||
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
ActionHandler::ActionHandler(QObject *parent) :
|
ActionHandler::ActionHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -102,3 +104,5 @@ void ActionHandler::actionExecuted(const ActionId &id, DeviceManager::DeviceErro
|
|||||||
reply->setData(statusToReply(status));
|
reply->setData(statusToReply(status));
|
||||||
reply->finished();
|
reply->finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -25,6 +25,8 @@
|
|||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class ActionHandler : public JsonHandler
|
class ActionHandler : public JsonHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -44,4 +46,6 @@ private:
|
|||||||
QHash<ActionId, JsonReply*> m_asyncActionExecutions;
|
QHash<ActionId, JsonReply*> m_asyncActionExecutions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ACTIONHANDLER_H
|
#endif // ACTIONHANDLER_H
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
DeviceHandler::DeviceHandler(QObject *parent) :
|
DeviceHandler::DeviceHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -672,3 +674,5 @@ void DeviceHandler::pairingFinished(const PairingTransactionId &pairingTransacti
|
|||||||
|
|
||||||
m_asynDeviceAdditions.insert(deviceId, reply);
|
m_asynDeviceAdditions.insert(deviceId, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -25,6 +25,8 @@
|
|||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class DeviceHandler : public JsonHandler
|
class DeviceHandler : public JsonHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -98,4 +100,6 @@ private:
|
|||||||
mutable QHash<QUuid, JsonReply*> m_asyncPairingRequests;
|
mutable QHash<QUuid, JsonReply*> m_asyncPairingRequests;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DEVICEHANDLER_H
|
#endif // DEVICEHANDLER_H
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
EventHandler::EventHandler(QObject *parent) :
|
EventHandler::EventHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -73,3 +75,5 @@ JsonReply* EventHandler::GetEventType(const QVariantMap ¶ms) const
|
|||||||
}
|
}
|
||||||
return createReply(statusToReply(DeviceManager::DeviceErrorEventTypeNotFound));
|
return createReply(statusToReply(DeviceManager::DeviceErrorEventTypeNotFound));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class EventHandler : public JsonHandler
|
class EventHandler : public JsonHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -39,4 +41,6 @@ private slots:
|
|||||||
void eventTriggered(const Event &event);
|
void eventTriggered(const Event &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EVENTHANDLER_H
|
#endif // EVENTHANDLER_H
|
||||||
|
|||||||
@ -26,6 +26,8 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
JsonHandler::JsonHandler(QObject *parent) :
|
JsonHandler::JsonHandler(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
@ -238,3 +240,5 @@ bool JsonReply::timedOut() const
|
|||||||
{
|
{
|
||||||
return m_timedOut;
|
return m_timedOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class JsonHandler;
|
class JsonHandler;
|
||||||
|
|
||||||
class JsonReply: public QObject
|
class JsonReply: public QObject
|
||||||
@ -116,4 +118,6 @@ private:
|
|||||||
QHash<QString, QVariantMap> m_returns;
|
QHash<QString, QVariantMap> m_returns;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // JSONHANDLER_H
|
#endif // JSONHANDLER_H
|
||||||
|
|||||||
@ -48,6 +48,8 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
JsonRPCServer::JsonRPCServer(QObject *parent):
|
JsonRPCServer::JsonRPCServer(QObject *parent):
|
||||||
JsonHandler(parent),
|
JsonHandler(parent),
|
||||||
#ifdef TESTING_ENABLED
|
#ifdef TESTING_ENABLED
|
||||||
@ -301,4 +303,4 @@ void JsonRPCServer::sendErrorResponse(const QUuid &clientId, int commandId, cons
|
|||||||
m_tcpServer->sendData(clientId, jsonDoc.toJson());
|
m_tcpServer->sendData(clientId, jsonDoc.toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#ifndef JSONRPCSERVER_H
|
#ifndef JSONRPCSERVER_H
|
||||||
#define JSONRPCSERVER_H
|
#define JSONRPCSERVER_H
|
||||||
|
|
||||||
|
#include "plugin/device.h"
|
||||||
#include "plugin/deviceclass.h"
|
#include "plugin/deviceclass.h"
|
||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
|
|
||||||
@ -32,12 +33,14 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
#ifdef TESTING_ENABLED
|
#ifdef TESTING_ENABLED
|
||||||
class MockTcpServer;
|
class MockTcpServer;
|
||||||
#else
|
#else
|
||||||
class TcpServer;
|
class TcpServer;
|
||||||
#endif
|
#endif
|
||||||
class Device;
|
|
||||||
|
|
||||||
class JsonRPCServer: public JsonHandler
|
class JsonRPCServer: public JsonHandler
|
||||||
{
|
{
|
||||||
@ -88,4 +91,6 @@ private:
|
|||||||
int m_notificationId;
|
int m_notificationId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
#endif // JSONRPCSERVER_H
|
||||||
|
|||||||
@ -31,6 +31,8 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
bool JsonTypes::s_initialized = false;
|
bool JsonTypes::s_initialized = false;
|
||||||
QString JsonTypes::s_lastError;
|
QString JsonTypes::s_lastError;
|
||||||
|
|
||||||
@ -1107,3 +1109,5 @@ QPair<bool, QString> JsonTypes::validateEnum(const QVariantList &enumDescription
|
|||||||
|
|
||||||
return report(enumDescription.contains(value.toString()), QString("Value %1 not allowed in %2").arg(value.toString()).arg(enumStrings.join(", ")));
|
return report(enumDescription.contains(value.toString()), QString("Value %1 not allowed in %2").arg(value.toString()).arg(enumStrings.join(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
#define JSONTYPES_H
|
#define JSONTYPES_H
|
||||||
|
|
||||||
#include "plugin/deviceclass.h"
|
#include "plugin/deviceclass.h"
|
||||||
|
#include "plugin/device.h"
|
||||||
|
#include "plugin/deviceplugin.h"
|
||||||
#include "plugin/devicedescriptor.h"
|
#include "plugin/devicedescriptor.h"
|
||||||
#include "rule.h"
|
#include "rule.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
@ -44,8 +46,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
class DevicePlugin;
|
namespace guhserver {
|
||||||
class Device;
|
|
||||||
|
|
||||||
#define DECLARE_OBJECT(typeName, jsonName) \
|
#define DECLARE_OBJECT(typeName, jsonName) \
|
||||||
public: \
|
public: \
|
||||||
@ -182,4 +183,6 @@ private:
|
|||||||
static QString s_lastError;
|
static QString s_lastError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // JSONTYPES_H
|
#endif // JSONTYPES_H
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
LoggingHandler::LoggingHandler(QObject *parent) :
|
LoggingHandler::LoggingHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -38,7 +40,7 @@ LoggingHandler::LoggingHandler(QObject *parent) :
|
|||||||
|
|
||||||
params.clear(); returns.clear();
|
params.clear(); returns.clear();
|
||||||
setDescription("GetLogEntries", "Get the LogEntries matching the given filter.");
|
setDescription("GetLogEntries", "Get the LogEntries matching the given filter.");
|
||||||
// params.insert("eventTypeId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
// params.insert("eventTypeId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
||||||
setParams("GetLogEntries", params);
|
setParams("GetLogEntries", params);
|
||||||
returns.insert("loggingError", JsonTypes::loggingErrorRef());
|
returns.insert("loggingError", JsonTypes::loggingErrorRef());
|
||||||
returns.insert("o:logEntries", QVariantList() << JsonTypes::logEntryRef());
|
returns.insert("o:logEntries", QVariantList() << JsonTypes::logEntryRef());
|
||||||
@ -70,3 +72,5 @@ JsonReply* LoggingHandler::GetLogEntries(const QVariantMap ¶ms) const
|
|||||||
returns.insert("logEntries", entries);
|
returns.insert("logEntries", entries);
|
||||||
return createReply(returns);
|
return createReply(returns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -25,6 +25,8 @@
|
|||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
#include "logging/logentry.h"
|
#include "logging/logentry.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class LoggingHandler : public JsonHandler
|
class LoggingHandler : public JsonHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -40,4 +42,6 @@ private slots:
|
|||||||
void logEntryAdded(const LogEntry &entry);
|
void logEntryAdded(const LogEntry &entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // LOGGINGHANDLER_H
|
#endif // LOGGINGHANDLER_H
|
||||||
|
|||||||
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
RulesHandler::RulesHandler(QObject *parent) :
|
RulesHandler::RulesHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -511,3 +513,5 @@ void RulesHandler::ruleConfigurationChangedNotification(const Rule &rule)
|
|||||||
|
|
||||||
emit RuleConfigurationChanged(params);
|
emit RuleConfigurationChanged(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class RulesHandler : public JsonHandler
|
class RulesHandler : public JsonHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -68,4 +70,6 @@ private slots:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // RULESHANDLER_H
|
#endif // RULESHANDLER_H
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
StateHandler::StateHandler(QObject *parent) :
|
StateHandler::StateHandler(QObject *parent) :
|
||||||
JsonHandler(parent)
|
JsonHandler(parent)
|
||||||
{
|
{
|
||||||
@ -58,3 +60,5 @@ JsonReply* StateHandler::GetStateType(const QVariantMap ¶ms) const
|
|||||||
}
|
}
|
||||||
return createReply(statusToReply(DeviceManager::DeviceErrorStateTypeNotFound));
|
return createReply(statusToReply(DeviceManager::DeviceErrorStateTypeNotFound));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class StateHandler : public JsonHandler
|
class StateHandler : public JsonHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -34,4 +36,6 @@ public:
|
|||||||
Q_INVOKABLE JsonReply *GetStateType(const QVariantMap ¶ms) const;
|
Q_INVOKABLE JsonReply *GetStateType(const QVariantMap ¶ms) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EVENTHANDLER_H
|
#endif // EVENTHANDLER_H
|
||||||
|
|||||||
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#define DB_SCHEMA_VERSION 1
|
#define DB_SCHEMA_VERSION 1
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
LogEngine::LogEngine(QObject *parent):
|
LogEngine::LogEngine(QObject *parent):
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
@ -210,3 +212,5 @@ void LogEngine::initDB()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class LogEngine: public QObject
|
class LogEngine: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -56,4 +58,6 @@ private:
|
|||||||
QSqlDatabase m_db;
|
QSqlDatabase m_db;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
LogEntry::LogEntry(QDateTime timestamp, Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode):
|
LogEntry::LogEntry(QDateTime timestamp, Logging::LoggingLevel level, Logging::LoggingSource source, int errorCode):
|
||||||
m_timestamp(timestamp),
|
m_timestamp(timestamp),
|
||||||
m_level(level),
|
m_level(level),
|
||||||
@ -109,3 +111,5 @@ int LogEntry::errorCode() const
|
|||||||
{
|
{
|
||||||
return m_errorCode;
|
return m_errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -27,6 +27,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class LogEntry
|
class LogEntry
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
@ -76,4 +78,6 @@ private:
|
|||||||
int m_errorCode;
|
int m_errorCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class LogFilter
|
class LogFilter
|
||||||
{
|
{
|
||||||
QDateTime m_startDate;
|
QDateTime m_startDate;
|
||||||
@ -30,4 +32,6 @@ class LogFilter
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class Logging
|
class Logging
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
@ -57,4 +59,6 @@ public:
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
#endif // LOGGING_H
|
||||||
|
|||||||
@ -24,14 +24,18 @@
|
|||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
#include <QMessageLogger>
|
#include <QMessageLogger>
|
||||||
|
#include <QStringList>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "guhservice.h"
|
#include "guhservice.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
|
||||||
QHash<QString, bool> s_loggingFilters;
|
QHash<QString, bool> s_loggingFilters;
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
void loggingCategoryFilter(QLoggingCategory *category)
|
void loggingCategoryFilter(QLoggingCategory *category)
|
||||||
{
|
{
|
||||||
if (s_loggingFilters.contains(category->categoryName())) {
|
if (s_loggingFilters.contains(category->categoryName())) {
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#if defined(QTSERVICE_DEBUG)
|
#if defined(QTSERVICE_DEBUG)
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -58,6 +59,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static QFile* f = 0;
|
static QFile* f = 0;
|
||||||
|
|
||||||
static void qtServiceCloseDebugLog()
|
static void qtServiceCloseDebugLog()
|
||||||
@ -78,10 +80,10 @@ void qtServiceLogDebug(QtMsgType type, const char* msg)
|
|||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
QString s(QTime::currentTime().toString("HH:mm:ss.zzz "));
|
QString s(QTime::currentTime().toString("HH:mm:ss.zzz "));
|
||||||
s += QString("[%1] ").arg(
|
s += QString("[%1] ").arg(
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
GetCurrentProcessId());
|
GetCurrentProcessId());
|
||||||
#else
|
#else
|
||||||
getpid());
|
getpid());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
@ -201,6 +203,7 @@ void qtServiceLogDebug(QtMsgType type, const char* msg)
|
|||||||
|
|
||||||
\sa startupType()
|
\sa startupType()
|
||||||
*/
|
*/
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -208,7 +211,7 @@ void qtServiceLogDebug(QtMsgType type, const char* msg)
|
|||||||
\a name.
|
\a name.
|
||||||
*/
|
*/
|
||||||
QtServiceController::QtServiceController(const QString &name)
|
QtServiceController::QtServiceController(const QString &name)
|
||||||
: d_ptr(new QtServiceControllerPrivate())
|
: d_ptr(new QtServiceControllerPrivate())
|
||||||
{
|
{
|
||||||
Q_D(QtServiceController);
|
Q_D(QtServiceController);
|
||||||
d->q_ptr = this;
|
d->q_ptr = this;
|
||||||
@ -303,7 +306,7 @@ QString QtServiceController::serviceName() const
|
|||||||
\sa uninstall(), start()
|
\sa uninstall(), start()
|
||||||
*/
|
*/
|
||||||
bool QtServiceController::install(const QString &serviceFilePath, const QString &account,
|
bool QtServiceController::install(const QString &serviceFilePath, const QString &account,
|
||||||
const QString &password)
|
const QString &password)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << QLatin1String("-i");
|
arguments << QLatin1String("-i");
|
||||||
@ -636,12 +639,12 @@ QtServiceBase::QtServiceBase(int argc, char **argv, const QString &name)
|
|||||||
|
|
||||||
QString nm(name);
|
QString nm(name);
|
||||||
if (nm.length() > 255) {
|
if (nm.length() > 255) {
|
||||||
qWarning("QtService: 'name' is longer than 255 characters.");
|
qWarning("QtService: 'name' is longer than 255 characters.");
|
||||||
nm.truncate(255);
|
nm.truncate(255);
|
||||||
}
|
}
|
||||||
if (nm.contains('\\')) {
|
if (nm.contains('\\')) {
|
||||||
qWarning("QtService: 'name' contains backslashes '\\'.");
|
qWarning("QtService: 'name' contains backslashes '\\'.");
|
||||||
nm.replace((QChar)'\\', (QChar)'\0');
|
nm.replace((QChar)'\\', (QChar)'\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr = new QtServiceBasePrivate(nm);
|
d_ptr = new QtServiceBasePrivate(nm);
|
||||||
@ -771,7 +774,7 @@ int QtServiceBase::exec()
|
|||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
printf("The service %s has been installed under: %s\n",
|
printf("The service %s has been installed under: %s\n",
|
||||||
serviceName().toLatin1().constData(), d_ptr->filePath().toLatin1().constData());
|
serviceName().toLatin1().constData(), d_ptr->filePath().toLatin1().constData());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "The service %s is already installed\n", serviceName().toLatin1().constData());
|
fprintf(stderr, "The service %s is already installed\n", serviceName().toLatin1().constData());
|
||||||
@ -784,7 +787,7 @@ int QtServiceBase::exec()
|
|||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
printf("The service %s has been uninstalled.\n",
|
printf("The service %s has been uninstalled.\n",
|
||||||
serviceName().toLatin1().constData());
|
serviceName().toLatin1().constData());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "The service %s is not installed\n", serviceName().toLatin1().constData());
|
fprintf(stderr, "The service %s is not installed\n", serviceName().toLatin1().constData());
|
||||||
@ -792,7 +795,7 @@ int QtServiceBase::exec()
|
|||||||
return 0;
|
return 0;
|
||||||
} else if (a == QLatin1String("-v") || a == QLatin1String("-version")) {
|
} else if (a == QLatin1String("-v") || a == QLatin1String("-version")) {
|
||||||
printf("The service\n"
|
printf("The service\n"
|
||||||
"\t%s\n\t%s\n\n", serviceName().toLatin1().constData(), d_ptr->args.at(0).toLatin1().constData());
|
"\t%s\n\t%s\n\n", serviceName().toLatin1().constData(), d_ptr->args.at(0).toLatin1().constData());
|
||||||
printf("is %s", (d_ptr->controller.isInstalled() ? "installed" : "not installed"));
|
printf("is %s", (d_ptr->controller.isInstalled() ? "installed" : "not installed"));
|
||||||
printf(" and %s\n\n", (d_ptr->controller.isRunning() ? "running" : "not running"));
|
printf(" and %s\n\n", (d_ptr->controller.isRunning() ? "running" : "not running"));
|
||||||
return 0;
|
return 0;
|
||||||
@ -1111,6 +1114,4 @@ void QtServiceBase::processCommand(int /*code*/)
|
|||||||
|
|
||||||
\reimp
|
\reimp
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
#define QTSERVICE_H
|
#define QTSERVICE_H
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
# if !defined(QT_QTSERVICE_EXPORT) && !defined(QT_QTSERVICE_IMPORT)
|
# if !defined(QT_QTSERVICE_EXPORT) && !defined(QT_QTSERVICE_IMPORT)
|
||||||
@ -59,7 +60,8 @@
|
|||||||
# define QT_QTSERVICE_EXPORT
|
# define QT_QTSERVICE_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QStringList;
|
namespace guhserver {
|
||||||
|
|
||||||
class QtServiceControllerPrivate;
|
class QtServiceControllerPrivate;
|
||||||
|
|
||||||
class QT_QTSERVICE_EXPORT QtServiceController
|
class QT_QTSERVICE_EXPORT QtServiceController
|
||||||
@ -186,7 +188,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Application *app;
|
Application *app;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QtServiceBase::ServiceFlags)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QtServiceBase::ServiceFlags)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QTSERVICE_H
|
#endif // QTSERVICE_H
|
||||||
|
|||||||
@ -44,6 +44,8 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "qtservice.h"
|
#include "qtservice.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class QtServiceControllerPrivate
|
class QtServiceControllerPrivate
|
||||||
{
|
{
|
||||||
Q_DECLARE_PUBLIC(QtServiceController)
|
Q_DECLARE_PUBLIC(QtServiceController)
|
||||||
@ -84,4 +86,6 @@ public:
|
|||||||
class QtServiceSysPrivate *sysd;
|
class QtServiceSysPrivate *sysd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -58,6 +58,9 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
static QString encodeName(const QString &name, bool allowUpper = false)
|
static QString encodeName(const QString &name, bool allowUpper = false)
|
||||||
{
|
{
|
||||||
@ -472,3 +475,4 @@ void QtServiceBase::setServiceFlags(QtServiceBase::ServiceFlags flags)
|
|||||||
d_ptr->sysd->serviceFlags = flags;
|
d_ptr->sysd->serviceFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -62,6 +62,8 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
typedef SERVICE_STATUS_HANDLE(WINAPI*PRegisterServiceCtrlHandler)(const wchar_t*,LPHANDLER_FUNCTION);
|
typedef SERVICE_STATUS_HANDLE(WINAPI*PRegisterServiceCtrlHandler)(const wchar_t*,LPHANDLER_FUNCTION);
|
||||||
static PRegisterServiceCtrlHandler pRegisterServiceCtrlHandler = 0;
|
static PRegisterServiceCtrlHandler pRegisterServiceCtrlHandler = 0;
|
||||||
typedef BOOL(WINAPI*PSetServiceStatus)(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
|
typedef BOOL(WINAPI*PSetServiceStatus)(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
|
||||||
@ -942,4 +944,4 @@ void QtServiceBase::setServiceFlags(QtServiceBase::ServiceFlags flags)
|
|||||||
d_ptr->sysd->setServiceFlags(flags);
|
d_ptr->sysd->setServiceFlags(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -45,6 +45,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
#ifndef SUN_LEN
|
#ifndef SUN_LEN
|
||||||
#define SUN_LEN(ptr) ((size_t)(((struct sockaddr_un *) 0)->sun_path) \
|
#define SUN_LEN(ptr) ((size_t)(((struct sockaddr_un *) 0)->sun_path) \
|
||||||
+strlen ((ptr)->sun_path))
|
+strlen ((ptr)->sun_path))
|
||||||
@ -90,3 +92,5 @@ void QtUnixServerSocket::close()
|
|||||||
path_.clear();
|
path_.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -43,6 +43,8 @@
|
|||||||
|
|
||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class QtUnixServerSocket : public QTcpServer
|
class QtUnixServerSocket : public QTcpServer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -57,5 +59,6 @@ private:
|
|||||||
QString path_;
|
QString path_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -50,6 +50,8 @@
|
|||||||
+strlen ((ptr)->sun_path))
|
+strlen ((ptr)->sun_path))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
QtUnixSocket::QtUnixSocket(QObject *parent)
|
QtUnixSocket::QtUnixSocket(QObject *parent)
|
||||||
: QTcpSocket(parent)
|
: QTcpSocket(parent)
|
||||||
{
|
{
|
||||||
@ -76,3 +78,5 @@ bool QtUnixSocket::connectTo(const QString &path)
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -43,6 +43,8 @@
|
|||||||
|
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class QtUnixSocket : public QTcpSocket
|
class QtUnixSocket : public QTcpSocket
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -52,4 +54,5 @@ public:
|
|||||||
bool connectTo(const QString &path);
|
bool connectTo(const QString &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
/*! Constructs an empty, invalid rule. */
|
/*! Constructs an empty, invalid rule. */
|
||||||
Rule::Rule():
|
Rule::Rule():
|
||||||
Rule(RuleId(), QString(), QList<EventDescriptor>(), StateEvaluator(), QList<RuleAction>(), QList<RuleAction>())
|
Rule(RuleId(), QString(), QList<EventDescriptor>(), StateEvaluator(), QList<RuleAction>(), QList<RuleAction>())
|
||||||
@ -145,3 +147,5 @@ void Rule::setActive(bool active)
|
|||||||
{
|
{
|
||||||
m_active = active;
|
m_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class Rule
|
class Rule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -66,4 +68,6 @@ private:
|
|||||||
bool m_active;
|
bool m_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // RULE_H
|
#endif // RULE_H
|
||||||
|
|||||||
@ -95,6 +95,8 @@
|
|||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
/*! Constructs the RuleEngine with the given \a parent. Although it wouldn't harm to have multiple RuleEngines, there is one
|
/*! Constructs the RuleEngine with the given \a parent. Although it wouldn't harm to have multiple RuleEngines, there is one
|
||||||
instance available from \l{GuhCore}. This one should be used instead of creating multiple ones.
|
instance available from \l{GuhCore}. This one should be used instead of creating multiple ones.
|
||||||
*/
|
*/
|
||||||
@ -629,3 +631,5 @@ void RuleEngine::saveRule(const Rule &rule)
|
|||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -30,6 +30,8 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class RuleEngine : public QObject
|
class RuleEngine : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -95,6 +97,9 @@ private:
|
|||||||
QHash<RuleId, Rule> m_rules; // ...but use a Hash for faster finding
|
QHash<RuleId, Rule> m_rules; // ...but use a Hash for faster finding
|
||||||
QList<RuleId> m_activeRules;
|
QList<RuleId> m_activeRules;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(RuleEngine::RuleError)
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(guhserver::RuleEngine::RuleError)
|
||||||
|
|
||||||
#endif // RULEENGINE_H
|
#endif // RULEENGINE_H
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
StateEvaluator::StateEvaluator(const StateDescriptor &stateDescriptor):
|
StateEvaluator::StateEvaluator(const StateDescriptor &stateDescriptor):
|
||||||
m_stateDescriptor(stateDescriptor),
|
m_stateDescriptor(stateDescriptor),
|
||||||
m_operatorType(Types::StateOperatorAnd)
|
m_operatorType(Types::StateOperatorAnd)
|
||||||
@ -171,4 +173,4 @@ StateEvaluator StateEvaluator::loadFromSettings(QSettings &settings, const QStri
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -28,6 +28,8 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class StateEvaluator
|
class StateEvaluator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -58,4 +60,6 @@ private:
|
|||||||
Types::StateOperator m_operatorType;
|
Types::StateOperator m_operatorType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // STATEEVALUATOR_H
|
#endif // STATEEVALUATOR_H
|
||||||
|
|||||||
@ -26,6 +26,8 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
TcpServer::TcpServer(QObject *parent) :
|
TcpServer::TcpServer(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
@ -149,4 +151,4 @@ bool TcpServer::stopServer()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -28,6 +28,8 @@
|
|||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class TcpServer : public QObject
|
class TcpServer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -57,4 +59,6 @@ public slots:
|
|||||||
bool stopServer();
|
bool stopServer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TCPSERVER_H
|
#endif // TCPSERVER_H
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestActions: public GuhTestBase
|
class TestActions: public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -148,6 +150,5 @@ void TestActions::getActionType()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "testactions.moc"
|
#include "testactions.moc"
|
||||||
QTEST_MAIN(TestActions)
|
QTEST_MAIN(TestActions)
|
||||||
|
|||||||
@ -30,6 +30,8 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestDevices : public GuhTestBase
|
class TestDevices : public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -885,5 +887,5 @@ void TestDevices::removeDevice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "testdevices.moc"
|
#include "testdevices.moc"
|
||||||
|
|
||||||
QTEST_MAIN(TestDevices)
|
QTEST_MAIN(TestDevices)
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestEvents: public GuhTestBase
|
class TestEvents: public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@ -34,6 +34,8 @@
|
|||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
||||||
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||||
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
||||||
@ -193,3 +195,5 @@ void GuhTestBase::restartServer()
|
|||||||
spy.wait();
|
spy.wait();
|
||||||
m_mockTcpServer = MockTcpServer::servers().first();
|
m_mockTcpServer = MockTcpServer::servers().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -34,6 +34,8 @@
|
|||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
extern DeviceClassId mockDeviceClassId;
|
extern DeviceClassId mockDeviceClassId;
|
||||||
extern DeviceClassId mockDeviceAutoClassId;
|
extern DeviceClassId mockDeviceAutoClassId;
|
||||||
extern DeviceClassId mockDeviceDiscoveryClassId;
|
extern DeviceClassId mockDeviceDiscoveryClassId;
|
||||||
@ -50,6 +52,7 @@ extern EventTypeId mockEvent2Id;
|
|||||||
extern StateTypeId mockIntStateId;
|
extern StateTypeId mockIntStateId;
|
||||||
extern StateTypeId mockBoolStateId;
|
extern StateTypeId mockBoolStateId;
|
||||||
|
|
||||||
|
|
||||||
class MockTcpServer;
|
class MockTcpServer;
|
||||||
|
|
||||||
class GuhTestBase : public QObject
|
class GuhTestBase : public QObject
|
||||||
@ -136,4 +139,6 @@ protected:
|
|||||||
QString m_rulesSettings;
|
QString m_rulesSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // GUHTESTBASE_H
|
#endif // GUHTESTBASE_H
|
||||||
|
|||||||
@ -33,6 +33,8 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestJSONRPC: public GuhTestBase
|
class TestJSONRPC: public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
QList<MockTcpServer*> MockTcpServer::s_allServers;
|
QList<MockTcpServer*> MockTcpServer::s_allServers;
|
||||||
|
|
||||||
MockTcpServer::MockTcpServer(QObject *parent):
|
MockTcpServer::MockTcpServer(QObject *parent):
|
||||||
@ -66,3 +68,5 @@ bool MockTcpServer::stopServer()
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -25,6 +25,8 @@
|
|||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
class MockTcpServer : public QObject
|
class MockTcpServer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -55,5 +57,7 @@ private:
|
|||||||
static QList<MockTcpServer*> s_allServers;
|
static QList<MockTcpServer*> s_allServers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TCPSERVER_H
|
#endif // TCPSERVER_H
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestPlugins: public GuhTestBase
|
class TestPlugins: public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestRules: public GuhTestBase
|
class TestRules: public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestStates: public GuhTestBase
|
class TestStates: public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@ -31,6 +31,8 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
using namespace guhserver;
|
||||||
|
|
||||||
class TestVersioning: public GuhTestBase
|
class TestVersioning: public GuhTestBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
Reference in New Issue
Block a user