IPv6 support (#1369)

* hyperion-remote - Support IPv6

* LEDDevices - Remove IPv6 limitations

* Separate JsonEditorHostValidation

* Standalone grabbers & JSON/Flatbuffer forwarder: IPv6 support

* remote: Fix setting multiple colors via Hex, add standard logging

* IPv6 Updates -Add db migration activities

* Addressing non-Windows compile issues

* Code cleanup, address clang feedback

* Update address (hostname, IPv4/IPv6) help text

* Apply migration steps to "old" configurations imported

* Show user the UI-Url, if hyperion is already running, address clang findings

* Windows Cmake OpenSLL output

* Minor Text update
This commit is contained in:
LordGrey
2021-11-17 20:30:43 +00:00
committed by GitHub
parent b33466d392
commit ad293b2fb6
61 changed files with 1714 additions and 926 deletions

View File

@@ -11,6 +11,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
#include <utils/DefaultSignalHandler.h>
@@ -53,7 +54,7 @@ int main(int argc, char ** argv)
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -122,8 +123,17 @@ int main(int argc, char ** argv)
}
}
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ FLATBUFFER_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("AML Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
FlatBufferConnection flatbuf("AML Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&amlWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -12,6 +12,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
#include <utils/DefaultSignalHandler.h>
@@ -54,7 +55,7 @@ int main(int argc, char ** argv)
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -124,8 +125,18 @@ int main(int argc, char ** argv)
address = argAddress.value(parser);
}
}
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ FLATBUFFER_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("Dispmanx Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
FlatBufferConnection flatbuf("Dispmanx Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&dispmanxWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -11,6 +11,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
#include <utils/DefaultSignalHandler.h>
@@ -55,7 +56,7 @@ int main(int argc, char ** argv)
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -125,8 +126,17 @@ int main(int argc, char ** argv)
}
}
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ FLATBUFFER_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("Framebuffer Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
FlatBufferConnection flatbuf("Framebuffer Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&fbWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -10,6 +10,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
#include <utils/DefaultSignalHandler.h>
@@ -49,7 +50,7 @@ int main(int argc, char ** argv)
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -119,8 +120,17 @@ int main(int argc, char ** argv)
}
}
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ FLATBUFFER_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("OSX Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
FlatBufferConnection flatbuf("OSX Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&osxWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -15,6 +15,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
using namespace commandline;
@@ -56,7 +57,7 @@ int main(int argc, char ** argv)
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -126,8 +127,17 @@ int main(int argc, char ** argv)
}
}
// Resolve hostname and port (or use default port)
QString host;
quint16 port { FLATBUFFER_DEFAULT_PORT };
if ( !NetUtils::resolveHostPort(address, host, port) )
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("Qt Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
FlatBufferConnection flatbuf("Qt Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&qtWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -10,6 +10,7 @@
#include <QJsonArray>
#include <QJsonDocument>
#include <QHostInfo>
#include <QUrl>
// hyperion-remote includes
#include "JsonConnection.h"
@@ -17,31 +18,17 @@
// util includes
#include <utils/JsonUtils.h>
JsonConnection::JsonConnection(const QString & address, bool printJson)
JsonConnection::JsonConnection(const QString & host, bool printJson , quint16 port)
: _printJson(printJson)
, _log(Logger::getInstance("REMOTE"))
, _socket()
{
QStringList parts = address.split(":");
if (parts.size() != 2)
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
bool ok;
uint16_t port = parts[1].toUShort(&ok);
if (!ok)
{
throw std::runtime_error(QString("Wrong address: Unable to parse the port number (%1)").arg(parts[1]).toStdString());
}
_socket.connectToHost(parts[0], port);
_socket.connectToHost(host, port);
if (!_socket.waitForConnected())
{
throw std::runtime_error("Unable to connect to host");
throw std::runtime_error(QString("Unable to connect to host (%1), port (%2)").arg(host).arg(port).toStdString());
}
qDebug() << "Connected to:" << address;
Debug(_log, "Connected to: %s, port: %u", QSTRING_CSTR(host), port);
}
JsonConnection::~JsonConnection()
@@ -51,7 +38,7 @@ JsonConnection::~JsonConnection()
void JsonConnection::setColor(std::vector<QColor> colors, int priority, int duration)
{
qDebug() << "Set color to " << colors[0].red() << " " << colors[0].green() << " " << colors[0].blue() << (colors.size() > 1 ? " + ..." : "");
Debug(_log, "Set color to [%d,%d,%d] %s", colors[0].red(), colors[0].green(), colors[0].blue(), (colors.size() > 1 ? " + ..." : ""));
// create command
QJsonObject command;
@@ -81,7 +68,7 @@ void JsonConnection::setColor(std::vector<QColor> colors, int priority, int dura
void JsonConnection::setImage(QImage &image, int priority, int duration)
{
qDebug() << "Set image has size: " << image.width() << "x" << image.height();
Debug(_log, "Set image has size: %dx%d", image.width(), image.height());
// ensure the image has RGB888 format
image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
@@ -121,7 +108,7 @@ void JsonConnection::setImage(QImage &image, int priority, int duration)
void JsonConnection::setEffect(const QString &effectName, const QString & effectArgs, int priority, int duration)
{
qDebug() << "Start effect " << effectName;
Debug(_log, "Start effect: %s", QSTRING_CSTR(effectName));
// create command
QJsonObject command, effect;
@@ -157,7 +144,7 @@ void JsonConnection::setEffect(const QString &effectName, const QString & effect
void JsonConnection::createEffect(const QString &effectName, const QString &effectScript, const QString & effectArgs)
{
qDebug() << "Create effect " << effectName;
Debug(_log, "Create effect: %s", QSTRING_CSTR(effectName));
// create command
QJsonObject effect;
@@ -185,7 +172,7 @@ void JsonConnection::createEffect(const QString &effectName, const QString &effe
void JsonConnection::deleteEffect(const QString &effectName)
{
qDebug() << "Delete effect configuration" << effectName;
Debug(_log, "Delete effect configuration: %s", QSTRING_CSTR(effectName));
// create command
QJsonObject effect;
@@ -208,7 +195,7 @@ QString JsonConnection::getServerInfoString()
QJsonObject JsonConnection::getServerInfo()
{
qDebug() << "Get server info";
Debug(_log, "Get server info");
// create command
QJsonObject command;
@@ -233,7 +220,7 @@ QJsonObject JsonConnection::getServerInfo()
QString JsonConnection::getSysInfo()
{
qDebug() << "Get system info";
Debug(_log, "Get system info");
// create command
QJsonObject command;
@@ -260,7 +247,7 @@ QString JsonConnection::getSysInfo()
void JsonConnection::clear(int priority)
{
qDebug() << "Clear priority channel " << priority;
Debug(_log, "Clear priority channel [%d]", priority);
// create command
QJsonObject command;
@@ -276,7 +263,7 @@ void JsonConnection::clear(int priority)
void JsonConnection::clearAll()
{
qDebug() << "Clear all priority channels";
Debug(_log, "Clear all priority channels");
// create command
QJsonObject command;
@@ -292,7 +279,7 @@ void JsonConnection::clearAll()
void JsonConnection::setComponentState(const QString & component, bool state)
{
qDebug() << (state ? "Enable" : "Disable") << "Component" << component;
Debug(_log, "%s Component: %s", (state ? "Enable" : "Disable"), QSTRING_CSTR(component));
// create command
QJsonObject command, parameter;
@@ -339,7 +326,7 @@ void JsonConnection::setSourceAutoSelect()
QString JsonConnection::getConfig(std::string type)
{
assert( type == "schema" || type == "config" );
qDebug() << "Get configuration file from Hyperion Server";
Debug(_log, "Get configuration file from Hyperion Server");
// create command
QJsonObject command;
@@ -408,7 +395,7 @@ void JsonConnection::setAdjustment(
int *brightness,
int *brightnessC)
{
qDebug() << "Set color adjustments";
Debug(_log, "Set color adjustments");
// create command
QJsonObject command, adjust;

View File

@@ -9,6 +9,8 @@
//forward class decl
class Logger;
const int JSON_DEFAULT_PORT = 19444;
///
/// Connection class to setup an connection to the hyperion server and execute commands
///
@@ -18,10 +20,11 @@ public:
///
/// Constructor
///
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
/// @param address The hostname or IP-address of the Hyperion JSON-server (for example "192.168.0.32")
/// @param address The port of the Hyperion JSON-server (default port = 19444)
/// @param printJson Boolean indicating if the sent and received json is written to stdout
///
JsonConnection(const QString & address, bool printJson);
JsonConnection(const QString& host, bool printJson, quint16 port = JSON_DEFAULT_PORT);
///
/// Destructor

View File

@@ -9,14 +9,16 @@
#include <QCoreApplication>
#include <QLocale>
#include "HyperionConfig.h"
#include <commandline/Parser.h>
// hyperion-remote include
#include "JsonConnection.h"
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
#include "HyperionConfig.h"
#include <commandline/Parser.h>
#include <utils/DefaultSignalHandler.h>
using namespace commandline;
@@ -66,6 +68,10 @@ int main(int argc, char * argv[])
#ifndef _WIN32
setenv("AVAHI_COMPAT_NOWARN", "1", 1);
#endif
Logger* log = Logger::getInstance("REMOTE");
Logger::setLogLevel(Logger::INFO);
std::cout
<< "hyperion-remote:" << std::endl
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
@@ -87,8 +93,8 @@ int main(int argc, char * argv[])
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// art variable definition append art to Parser short-, long option description, optional default value //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Option & argAddress = parser.add<Option> ('a', "address" , "Set the address of the hyperion server [default: %1]", "127.0.0.1:19444");
Option & argToken = parser.add<Option> ('t', "token " , "If authorization tokens are required, this token is used");
Option & argAddress = parser.add<Option> ('a', "address" , "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
Option & argToken = parser.add<Option> ('t', "token" , "If authorization tokens are required, this token is used");
Option & argInstance = parser.add<Option> ('I', "instance" , "Select a specific target instance by name for your command. By default it uses always the first instance");
IntOption & argPriority = parser.add<IntOption> ('p', "priority" , "Used to the provided priority channel (suggested 2-99) [default: %1]", "50");
IntOption & argDuration = parser.add<IntOption> ('d', "duration" , "Specify how long the LEDs should be switched on in milliseconds [default: infinity]");
@@ -111,8 +117,6 @@ int main(int argc, char * argv[])
IntOption & argBacklightThreshold = parser.add<IntOption> ('n', "backlightThreshold" , "threshold for activating backlight (minimum brightness)");
IntOption & argBacklightColored = parser.add<IntOption> (0x0, "backlightColored" , "0 = white backlight; 1 = colored backlight");
DoubleOption & argGamma = parser.add<DoubleOption> ('g', "gamma" , "Set the overall gamma of the LEDs");
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print" , "Print the JSON input and output messages on stdout");
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help" , "Show this help message and exit");
ColorOption & argRAdjust = parser.add<ColorOption> ('R', "redAdjustment" , "Set the adjustment of the red color (requires colors in hex format as RRGGBB)");
ColorOption & argGAdjust = parser.add<ColorOption> ('G', "greenAdjustment" , "Set the adjustment of the green color (requires colors in hex format as RRGGBB)");
ColorOption & argBAdjust = parser.add<ColorOption> ('B', "blueAdjustment" , "Set the adjustment of the blue color (requires colors in hex format as RRGGBB)");
@@ -131,9 +135,19 @@ int main(int argc, char * argv[])
BooleanOption & argSchemaGet = parser.add<BooleanOption>(0x0, "schemaGet" , "Print the JSON schema for Hyperion configuration");
Option & argConfigSet = parser.add<Option> (0x0, "configSet" , "Write to the actual loaded configuration file. Should be a JSON object string.");
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print", "Print the JSON input and output messages on stdout");
BooleanOption & argDebug = parser.add<BooleanOption>(0x0, "debug", "Enable debug logging");
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
// parse all _options
parser.process(app);
// check if debug logging is required
if (parser.isSet(argDebug))
{
Logger::setLogLevel(Logger::DEBUG);
}
// check if we need to display the usage. exit if we do.
if (parser.isSet(argHelp))
{
@@ -196,8 +210,17 @@ int main(int argc, char * argv[])
}
}
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ JSON_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// create the connection to the hyperion server
JsonConnection connection(address, parser.isSet(argPrint));
JsonConnection connection(host, parser.isSet(argPrint), port);
// authorization token specified. Use it first
if (parser.isSet(argToken))
@@ -323,7 +346,7 @@ int main(int argc, char * argv[])
catch (const std::runtime_error & e)
{
// An error occurred. Display error and quit
std::cerr << e.what() << std::endl;
Error(log, "%s", e.what());
return 1;
}

View File

@@ -23,6 +23,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
#include <utils/DefaultSignalHandler.h>
@@ -81,7 +82,7 @@ int main(int argc, char** argv)
DoubleOption & argSignalHorizontalMax = parser.add<DoubleOption> (0x0, "signal-horizontal-max", "area for signal detection - horizontal maximum offset value. Values between 0.0 and 1.0");
DoubleOption & argSignalVerticalMax = parser.add<DoubleOption> (0x0, "signal-vertical-max" , "area for signal detection - vertical maximum offset value. Values between 0.0 and 1.0");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -241,8 +242,17 @@ int main(int argc, char** argv)
}
}
// Create the Flatbuf-connection
FlatBufferConnection flatbuf("V4L2 Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ FLATBUFFER_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("V4L2 Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&grabber, SIGNAL(newFrame(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -11,6 +11,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
using namespace commandline;
@@ -52,7 +53,7 @@ int main(int argc, char ** argv)
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -121,8 +122,18 @@ int main(int argc, char ** argv)
address = argAddress.value(parser);
}
}
// Create the Flatbuf-connection
FlatBufferConnection flatbuf("X11 Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ FLATBUFFER_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("X11 Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&x11Wrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -11,6 +11,7 @@
// ssdp discover
#include <ssdp/SSDPDiscover.h>
#include <utils/NetUtils.h>
using namespace commandline;
@@ -52,7 +53,7 @@ int main(int argc, char ** argv)
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
@@ -121,8 +122,18 @@ int main(int argc, char ** argv)
address = argAddress.value(parser);
}
}
// Create the Flatbuf-connection
FlatBufferConnection flatbuf("XCB Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
// Resolve hostname and port (or use default port)
QString host;
quint16 port{ FLATBUFFER_DEFAULT_PORT };
if (!NetUtils::resolveHostPort(address, host, port))
{
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
}
// Create the Flabuf-connection
FlatBufferConnection flatbuf("XCB Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
// Connect the screen capturing to flatbuf connection processing
QObject::connect(&xcbWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));

View File

@@ -181,6 +181,7 @@ if (WIN32)
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_filename_component(QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
if (NOT WINDEPLOYQT_EXECUTABLE)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt)
endif()
@@ -190,6 +191,37 @@ if (WIN32)
message(STATUS "Found windeployqt: ${WINDEPLOYQT_EXECUTABLE} PATH_HINT:${QT_BIN_DIR}")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} ${WINDEPLOYQT_PARAMS_RUNTIME} "$<TARGET_FILE:${PROJECT_NAME}>")
endif()
find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
string(REGEX MATCHALL "[0-9]+" openssl_versions "${OPENSSL_VERSION}")
list(GET openssl_versions 0 openssl_version_major)
list(GET openssl_versions 1 openssl_version_minor)
set(library_suffix "-${openssl_version_major}_${openssl_version_minor}")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
string(APPEND library_suffix "-x64")
endif()
find_file(OPENSSL_SSL
NAMES "libssl${library_suffix}.dll"
PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin
NO_DEFAULT_PATH
)
find_file(OPENSSL_CRYPTO
NAMES "libcrypto${library_suffix}.dll"
PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin
NO_DEFAULT_PATH
)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${OPENSSL_SSL} ${OPENSSL_CRYPTO}
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endif(OPENSSL_FOUND)
endif(WIN32)
if(ENABLE_DEPLOY_DEPENDENCIES)

View File

@@ -26,6 +26,8 @@
#include <QDir>
#include <QStringList>
#include <QSystemTrayIcon>
#include <QNetworkInterface>
#include <QHostInfo>
#include "HyperionConfig.h"
@@ -47,7 +49,7 @@
using namespace commandline;
#define PERM0664 QFileDevice::ReadOwner | QFileDevice::ReadGroup | QFileDevice::ReadOther | QFileDevice::WriteOwner | QFileDevice::WriteGroup
#define PERM0664 (QFileDevice::ReadOwner | QFileDevice::ReadGroup | QFileDevice::ReadOther | QFileDevice::WriteOwner | QFileDevice::WriteGroup)
#ifndef _WIN32
void signal_handler(int signum)
@@ -59,7 +61,6 @@ void signal_handler(int signum)
{
// only quit when a registered child process is gone
// currently this feature is not active ...
return;
}
else if (signum == SIGUSR1)
{
@@ -67,7 +68,6 @@ void signal_handler(int signum)
{
_hyperion->toggleStateAllInstances(false);
}
return;
}
else if (signum == SIGUSR2)
{
@@ -75,7 +75,6 @@ void signal_handler(int signum)
{
_hyperion->toggleStateAllInstances(true);
}
return;
}
}
#endif
@@ -106,8 +105,8 @@ QCoreApplication* createApplication(int &argc, char *argv[])
{
// if x11, then test if xserver is available
#if defined(ENABLE_X11)
Display* dpy = XOpenDisplay(NULL);
if (dpy != NULL)
Display* dpy = XOpenDisplay(nullptr);
if (dpy != nullptr)
{
XCloseDisplay(dpy);
isGuiApp = true;
@@ -165,7 +164,7 @@ int main(int argc, char** argv)
// Initialising QCoreApplication
QScopedPointer<QCoreApplication> app(createApplication(argc, argv));
bool isGuiApp = (qobject_cast<QApplication *>(app.data()) != 0 && QSystemTrayIcon::isSystemTrayAvailable());
bool isGuiApp = (qobject_cast<QApplication *>(app.data()) != nullptr && QSystemTrayIcon::isSystemTrayAvailable());
DefaultSignalHandler::install();
@@ -200,6 +199,13 @@ int main(int argc, char** argv)
parser.process(*qApp);
#ifdef WIN32
if (parser.isSet(consoleOption))
{
CreateConsole();
}
#endif
if (parser.isSet(versionOption))
{
std::cout
@@ -215,6 +221,24 @@ int main(int argc, char** argv)
if (getProcessIdsByProcessName(processName).size() > 1)
{
Error(log, "The Hyperion Daemon is already running, abort start");
// use the first non-localhost IPv4 address, IPv6 are not supported by Yeelight currently
for (const auto& address : QNetworkInterface::allAddresses())
{
if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol))
{
std::cout << "Access the Hyperion User-Interface for configuration and control via:" << std::endl;
std::cout << "http:://" << address.toString().toStdString() << ":8090" << std::endl;
QHostInfo hostInfo = QHostInfo::fromName(address.toString());
if (hostInfo.error() == QHostInfo::NoError)
{
QString hostname = hostInfo.hostName();
std::cout << "http:://" << hostname.toStdString() << ":8090" << std::endl;
}
break;
}
}
return 0;
}
}
@@ -226,13 +250,6 @@ int main(int argc, char** argv)
}
}
#ifdef WIN32
if (parser.isSet(consoleOption))
{
CreateConsole();
}
#endif
int logLevelCheck = 0;
if (parser.isSet(silentOption))
{
@@ -268,11 +285,13 @@ int main(int argc, char** argv)
std::cout << "Extract to folder: " << destDir.absolutePath().toStdString() << std::endl;
QStringList filenames = directory.entryList(QStringList() << "*", QDir::Files, QDir::Name | QDir::IgnoreCase);
QString destFileName;
for (const QString & filename : filenames)
for (const QString & filename : qAsConst(filenames))
{
destFileName = destDir.dirName()+"/"+filename;
if (QFile::exists(destFileName))
{
QFile::remove(destFileName);
}
std::cout << "Extract: " << filename.toStdString() << " ... ";
if (QFile::copy(QString(":/effects/")+filename, destFileName))
@@ -303,20 +322,16 @@ int main(int argc, char** argv)
try
{
if (dbFile.exists())
{
if (!dbFile.isReadable())
{
throw std::runtime_error("Configuration database '" + dbFile.absoluteFilePath().toStdString() + "' is not readable. Please setup permissions correctly!");
}
else
if (!dbFile.isWritable())
{
if (!dbFile.isWritable())
{
readonlyMode = true;
}
readonlyMode = true;
}
}
else
@@ -338,18 +353,16 @@ int main(int argc, char** argv)
Error(log,"Password reset is not possible. The user data path '%s' is not writeable.", QSTRING_CSTR(userDataDirectory.absolutePath()));
throw std::runtime_error("Password reset failed");
}
else
{
AuthTable* table = new AuthTable(userDataDirectory.absolutePath());
if(table->resetHyperionUser()){
Info(log,"Password reset successful");
delete table;
exit(0);
} else {
Error(log,"Failed to reset password!");
delete table;
exit(1);
}
AuthTable* table = new AuthTable(userDataDirectory.absolutePath());
if(table->resetHyperionUser()){
Info(log,"Password reset successful");
delete table;
exit(0);
} else {
Error(log,"Failed to reset password!");
delete table;
exit(1);
}
}
@@ -361,25 +374,23 @@ int main(int argc, char** argv)
Error(log,"Deleting the configuration database is not possible. The user data path '%s' is not writeable.", QSTRING_CSTR(dbFile.absolutePath()));
throw std::runtime_error("Deleting the configuration database failed");
}
else
if (QFile::exists(dbFile.absoluteFilePath()))
{
if (QFile::exists(dbFile.absoluteFilePath()))
if (!QFile::remove(dbFile.absoluteFilePath()))
{
if (!QFile::remove(dbFile.absoluteFilePath()))
{
Info(log,"Failed to delete Database!");
exit(1);
}
else
{
Info(log,"Configuration database deleted successfully.");
}
Info(log,"Failed to delete Database!");
exit(1);
}
else
{
Warning(log,"Configuration database [%s] does not exist!", QSTRING_CSTR(dbFile.absoluteFilePath()));
Info(log,"Configuration database deleted successfully.");
}
}
else
{
Warning(log,"Configuration database [%s] does not exist!", QSTRING_CSTR(dbFile.absoluteFilePath()));
}
}
Info(log,"Starting Hyperion - %s, %s, built: %s:%s", HYPERION_VERSION, HYPERION_BUILD_ID, __DATE__, __TIME__);