add debug categories to each plugin

fix loading vendorId
improoved man page
improoved help message
add extern ids to extern-plugininfo.h
This commit is contained in:
Simon Stürz 2015-06-30 18:57:44 +02:00 committed by Michael Zanetti
parent 515c3c0c2a
commit 37c2d0219d
68 changed files with 226 additions and 245 deletions

54
debian/guhd.1 vendored
View File

@ -1,6 +1,6 @@
.\" Manpage for guhd.
.\" Contact simon.stuerz@guh.guru to correct errors or typos.
.TH man 1 "May 2015" "1.0" "guhd man page"
.TH man 1 "June 2015" "1.1" "guhd man page"
.SH NAME
guhd \- Server for home automation systems
.SH SYNOPSIS
@ -23,8 +23,9 @@ Displays version information.
Run guhd in the foreground, not as daemon.
.TP
\fB\-d\fR, \fB\-\-debug\fR, \fB\<[No\]DebugCategory>\fR
Debug categories to enable. Prefix with \"No\" to disable. Warnings from all
categories will be printed unless explicitly muted with "NoWarnings".
Debug categories to enable. In order to disable a category which is enabled by
default, you can add \"No\" to the category. Warnings from all
categories will be printed unless they are explicitly muted with "NoWarnings".
.RS
.TP
\fBMain\ debug\ categories:\fR
@ -44,42 +45,17 @@ Print the debug messages from logging engine.
Print the debug messages from the rule engine.
.TP
\fBDebug\ categories\ for\ plugins:\fR
.IP \fICommandLauncher\fR\ (default\ disabled)
Print the debug messages from the command launcher device plugin.
.IP \fIDateTime\fR\ (default\ disabled)
Print the debug messages from the date/time device plugin.
.IP \fIEQ-3\fR\ (default\ disabled)
Print the debug messages from eQ-3 device plugin.
.IP \fILgSmartTv\fR\ (default\ disabled)
Print the debug messages from Lg Smart Tv device plugin.
.IP \fIKodi\fR\ (default\ disabled)
Print the debug messages from kodi device plugin.
.IP \fILircd\fR\ (default\ disabled)
Print the debug messages from lircd device plugin.
.IP \fIMailNotification\fR\ (default\ disabled)
Print the debug messages from the mail notification device plugin.
.IP \fIMock\fR\ (default\ disabled)
Print the debug messages from the mock device plugin.
.IP \fIOpenweahtermap\fR\ (default\ disabled)
Print the debug messages from the open weathermap device plugin.
.IP \fIPhilipsHue\fR\ (default\ disabled)
Print the debug messages from the Philips Hue device plugin.
.IP \fIRF433\fR\ (default\ disabled)
Print the debug messages from the RF 433 MHz plugins. Each plugin which uses the RF 433 MHz
hardware resource is in this debug caterogry.
.IP \fITune\fR\ (default\ disabled)
Print the debug messages from the tune device plugin.
.IP \fIUdpCommander\fR\ (default\ disabled)
Print the debug messages from the UPD commander device plugin.
.IP \fIWakeOnLan\fR\ (default\ disabled)
Print the debug messages from the wake on lan device plugin.
.IP \fIWarnings\fR\ (default\ enabled)
Print warnings of all categories.
.IP \fIWemo\fR\ (default\ disabled)
Print the debug messages from the wemo device plugin.
.IP \fIWifiDetector\fR\ (default\ disabled)
Print the debug messages from the WiFi detector device plugin.
Since guh loads the plugins dynamically, the list of supported
plugin debug categories depends on your plugin installation. Please use
the \fB-h\fR command to see which categories are available for your system.
.SH EXAMPLES
.TP
To start guhd in the foreground and read the debug messages from the Hardware:
.IP $ guhd -n -d Hardware
.TP
To start guhd in the foreground, disable debug messages from the DeviceManager
and enable debug messages for JsonRpc and LogEngine:
.IP $ guhd -n -d NoDeviceManager JsonRpc LogEngine
.SH SEE ALSO
Full developer documentation at: <http://dev.guh.guru>
.br

View File

