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