@ -226,18 +226,21 @@ DeviceManager::~DeviceManager()
}
}
QList<QJsonObject> DeviceManager::pluginNames()
QStringList DeviceManager::pluginSearchDirs()
{
QStringList searchDirs;
searchDirs << QCoreApplication::applicationDirPath() + "/../lib/guh/plugins";
searchDirs << QCoreApplication::applicationDirPath() + "/../plugins/";
searchDirs << QCoreApplication::applicationDirPath() + "/../plugins/deviceplugins";
searchDirs << QCoreApplication::applicationDirPath() + "/../../../plugins/deviceplugins";
return searchDirs;
}
QList<QJsonObject> DeviceManager::pluginsMetadata()
{
QList<QJsonObject> pluginList;
foreach (const QString &path, searchDirs) {
foreach (const QString &path, pluginSearchDirs()) {
QDir dir(path);
qCDebug(dcDeviceManager) << "Loading plugins from:" << dir.absolutePath();
foreach (const QString &entry, dir.entryList()) {
QFileInfo fi;
if (entry.startsWith("libguh_deviceplugin") && entry.endsWith(".so")) {
@ -767,13 +770,7 @@ DeviceManager::DeviceError DeviceManager::executeAction(const Action &action)
void DeviceManager::loadPlugins()
{
QStringList searchDirs;
searchDirs << QCoreApplication::applicationDirPath() + "/../lib/guh/plugins";
searchDirs << QCoreApplication::applicationDirPath() + "/../plugins/";
searchDirs << QCoreApplication::applicationDirPath() + "/../plugins/deviceplugins";
searchDirs << QCoreApplication::applicationDirPath() + "/../../../plugins/deviceplugins";
foreach (const QString &path, searchDirs) {
foreach (const QString &path, pluginSearchDirs()) {
QDir dir(path);
qCDebug(dcDeviceManager) << "Loading plugins from:" << dir.absolutePath();
foreach (const QString &entry, dir.entryList()) {
@ -1317,3 +1314,4 @@ DeviceManager::DeviceError DeviceManager::verifyParam(const ParamType &paramType
qCWarning(dcDeviceManager) << "Parameter name" << param.name() << "does not match with ParamType name" << paramType.name();
return DeviceErrorInvalidParameter;
}

View File

@ -88,7 +88,8 @@ public:
explicit DeviceManager(QObject *parent = 0);
~DeviceManager();
static QList<QJsonObject> pluginNames();
static QStringList pluginSearchDirs();
static QList<QJsonObject> pluginsMetadata();
QList<DevicePlugin*> plugins() const;
DevicePlugin* plugin(const PluginId &id) const;
@ -157,7 +158,6 @@ private:
DeviceError verifyParam(const ParamType &paramType, const Param &param);
private:
QHash<VendorId, Vendor> m_supportedVendors;
QHash<VendorId, QList<DeviceClassId> > m_vendorDeviceMap;
QHash<DeviceClassId, DeviceClass> m_supportedDevices;

View File

@ -28,24 +28,3 @@ Q_LOGGING_CATEGORY(dcConnection, "Connection")
Q_LOGGING_CATEGORY(dcJsonRpc, "JsonRpc")
Q_LOGGING_CATEGORY(dcLogEngine, "LogEngine")
// Plugins
#ifdef boblight
Q_LOGGING_CATEGORY(dcBoblight, "Boblight")
#endif
Q_LOGGING_CATEGORY(dcCommandLauncher, "CommandLauncher")
Q_LOGGING_CATEGORY(dcRF433, "RF433")
Q_LOGGING_CATEGORY(dcDateTime, "DateTime")
Q_LOGGING_CATEGORY(dcEQ3, "EQ-3")
Q_LOGGING_CATEGORY(dcLgSmartTv, "LgSmartTv")
Q_LOGGING_CATEGORY(dcLircd, "Lircd")
Q_LOGGING_CATEGORY(dcMailNotification, "MailNotification")
Q_LOGGING_CATEGORY(dcMock, "Mock")
Q_LOGGING_CATEGORY(dcOpenweathermap, "Openweahtermap")
Q_LOGGING_CATEGORY(dcPhilipsHue, "PhilipsHue")
Q_LOGGING_CATEGORY(dcTune, "Tune")
Q_LOGGING_CATEGORY(dcUdpCommander, "UdpCommander")
Q_LOGGING_CATEGORY(dcWakeOnLan, "WakeOnLan")
Q_LOGGING_CATEGORY(dcWemo, "Wemo")
Q_LOGGING_CATEGORY(dcWifiDetector, "WifiDetector")
//Q_LOGGING_CATEGORY(dcKodi, "Kodi")

View File

@ -32,31 +32,4 @@ Q_DECLARE_LOGGING_CATEGORY(dcConnection)
Q_DECLARE_LOGGING_CATEGORY(dcJsonRpc)
Q_DECLARE_LOGGING_CATEGORY(dcLogEngine)
// Plugins
#ifdef boblight
Q_DECLARE_LOGGING_CATEGORY(dcBoblight)
#endif
Q_DECLARE_LOGGING_CATEGORY(dcCommandLauncher)
Q_DECLARE_LOGGING_CATEGORY(dcRF433)
Q_DECLARE_LOGGING_CATEGORY(dcDateTime)
Q_DECLARE_LOGGING_CATEGORY(dcEQ3)
Q_DECLARE_LOGGING_CATEGORY(dcLgSmartTv)
Q_DECLARE_LOGGING_CATEGORY(dcLircd)
Q_DECLARE_LOGGING_CATEGORY(dcMailNotification)
Q_DECLARE_LOGGING_CATEGORY(dcMock)
Q_DECLARE_LOGGING_CATEGORY(dcOpenweathermap)
Q_DECLARE_LOGGING_CATEGORY(dcPhilipsHue)
Q_DECLARE_LOGGING_CATEGORY(dcTune)
Q_DECLARE_LOGGING_CATEGORY(dcUdpCommander)
Q_DECLARE_LOGGING_CATEGORY(dcWakeOnLan)
Q_DECLARE_LOGGING_CATEGORY(dcWemo)
Q_DECLARE_LOGGING_CATEGORY(dcWifiDetector)
//Q_DECLARE_LOGGING_CATEGORY(dcKodi)
#endif // LOGGINGCATEGORYS_H

View File

@ -21,7 +21,7 @@
#include "bobclient.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
#include "libboblight/boblight.h"

View File

@ -50,7 +50,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "loggingcategories.h"
#include "bobclient.h"
#include "plugininfo.h"

View File

@ -1,6 +1,7 @@
{
"name": "Boblight",
"id": "8c5e8d4c-b5ed-4bfe-b30d-35c2790ec100",
"name": "Boblight",
"idName": "Boblight",
"vendors": [
{
"name": "Boblight",

View File

@ -105,7 +105,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>

View File

@ -1,5 +1,6 @@
{
"name": "Application and script launcher",
"idName": "CommandLauncher",
"id": "5d37b796-4872-4eab-a7af-94ca9ddd8199",
"vendors": [
{

View File

@ -50,7 +50,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>
@ -129,10 +128,10 @@ DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, con
// =======================================
// send data to driver
if(transmitData(delay, rawData, repetitions)){
qCDebug(dcRF433) << "transmitted successfully" << pluginName() << device->name() << action.actionTypeId();
qCDebug(dcConrad) << "transmitted successfully" << pluginName() << device->name() << action.actionTypeId();
return DeviceManager::DeviceErrorNoError;
}else{
qCWarning(dcRF433) << "could not transmitt" << pluginName() << device->name() << action.actionTypeId();
qCWarning(dcConrad) << "could not transmitt" << pluginName() << device->name() << action.actionTypeId();
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
}
@ -144,7 +143,7 @@ void DevicePluginConrad::radioData(const QList<int> &rawData)
return;
}
qCDebug(dcRF433) << rawData;
qCDebug(dcConrad) << rawData;
int delay = rawData.first()/10;
QByteArray binCode;
@ -187,5 +186,5 @@ void DevicePluginConrad::radioData(const QList<int> &rawData)
return;
}
qCDebug(dcRF433) << "Conrad: " << binCode.left(binCode.length() - 24) << " ID = " << binCode.right(24);
qCDebug(dcConrad) << "Conrad: " << binCode.left(binCode.length() - 24) << " ID = " << binCode.right(24);
}

View File

@ -1,9 +1,11 @@
{
"name": "Conrad",
"idName": "Conrad",
"id": "1fd1a076-f229-4ec6-b501-48ddd15935e4",
"vendors": [
{
"name": "Conrad Electronic",
"idName": "conrad",
"id": "986cf06f-3ef1-4271-b2a3-2cc277ebecb6",
"deviceClasses": [
{

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "alarm.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
Alarm::Alarm(QObject *parent) :
QObject(parent),

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "countdown.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
Countdown::Countdown(const QString &name, const QTime &time, const bool &repeating, QObject *parent) :
QObject(parent),

View File

@ -101,7 +101,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QJsonDocument>
#include <QUrlQuery>

View File

@ -1,9 +1,11 @@
{
"name": "Time",
"idName": "DateTime",
"id": "c26014c6-87fb-4233-85ed-01d18625018d",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{

View File

@ -47,7 +47,6 @@
#include "devicepluginelro.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>
@ -153,10 +152,10 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const
// send data to hardware resource
if (transmitData(delay, rawData)) {
qCDebug(dcRF433) << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
qCDebug(dcElro) << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
return DeviceManager::DeviceErrorNoError;
} else {
qCWarning(dcRF433) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
qCWarning(dcElro) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
}
@ -208,13 +207,13 @@ void DevicePluginElro::radioData(const QList<int> &rawData)
return;
}
qCDebug(dcRF433) << "ELRO understands this protocol: " << binCode;
qCDebug(dcElro) << "ELRO understands this protocol: " << binCode;
if (binCode.left(20) == "00000100000000000001") {
if (binCode.right(4) == "0100") {
qCDebug(dcRF433) << "Motion Detector OFF";
qCDebug(dcElro) << "Motion Detector OFF";
} else {
qCDebug(dcRF433) << "Motion Detector ON";
qCDebug(dcElro) << "Motion Detector ON";
}
}
@ -258,5 +257,5 @@ void DevicePluginElro::radioData(const QList<int> &rawData)
return;
}
qCDebug(dcRF433) << "Elro:" << group << buttonCode << power;
qCDebug(dcElro) << "Elro:" << group << buttonCode << power;
}

View File

@ -1,9 +1,11 @@
{
"name": "Elro",
"idName": "Elro",
"id": "2b267f81-d9ae-4f4f-89a0-7386b547cfd3",
"vendors": [
{
"name": "Elro",
"idName": "elro",
"id": "435a13a0-65ca-4f0c-94c1-e5873b258db5",
"deviceClasses": [
{

View File

@ -72,7 +72,6 @@
#include "devicemanager.h"
#include "types/param.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>

View File

@ -1,9 +1,11 @@
{
"name": "eQ-3",
"idName": "EQ3",
"id": "f324c43c-9680-48d8-852a-93b2227139b9",
"vendors": [
{
"name": "eQ-3",
"idName": "eq3",
"id": "2cac0645-855e-44fa-837e-1cab0ae4304c",
"deviceClasses": [
{

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "maxcube.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
MaxCube::MaxCube(QObject *parent, QString serialNumber, QHostAddress hostAdress, quint16 port):
QTcpSocket(parent), m_serialNumber(serialNumber), m_hostAddress(hostAdress), m_port(port)

View File

@ -19,6 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "maxcubediscovery.h"
#include "extern-plugininfo.h"
MaxCubeDiscovery::MaxCubeDiscovery(QObject *parent) :
QObject(parent)

View File

@ -19,6 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "maxdevice.h"
#include "extern-plugininfo.h"
MaxDevice::MaxDevice(QObject *parent) :
QObject(parent)

View File

@ -19,6 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "radiatorthermostat.h"
#include "extern-plugininfo.h"
RadiatorThermostat::RadiatorThermostat(QObject *parent) :
MaxDevice(parent)

View File

@ -19,6 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "room.h"
#include "extern-plugininfo.h"
Room::Room(QObject *parent) :
QObject(parent)

View File

@ -19,6 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "wallthermostat.h"
#include "extern-plugininfo.h"
WallThermostat::WallThermostat(QObject *parent) :
MaxDevice(parent)

View File

@ -1,9 +1,11 @@
{
"name": "Generic Elements",
"idName": "GenericElements",
"id": "6e22161e-39b7-4416-8623-39e730721efb",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{

View File

@ -49,7 +49,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>
@ -181,10 +180,10 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device
// =======================================
// send data to hardware resource
if (transmitData(delay, rawData)) {
qCDebug(dcRF433) << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
qCDebug(dcIntertechno) << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
return DeviceManager::DeviceErrorNoError;
} else {
qCWarning(dcRF433) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
qCWarning(dcIntertechno) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
}
@ -384,6 +383,6 @@ void DevicePluginIntertechno::radioData(const QList<int> &rawData)
return;
}
qCDebug(dcRF433) << "Intertechno: family code = " << familyCode << "button code =" << buttonCode << power;
qCDebug(dcIntertechno) << "Intertechno: family code = " << familyCode << "button code =" << buttonCode << power;
}

View File

@ -1,9 +1,11 @@
{
"name": "Intertechno",
"idName": "Intertechno",
"id": "e998d934-0397-42c1-ad63-9141bcac8563",
"vendors": [
{
"name": "Intertechno",
"idName": "intertechno",
"id": "6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba",
"deviceClasses": [
{

View File

@ -68,7 +68,6 @@
#include "devicepluginkodi.h"
#include "plugin/device.h"
#include "plugininfo.h"
#include "loggingcategories.h"
DevicePluginKodi::DevicePluginKodi()
{

View File

@ -1,11 +1,12 @@
{
"id": "e7186890-99fa-4c5b-8247-09c6d450d490",
"name": "Kodi",
"idName": "Kodi",
"id": "e7186890-99fa-4c5b-8247-09c6d450d490",
"vendors": [
{
"name": "Kodi",
"id": "447bf3d6-a86e-4636-9db0-8936c0e4d9e9",
"name": "Kodi",
"idName": "kodi",
"deviceClasses": [
{
"deviceClassId": "d09953e3-c5bd-415b-973b-0d0bf2be3f69",

View File

@ -19,7 +19,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "kodiconnection.h"
#include "loggingcategories.h"
#include "jsonhandler.h"
#include "extern-plugininfo.h"

View File

@ -53,7 +53,6 @@
#include "devicepluginleynew.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>
@ -175,10 +174,10 @@ DeviceManager::DeviceError DevicePluginLeynew::executeAction(Device *device, con
// =======================================
// send data to hardware resource
if(transmitData(delay, rawData, repetitions)){
qCDebug(dcRF433) << "transmitted" << pluginName() << device->name() << action.id();
qCDebug(dcLeynew) << "transmitted" << pluginName() << device->name() << action.id();
return DeviceManager::DeviceErrorNoError;
}else{
qCWarning(dcRF433) << "could not transmitt" << pluginName() << device->name() << action.id();
qCWarning(dcLeynew) << "could not transmitt" << pluginName() << device->name() << action.id();
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
}

View File

@ -1,9 +1,11 @@
{
"name": "Leynew",
"idName": "Leynew",
"id": "9a6d23e6-fad8-4203-aeab-2e6e5c756990",
"vendors": [
{
"name": "Leynew",
"idName": "leynew",
"id": "83c649b4-49b0-4482-9334-d86a85bfbd2a",
"deviceClasses": [
{

View File

@ -49,7 +49,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>

View File

@ -1,9 +1,11 @@
{
"name": "LG Smart Tv",
"idName": "LgSmartTv",
"id": "4ef7a68b-9da0-4c62-b9ac-f478dc6f9f52",
"vendors": [
{
"name": "LG",
"idName": "lg",
"id": "a9af9673-78db-4226-a16b-f34b304f7041",
"deviceClasses": [
{

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "tvdevice.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
TvDevice::TvDevice(const QHostAddress &hostAddress, const int &port, QObject *parent) :
QObject(parent),

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "tveventhandler.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
TvEventHandler::TvEventHandler(const QHostAddress &host, const int &port, QObject *parent) :
QTcpServer(parent),

View File

@ -50,8 +50,7 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "loggingcategories.h"
#include "plugininfo.h"
#include "lircdclient.h"
#include <QDebug>

View File

@ -1,9 +1,11 @@
{
"name": "Lirc receiver",
"idName": "Lircd",
"id": "075f734f-4d76-4ce3-9ef8-34c212285676",
"vendors": [
{
"name": "Lirc",
"idName": "lirc",
"id": "9a53049c-8828-4b87-b3f6-7bc7708196cd",
"deviceClasses": [
{

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "lircdclient.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
#include <QDebug>
#include <QLocalSocket>

View File

@ -67,7 +67,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QJsonDocument>

View File

@ -1,9 +1,11 @@
{
"name": "Mail notification",
"idName": "MailNotification",
"id": "1ae35df1-1b51-4c93-94fa-3febc77e0318",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "smtpclient.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
SmtpClient::SmtpClient(QObject *parent):
QObject(parent)

View File

@ -25,7 +25,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>
@ -47,7 +46,7 @@ DeviceManager::HardwareResources DevicePluginMock::requiredHardware() const
DeviceManager::DeviceError DevicePluginMock::discoverDevices(const DeviceClassId &deviceClassId, const ParamList &params)
{
Q_UNUSED(deviceClassId)
qCDebug(dcMock) << "starting mock discovery:" << params;
qCDebug(dcMockDevice) << "starting mock discovery:" << params;
m_discoveredDeviceCount = params.paramValue("resultCount").toInt();
QTimer::singleShot(1000, this, SLOT(emitDevicesDiscovered()));
return DeviceManager::DeviceErrorAsync;
@ -55,14 +54,14 @@ DeviceManager::DeviceError DevicePluginMock::discoverDevices(const DeviceClassId
DeviceManager::DeviceSetupStatus DevicePluginMock::setupDevice(Device *device)
{
qCDebug(dcMock) << "Mockdevice created returning true"
qCDebug(dcMockDevice) << "Mockdevice created returning true"
<< device->paramValue("name").toString()
<< device->paramValue("httpport").toInt()
<< device->paramValue("async").toBool()
<< device->paramValue("broken").toBool();
if (device->paramValue("broken").toBool()) {
qCWarning(dcMock) << "This device is intentionally broken.";
qCWarning(dcMockDevice) << "This device is intentionally broken.";
return DeviceManager::DeviceSetupStatusFailure;
}
@ -70,7 +69,7 @@ DeviceManager::DeviceSetupStatus DevicePluginMock::setupDevice(Device *device)
m_daemons.insert(device, daemon);
if (!daemon->isListening()) {
qCWarning(dcMock) << "HTTP port opening failed.";
qCWarning(dcMockDevice) << "HTTP port opening failed.";
return DeviceManager::DeviceSetupStatusFailure;
}
@ -168,7 +167,7 @@ void DevicePluginMock::triggerEvent(const EventTypeId &id)
Event event(id, device->id());
qCDebug(dcMock) << "Emitting event " << event.eventTypeId();
qCDebug(dcMockDevice) << "Emitting event " << event.eventTypeId();
emit emitEvent(event);
}
@ -203,7 +202,7 @@ void DevicePluginMock::emitDevicesDiscovered()
void DevicePluginMock::emitDeviceSetupFinished()
{
qCDebug(dcMock) << "emitting setup finised";
qCDebug(dcMockDevice) << "emitting setup finised";
Device *device = m_asyncSetupDevices.takeFirst();
if (device->paramValue("broken").toBool()) {
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure);

View File

@ -1,9 +1,11 @@
{
"name": "Mock Devices",
"idName": "MockDevice",
"id": "727a4a9a-c187-446f-aadf-f1b2220607d1",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{

View File

@ -25,7 +25,7 @@
#include "plugin/deviceclass.h"
#include "plugin/deviceplugin.h"
#include "types/statetype.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
#include <QTcpSocket>
#include <QDebug>
@ -114,7 +114,7 @@ void HttpDaemon::discardClient()
QTcpSocket* socket = (QTcpSocket*)sender();
socket->deleteLater();
qCDebug(dcMock) << "Connection closed";
qCDebug(dcMockDevice) << "Connection closed";
}
QString HttpDaemon::generateHeader()

View File

@ -56,7 +56,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QJsonDocument>
@ -130,7 +129,7 @@ void DevicePluginOpenweathermap::deviceRemoved(Device *device)
void DevicePluginOpenweathermap::networkManagerReplyReady(QNetworkReply *reply)
{
if (reply->error()) {
qCWarning(dcOpenweathermap) << "OpenWeatherMap reply error: " << reply->errorString();
qCWarning(dcOpenWeatherMap) << "OpenWeatherMap reply error: " << reply->errorString();
}
if (m_autodetectionReplies.contains(reply)) {
@ -219,7 +218,7 @@ void DevicePluginOpenweathermap::processAutodetectResponse(QByteArray data)
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
if(error.error != QJsonParseError::NoError) {
qCWarning(dcOpenweathermap) << "failed to parse data" << data << ":" << error.errorString();
qCWarning(dcOpenWeatherMap) << "failed to parse data" << data << ":" << error.errorString();
}
// search by geographic coordinates
@ -236,15 +235,15 @@ void DevicePluginOpenweathermap::processAutodetectResponse(QByteArray data)
if (dataMap.contains("lon") && dataMap.contains("lat")) {
m_longitude = dataMap.value("lon").toDouble();
m_latitude = dataMap.value("lat").toDouble();
qCDebug(dcOpenweathermap) << "----------------------------------------";
qCDebug(dcOpenweathermap) << "Autodetection of location: ";
qCDebug(dcOpenweathermap) << "----------------------------------------";
qCDebug(dcOpenweathermap) << " name:" << m_cityName;
qCDebug(dcOpenweathermap) << " country:" << m_country;
qCDebug(dcOpenweathermap) << " WAN IP:" << m_wanIp.toString();
qCDebug(dcOpenweathermap) << " latitude:" << m_latitude;
qCDebug(dcOpenweathermap) << " longitude:" << m_longitude;
qCDebug(dcOpenweathermap) << "----------------------------------------";
qCDebug(dcOpenWeatherMap) << "----------------------------------------";
qCDebug(dcOpenWeatherMap) << "Autodetection of location: ";
qCDebug(dcOpenWeatherMap) << "----------------------------------------";
qCDebug(dcOpenWeatherMap) << " name:" << m_cityName;
qCDebug(dcOpenWeatherMap) << " country:" << m_country;
qCDebug(dcOpenWeatherMap) << " WAN IP:" << m_wanIp.toString();
qCDebug(dcOpenWeatherMap) << " latitude:" << m_latitude;
qCDebug(dcOpenWeatherMap) << " longitude:" << m_longitude;
qCDebug(dcOpenWeatherMap) << "----------------------------------------";
searchGeoLocation(m_latitude, m_longitude);
}
}
@ -255,7 +254,7 @@ void DevicePluginOpenweathermap::processSearchResponse(QByteArray data)
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
if(error.error != QJsonParseError::NoError) {
qCWarning(dcOpenweathermap) << "failed to parse data" << data << ":" << error.errorString();
qCWarning(dcOpenWeatherMap) << "failed to parse data" << data << ":" << error.errorString();
}
QVariantMap dataMap = jsonDoc.toVariant().toMap();
@ -280,7 +279,7 @@ void DevicePluginOpenweathermap::processGeoSearchResponse(QByteArray data)
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
if(error.error != QJsonParseError::NoError) {
qCWarning(dcOpenweathermap) << "failed to parse data" << data << ":" << error.errorString();
qCWarning(dcOpenWeatherMap) << "failed to parse data" << data << ":" << error.errorString();
}
QVariantMap dataMap = jsonDoc.toVariant().toMap();
@ -327,7 +326,7 @@ void DevicePluginOpenweathermap::processWeatherData(const QByteArray &data, Devi
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(dcOpenweathermap) << "failed to parse weather data for device " << device->name() << ": " << data << ":" << error.errorString();
qCWarning(dcOpenWeatherMap) << "failed to parse weather data for device " << device->name() << ": " << data << ":" << error.errorString();
return;
}

View File

@ -1,9 +1,11 @@
{
"name": "OpenWeatherMap",
"idName": "OpenWeatherMap",
"id": "bc6af567-2338-41d5-aac1-462dec6e4783",
"vendors": [
{
"name": "OpenWeatherMap",
"idName": "openWeatherMap",
"id": "bf1e96f0-9650-4e7c-a56c-916d54d18e7a",
"deviceClasses": [
{

View File

@ -51,7 +51,6 @@
#include "plugin/device.h"
#include "types/param.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>

View File

@ -1,10 +1,12 @@
{
"name": "Philips Hue",
"idName": "PhilipsHue",
"id": "5f2e634b-b7f3-48ee-976a-b5ae22aa5c55",
"vendors": [
{
"id": "0ae1e001-2aa6-47ed-b8c0-334c3728a68f",
"name": "Philips",
"idName": "philips",
"deviceClasses": [
{
"deviceClassId": "642aa4c7-19aa-45ed-ba06-aa1ae6c9edf7",

View File

@ -20,6 +20,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "huelight.h"
#include "extern-plugininfo.h"
HueLight::HueLight(const int &lightId, const QHostAddress &hostAddress, const QString &name, const QString &apiKey, const QString &modelId, const DeviceId &bridgeId, QObject *parent) :
QObject(parent),

View File

@ -25,7 +25,6 @@
#include "deviceplugintune.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
DevicePluginTune::DevicePluginTune()
{

View File

@ -1,9 +1,11 @@
{
"name": "Tune",
"idName": "Tune",
"id": "826c8f4a-e2e1-4891-84d4-2c7a46ab1eea",
"vendors": [
{
"name": "Tune",
"idName": "tune",
"id": "9ba2d9dc-b975-46bb-9e83-dbbd03ccab6c",
"deviceClasses": [
{

View File

@ -19,24 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "jsonrpcserver.h"
#include "loggingcategories.h"
extern PluginId pluginId;
extern DeviceClassId moodDeviceClassId;
extern StateTypeId activeStateTypeId;
extern ActionTypeId activeActionTypeId;
extern StateTypeId valueStateTypeId;
extern ActionTypeId valueActionTypeId;
extern DeviceClassId tuneDeviceClassId;
extern StateTypeId reachableStateTypeId;
extern StateTypeId approximationDetectedStateTypeId;
extern StateTypeId temperatureStateTypeId;
extern StateTypeId humidityStateTypeId;
extern StateTypeId lightIntensityStateTypeId;
extern StateTypeId powerStateTypeId;
extern ActionTypeId powerActionTypeId;
extern StateTypeId brightnessStateTypeId;
extern ActionTypeId brightnessActionTypeId;
#include "extern-plugininfo.h"
JsonRpcServer::JsonRpcServer(QObject *parent) :
QObject(parent),

View File

@ -19,7 +19,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "tunemanager.h"
#include "loggingcategories.h"
#include "extern-plugininfo.h"
TuneManager::TuneManager(int port, QObject *parent) :
QObject(parent),

View File

@ -65,7 +65,6 @@
#include "devicepluginudpcommander.h"
#include "plugin/device.h"
#include "plugininfo.h"
#include "loggingcategories.h"
DevicePluginUdpCommander::DevicePluginUdpCommander()
{

View File

@ -1,9 +1,11 @@
{
"name": "UDP Commander",
"idName": "UdpCommander",
"id": "24a8474c-1d86-499e-a76e-9cbfbf48dd72",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{

View File

@ -47,7 +47,6 @@
#include "devicepluginunitec.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>
@ -69,7 +68,7 @@ DeviceManager::DeviceSetupStatus DevicePluginUnitec::setupDevice(Device *device)
foreach (Device* d, myDevices()) {
if (d->paramValue("Channel").toString() == device->paramValue("Channel").toString()) {
qCWarning(dcRF433) << "Unitec switch with channel " << device->paramValue("Channel").toString() << "already added.";
qCWarning(dcUnitec) << "Unitec switch with channel " << device->paramValue("Channel").toString() << "already added.";
return DeviceManager::DeviceSetupStatusFailure;
}
}
@ -129,10 +128,10 @@ DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, con
// =======================================
// send data to hardware resource
if(transmitData(delay, rawData)){
qCDebug(dcRF433) << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
qCDebug(dcUnitec) << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
return DeviceManager::DeviceErrorNoError;
}else{
qCWarning(dcRF433) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
qCWarning(dcUnitec) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
}

View File

@ -1,9 +1,11 @@
{
"name": "Unitec",
"idName": "Unitec",
"id": "aefca391-f8bf-4f6c-a205-6764de3c2c3c",
"vendors": [
{
"name": "Unitec",
"idName": "unitec",
"id": "f2cd9a76-5a7f-4c01-bf8c-5eae8b12e95c",
"deviceClasses": [
{

View File

@ -53,7 +53,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>

View File

@ -1,9 +1,11 @@
{
"name": "Wake on Lan",
"idName": "WakeOnLan",
"id": "b5a87848-de56-451e-84a6-edd26ad4958f",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{

View File

@ -53,7 +53,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QNetworkReply>

View File

@ -1,9 +1,11 @@
{
"name": "Wemo",
"idName": "Wemo",
"id": "2e3b5ce0-ecf1-43de-98f0-07df4068a583",
"vendors": [
{
"name": "Belkin",
"idName": "belkin",
"id": "b241f7f5-8153-4a72-b260-f62beadc2d19",
"deviceClasses": [
{

View File

@ -52,7 +52,6 @@
#include "plugin/device.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include "loggingcategories.h"
#include <QDebug>
#include <QStringList>

View File

@ -1,9 +1,11 @@
{
"name": "WiFi Detector",
"idName": "WifiDetector",
"id": "8e0f791e-b273-4267-8605-b7c2f55a68ab",
"vendors": [
{
"name": "guh",
"idName": "guh",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{

View File

@ -8,26 +8,30 @@ inputFile = open(sys.argv[1], "r")
outputfile = open(sys.argv[2], "w")
outputfile2 = open("extern-" + sys.argv[2], "w")
variableNames = []
externDefinitions = []
try:
pluginMap = json.loads(inputFile.read())
except ValueError as e:
print " --> Error loading input file \"%s\"" % (sys.argv[1])
print " %s" % (e)
exit -1
def out(line):
def writePluginInfo(line):
outputfile.write("%s\n" % line)
def out2(line):
def writeExternPluginInfo(line):
outputfile2.write("%s\n" % line)
def extractVendors(pluginMap):
for vendor in pluginMap['vendors']:
try:
out("VendorId %sVendorId = VendorId(\"%s\");" % pluginMap["idName"], pluginMap["id"])
print("define VendorId %sVendorId = %s" % (pluginMap["idName"], vendor["id"]))
writePluginInfo("VendorId %sVendorId = VendorId(\"%s\");" % (vendor["idName"], vendor["id"]))
createExternDefinition("VendorId", "%sVendorId" % (vendor["idName"]))
except:
pass
extractDeviceClasses(vendor)
@ -35,12 +39,13 @@ def extractVendors(pluginMap):
def extractDeviceClasses(vendorMap):
for deviceClass in vendorMap["deviceClasses"]:
print("have deviceclass %s" % deviceClass["deviceClassId"])
try:
variableName = "%sDeviceClassId" % (deviceClass["idName"])
if not variableName in variableNames:
variableNames.append(variableName)
out("DeviceClassId %s = DeviceClassId(\"%s\");" % (variableName, deviceClass["deviceClassId"]))
print("define DeviceClassId %s = %s" % (variableName, deviceClass["deviceClassId"]))
writePluginInfo("DeviceClassId %s = DeviceClassId(\"%s\");" % (variableName, deviceClass["deviceClassId"]))
createExternDefinition("DeviceClassId", variableName)
else:
print("duplicated variable name \"%s\" for DeviceClassId %s -> skipping") % (variableName, deviceClass["deviceClassId"])
except:
@ -57,16 +62,19 @@ def extractStateTypes(deviceClassMap):
variableName = "%sStateTypeId" % (stateType["idName"])
if not variableName in variableNames:
variableNames.append(variableName)
out("StateTypeId %s = StateTypeId(\"%s\");" % (variableName, stateType["id"]))
print("define StateTypeId %s = %s" % (variableName, stateType["id"]))
writePluginInfo("StateTypeId %s = StateTypeId(\"%s\");" % (variableName, stateType["id"]))
createExternDefinition("StateTypeId", variableName)
else:
print("duplicated variable name \"%s\" for StateTypeId %s -> skipping") % (variableName, stateType["id"])
# create ActionTypeId if the state is writable
if 'writable' in stateType:
print("create ActionTypeId for StateType %s" % stateType["id"])
vName = "%sActionTypeId" % (stateType["idName"])
if not vName in variableNames:
variableNames.append(vName)
out("ActionTypeId %s = ActionTypeId(\"%s\");" % (vName, stateType["id"]))
print("define ActionTypeId %s for writable StateType %s = %s" % (vName, variableName, stateType["id"]))
writePluginInfo("ActionTypeId %s = ActionTypeId(\"%s\");" % (vName, stateType["id"]))
createExternDefinition("ActionTypeId", vName)
else:
print("duplicated variable name \"%s\" for ActionTypeId %s -> skipping") % (variableName, stateType["id"])
except:
@ -82,7 +90,8 @@ def extractActionTypes(deviceClassMap):
variableName = "%sActionTypeId" % (actionType["idName"])
if not variableName in variableNames:
variableNames.append(variableName)
out("ActionTypeId %s = ActionTypeId(\"%s\");" % (variableName, actionType["id"]))
writePluginInfo("ActionTypeId %s = ActionTypeId(\"%s\");" % (variableName, actionType["id"]))
createExternDefinition("ActionTypeId", variableName)
else:
print("duplicated variable name \"%s\" for ActionTypeId %s -> skipping") % (variableName, actionType["id"])
except:
@ -98,7 +107,8 @@ def extractEventTypes(deviceClassMap):
variableName = "%sEventTypeId" % (eventType["idName"])
if not variableName in variableNames:
variableNames.append(variableName)
out("EventTypeId %s = EventTypeId(\"%s\");" % (variableName, eventType["id"]))
writePluginInfo("EventTypeId %s = EventTypeId(\"%s\");" % (variableName, eventType["id"]))
createExternDefinition("EventTypeId", variableName)
else:
print("duplicated variable name \"%s\" for EventTypeId %s -> skipping") % (variableName, eventType["id"])
except:
@ -106,52 +116,74 @@ def extractEventTypes(deviceClassMap):
except:
pass
def createExternDefinition(type, name):
definition = {}
definition['type'] = type
definition['variable'] = name
externDefinitions.append(definition)
##################################################################################################################
# write plugininfo.h
print " --> generate plugininfo.h"
print "PluginId for plugin \"%s\" = %s" %(pluginMap['name'], pluginMap['id'])
# write header
out("/* This file is generated by the guh build system. Any changes to this file will")
out(" * be lost.")
out(" *")
out(" * If you want to change this file, edit the plugin's json file and add")
out(" * idName tags where appropriate.")
out(" */")
out("#ifndef PLUGININFO_H")
out("#define PLUGININFO_H")
out("#include \"typeutils.h\"")
out("#include <QLoggingCategory>")
out("")
out("PluginId pluginId = PluginId(\"%s\");" % pluginMap['id'])
writePluginInfo("/* This file is generated by the guh build system. Any changes to this file will")
writePluginInfo(" * be lost.")
writePluginInfo(" *")
writePluginInfo(" * If you want to change this file, edit the plugin's json file and add")
writePluginInfo(" * idName tags where appropriate.")
writePluginInfo(" */")
writePluginInfo("")
writePluginInfo("#ifndef PLUGININFO_H")
writePluginInfo("#define PLUGININFO_H")
writePluginInfo("#include \"typeutils.h\"")
writePluginInfo("#include <QLoggingCategory>")
writePluginInfo("")
writePluginInfo("// Id definitions")
writePluginInfo("PluginId pluginId = PluginId(\"%s\");" % pluginMap['id'])
extractVendors(pluginMap)
out("")
writePluginInfo("")
writePluginInfo("// Loging category")
if 'idName' in pluginMap:
out("Q_DECLARE_LOGGING_CATEGORY(dc%s)" % pluginMap['idName'])
out("Q_LOGGING_CATEGORY(dc%s, \"dc%s\")" % (pluginMap['idName'], pluginMap['idName']))
out("")
out("#endif")
writePluginInfo("Q_DECLARE_LOGGING_CATEGORY(dc%s)" % pluginMap['idName'])
writePluginInfo("Q_LOGGING_CATEGORY(dc%s, \"%s\")" % (pluginMap['idName'], pluginMap['idName']))
print "define logging category: \"dc%s\"" % pluginMap['idName']
writePluginInfo("")
writePluginInfo("#endif // PLUGININFO_H")
print " --> generated successfully \"%s\"" % sys.argv[2]
out2("/* This file is generated by the guh build system. Any changes to this file will")
out2(" * be lost.")
out2(" *")
out2(" * If you want to change this file, edit the plugin's json file and add")
out2(" * idName tags where appropriate.")
out2(" */")
out2("#ifndef PLUGININFO_H")
out2("#define PLUGININFO_H")
out2("#include \"typeutils.h\"")
out2("#include <QLoggingCategory>")
out2("")
##################################################################################################################
# write extern-plugininfo.h
print " --> generate extern-plugininfo.h"
writeExternPluginInfo("/* This file is generated by the guh build system. Any changes to this file will")
writeExternPluginInfo(" * be lost.")
writeExternPluginInfo(" *")
writeExternPluginInfo(" * If you want to change this file, edit the plugin's json file and add")
writeExternPluginInfo(" * idName tags where appropriate.")
writeExternPluginInfo(" */")
writeExternPluginInfo("")
writeExternPluginInfo("#ifndef EXTERNPLUGININFO_H")
writeExternPluginInfo("#define EXTERNPLUGININFO_H")
writeExternPluginInfo("#include \"typeutils.h\"")
writeExternPluginInfo("#include <QLoggingCategory>")
writeExternPluginInfo("")
writeExternPluginInfo("// Id definitions")
for externDefinition in externDefinitions:
writeExternPluginInfo("extern %s %s;" % (externDefinition['type'], externDefinition['variable']))
writeExternPluginInfo("")
writeExternPluginInfo("// Logging category definition")
if 'idName' in pluginMap:
out2("Q_DECLARE_LOGGING_CATEGORY(dc%s)" % pluginMap['idName'])
out2("")
out2("#endif")
writeExternPluginInfo("Q_DECLARE_LOGGING_CATEGORY(dc%s)" % pluginMap['idName'])
writeExternPluginInfo("")
writeExternPluginInfo("#endif // EXTERNPLUGININFO_H")
print " --> finished writing \"%s\"" % (sys.argv[2])
print " --> generated successfully \"extern-%s\"" % (sys.argv[2])

View File

@ -46,13 +46,12 @@ void loggingCategoryFilter(QLoggingCategory *category)
int main(int argc, char *argv[])
{
//qInstallMessageHandler(myMessageOutput);
QCoreApplication application(argc, argv);
application.setOrganizationName("guh");
application.setApplicationName("guhd");
application.setApplicationVersion(GUH_VERSION_STRING);
// filter for core and libguh
// logging filers for core and libguh
s_loggingFilters.insert("Application", true);
s_loggingFilters.insert("Warnings", true);
s_loggingFilters.insert("DeviceManager", true);
@ -62,8 +61,9 @@ int main(int argc, char *argv[])
s_loggingFilters.insert("Hardware", false);
s_loggingFilters.insert("LogEngine", false);
foreach (const QJsonObject &object, DeviceManager::pluginNames()) {
s_loggingFilters.insert("dc" + object.value("idName").toString(), false);
QHash<QString, bool> loggingFiltersPlugins;
foreach (const QJsonObject &pluginMetadata, DeviceManager::pluginsMetadata()) {
loggingFiltersPlugins.insert(pluginMetadata.value("idName").toString(), false);
}
QCommandLineParser parser;
@ -72,7 +72,8 @@ int main(int argc, char *argv[])
QString applicationDescription = QString("\nguh ( /[guːh]/ ) is an open source home automation server, which allows to\n"
"control a lot of different devices from many different manufacturers.\n\n"
"guhd %1 (C) 2014-2015 guh\n"
"Released under the GNU GENERAL PUBLIC LICENSE Version 2.").arg(GUH_VERSION_STRING);
"Released under the GNU GENERAL PUBLIC LICENSE Version 2.\n\n"
"API version: %2\n").arg(GUH_VERSION_STRING).arg(JSON_PROTOCOL_VERSION);
parser.setApplicationDescription(applicationDescription);
@ -80,16 +81,30 @@ int main(int argc, char *argv[])
parser.addOption(foregroundOption);
QString debugDescription = QString("Debug categories to enable. Prefix with \"No\" to disable. Warnings from all categories will be printed unless explicitly muted with \"NoWarnings\". \n\nCategories are:");
// create sorted loggingFiler list
QStringList sortedFilterList = QStringList(s_loggingFilters.keys());
sortedFilterList.sort();
foreach (const QString &filterName, sortedFilterList) {
debugDescription += "\n- " + filterName + " (" + (s_loggingFilters.value(filterName) ? "yes" : "no") + ")";
}
// create sorted plugin loggingFiler list
QStringList sortedPluginList = QStringList(loggingFiltersPlugins.keys());
sortedPluginList.sort();
debugDescription += "\n\nPlugin categories:\n";
foreach (const QString &filterName, sortedPluginList) {
debugDescription += "\n- " + filterName + " (" + (s_loggingFilters.value(filterName) ? "yes" : "no") + ")";
}
QCommandLineOption debugOption(QStringList() << "d" << "debug", debugDescription, "[No]DebugCategory");
parser.addOption(debugOption);
parser.process(application);
// add plugin metadata to the static hash
foreach (const QString &category, loggingFiltersPlugins.keys()) {
s_loggingFilters.insert(category, false);
}
// check debug area
foreach (QString debugArea, parser.values(debugOption)) {
bool enable = !debugArea.startsWith("No");