mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Feat: SSDP discovery for hyperion-remote (#602)
* Auto stash before merge of "log" and "hyperion-project/master" * resolve merge tool mess
This commit is contained in:
parent
c4d0edd9c2
commit
d3f45e7ae5
@ -7,7 +7,8 @@ class QUdpSocket;
|
|||||||
|
|
||||||
enum searchType{
|
enum searchType{
|
||||||
STY_WEBSERVER,
|
STY_WEBSERVER,
|
||||||
STY_FLATBUFSERVER
|
STY_FLATBUFSERVER,
|
||||||
|
STY_JSONSERVER
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -19,7 +19,7 @@ class QNetworkConfigurationManager;
|
|||||||
class SSDPHandler : public SSDPServer{
|
class SSDPHandler : public SSDPServer{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SSDPHandler(WebServer* webserver, const quint16& flatBufPort, QObject * parent = nullptr);
|
SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, QObject * parent = nullptr);
|
||||||
~SSDPHandler();
|
~SSDPHandler();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -89,7 +89,6 @@ private:
|
|||||||
WebServer* _webserver;
|
WebServer* _webserver;
|
||||||
QString _localAddress;
|
QString _localAddress;
|
||||||
QNetworkConfigurationManager* _NCA;
|
QNetworkConfigurationManager* _NCA;
|
||||||
quint16 _flatbufPort;
|
|
||||||
QString _uuid;
|
QString _uuid;
|
||||||
/// Targets for announcement
|
/// Targets for announcement
|
||||||
std::vector<QString> _deviceList;
|
std::vector<QString> _deviceList;
|
||||||
|
@ -78,6 +78,21 @@ public:
|
|||||||
///
|
///
|
||||||
void setFlatBufPort(const quint16& port) { _fbsPort = QString::number(port); };
|
void setFlatBufPort(const quint16& port) { _fbsPort = QString::number(port); };
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Get current flatbuffer server port
|
||||||
|
///
|
||||||
|
quint16 getFlatBufPort() { return _fbsPort.toInt(); };
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief set new jsonserver server port
|
||||||
|
///
|
||||||
|
void setJsonServerPort(const quint16& port) { _jssPort = QString::number(port); };
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief get new jsonserver server port
|
||||||
|
///
|
||||||
|
quint16 getJsonServerPort() { return _jssPort.toInt(); };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
///
|
///
|
||||||
/// @brief Emits whenever a new SSDP search "man : ssdp:discover" is received along with the service type
|
/// @brief Emits whenever a new SSDP search "man : ssdp:discover" is received along with the service type
|
||||||
@ -95,6 +110,7 @@ private:
|
|||||||
QString _serverHeader;
|
QString _serverHeader;
|
||||||
QString _uuid;
|
QString _uuid;
|
||||||
QString _fbsPort;
|
QString _fbsPort;
|
||||||
|
QString _jssPort;
|
||||||
QString _descAddress;
|
QString _descAddress;
|
||||||
bool _running;
|
bool _running;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ void SSDPDiscover::searchForService(const QString& st)
|
|||||||
|
|
||||||
const QString SSDPDiscover::getFirstService(const searchType& type, const QString& st, const int& timeout_ms)
|
const QString SSDPDiscover::getFirstService(const searchType& type, const QString& st, const int& timeout_ms)
|
||||||
{
|
{
|
||||||
Info(_log, "Search for Service [%s]", QSTRING_CSTR(st));
|
Info(_log, "Search for Hyperion server");
|
||||||
_searchTarget = st;
|
_searchTarget = st;
|
||||||
|
|
||||||
// search
|
// search
|
||||||
@ -91,7 +91,7 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
|
|||||||
//Info(_log, "Received msearch response from '%s:%d'. Search target: %s",QSTRING_CSTR(sender.toString()), senderPort, QSTRING_CSTR(headers.value("st")));
|
//Info(_log, "Received msearch response from '%s:%d'. Search target: %s",QSTRING_CSTR(sender.toString()), senderPort, QSTRING_CSTR(headers.value("st")));
|
||||||
if(type == STY_WEBSERVER)
|
if(type == STY_WEBSERVER)
|
||||||
{
|
{
|
||||||
Info(_log, "Found service [%s] at: %s:%d", QSTRING_CSTR(st), QSTRING_CSTR(url.host()), url.port());
|
Info(_log, "Found service at: %s:%d", QSTRING_CSTR(url.host()), url.port());
|
||||||
|
|
||||||
return url.host()+":"+QString::number(url.port());
|
return url.host()+":"+QString::number(url.port());
|
||||||
}
|
}
|
||||||
@ -104,10 +104,23 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info(_log, "Found service [%s] at: %s:%s", QSTRING_CSTR(st), QSTRING_CSTR(url.host()), QSTRING_CSTR(fbsport));
|
Info(_log, "Found service at: %s:%s", QSTRING_CSTR(url.host()), QSTRING_CSTR(fbsport));
|
||||||
return url.host()+":"+fbsport;
|
return url.host()+":"+fbsport;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(type == STY_JSONSERVER)
|
||||||
|
{
|
||||||
|
const QString jssport = headers.value("hyperion-jss-port");
|
||||||
|
if(jssport.isEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info(_log, "Found service at: %s:%s", QSTRING_CSTR(url.host()), QSTRING_CSTR(jssport));
|
||||||
|
return url.host()+":"+jssport;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Info(_log,"Search timeout, service [%s] not found", QSTRING_CSTR(st) );
|
Info(_log,"Search timeout, service [%s] not found", QSTRING_CSTR(st) );
|
||||||
|
@ -9,14 +9,14 @@
|
|||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <QNetworkConfigurationManager>
|
#include <QNetworkConfigurationManager>
|
||||||
|
|
||||||
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, QObject * parent)
|
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, QObject * parent)
|
||||||
: SSDPServer(parent)
|
: SSDPServer(parent)
|
||||||
, _webserver(webserver)
|
, _webserver(webserver)
|
||||||
, _localAddress()
|
, _localAddress()
|
||||||
, _NCA(nullptr)
|
, _NCA(nullptr)
|
||||||
{
|
{
|
||||||
_flatbufPort = flatBufPort;
|
setFlatBufPort(flatBufPort);
|
||||||
setFlatBufPort(_flatbufPort);
|
setJsonServerPort(jsonServerPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDPHandler::~SSDPHandler()
|
SSDPHandler::~SSDPHandler()
|
||||||
@ -62,10 +62,18 @@ void SSDPHandler::handleSettingsUpdate(const settings::type& type, const QJsonDo
|
|||||||
if(type == settings::FLATBUFSERVER)
|
if(type == settings::FLATBUFSERVER)
|
||||||
{
|
{
|
||||||
const QJsonObject& obj = config.object();
|
const QJsonObject& obj = config.object();
|
||||||
if(obj["port"].toInt() != _flatbufPort)
|
if(obj["port"].toInt() != SSDPServer::getFlatBufPort())
|
||||||
{
|
{
|
||||||
_flatbufPort = obj["port"].toInt();
|
SSDPServer::setFlatBufPort(obj["port"].toInt());
|
||||||
setFlatBufPort(_flatbufPort);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == settings::JSONSERVER)
|
||||||
|
{
|
||||||
|
const QJsonObject& obj = config.object();
|
||||||
|
if(obj["port"].toInt() != SSDPServer::getJsonServerPort())
|
||||||
|
{
|
||||||
|
SSDPServer::setJsonServerPort(obj["port"].toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ static const QString UPNP_ALIVE_MESSAGE = "NOTIFY * HTTP/1.1\r\n"
|
|||||||
"SERVER: %4\r\n"
|
"SERVER: %4\r\n"
|
||||||
"USN: uuid:%5\r\n"
|
"USN: uuid:%5\r\n"
|
||||||
"HYPERION-FBS-PORT: %6\r\n"
|
"HYPERION-FBS-PORT: %6\r\n"
|
||||||
|
"HYPERION-JSS-PORT: %7\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
|
||||||
// Implement ssdp:update as per spec 1.1, section 1.2.4
|
// Implement ssdp:update as per spec 1.1, section 1.2.4
|
||||||
@ -70,6 +71,7 @@ static const QString UPNP_MSEARCH_RESPONSE = "HTTP/1.1 200 OK\r\n"
|
|||||||
"ST: %5\r\n"
|
"ST: %5\r\n"
|
||||||
"USN: uuid:%6\r\n"
|
"USN: uuid:%6\r\n"
|
||||||
"HYPERION-FBS-PORT: %7\r\n"
|
"HYPERION-FBS-PORT: %7\r\n"
|
||||||
|
"HYPERION-JSS-PORT: %8\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
|
||||||
SSDPServer::SSDPServer(QObject * parent)
|
SSDPServer::SSDPServer(QObject * parent)
|
||||||
@ -169,7 +171,8 @@ void SSDPServer::sendMSearchResponse(const QString& st, const QString& senderIp,
|
|||||||
, _serverHeader
|
, _serverHeader
|
||||||
, st
|
, st
|
||||||
, _uuid
|
, _uuid
|
||||||
, _fbsPort );
|
, _fbsPort
|
||||||
|
, _jssPort );
|
||||||
|
|
||||||
_udpSocket->writeDatagram(message.toUtf8(),
|
_udpSocket->writeDatagram(message.toUtf8(),
|
||||||
QHostAddress(senderIp),
|
QHostAddress(senderIp),
|
||||||
@ -199,7 +202,8 @@ void SSDPServer::sendAlive(const QString& st)
|
|||||||
, st
|
, st
|
||||||
, _serverHeader
|
, _serverHeader
|
||||||
, tempUSN
|
, tempUSN
|
||||||
, _fbsPort);
|
, _fbsPort
|
||||||
|
, _jssPort );
|
||||||
|
|
||||||
// we repeat 3 times
|
// we repeat 3 times
|
||||||
quint8 rep = 0;
|
quint8 rep = 0;
|
||||||
|
@ -65,12 +65,8 @@ int main(int argc, char ** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server searching by ssdp
|
// server searching by ssdp
|
||||||
QString address;
|
QString address = argAddress.value(parser);
|
||||||
if(parser.isSet(argAddress))
|
if(argAddress.value(parser) == "127.0.0.1:19400")
|
||||||
{
|
|
||||||
address = argAddress.value(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SSDPDiscover discover;
|
SSDPDiscover discover;
|
||||||
address = discover.getFirstService(STY_FLATBUFSERVER);
|
address = discover.getFirstService(STY_FLATBUFSERVER);
|
||||||
@ -79,6 +75,7 @@ int main(int argc, char ** argv)
|
|||||||
address = argAddress.value(parser);
|
address = argAddress.value(parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the Flabuf-connection
|
// Create the Flabuf-connection
|
||||||
FlatBufferConnection flatbuf("AML Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
FlatBufferConnection flatbuf("AML Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||||
|
|
||||||
|
@ -94,12 +94,8 @@ int main(int argc, char ** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server searching by ssdp
|
// server searching by ssdp
|
||||||
QString address;
|
QString address = argAddress.value(parser);
|
||||||
if(parser.isSet(argAddress))
|
if(argAddress.value(parser) == "127.0.0.1:19400")
|
||||||
{
|
|
||||||
address = argAddress.value(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SSDPDiscover discover;
|
SSDPDiscover discover;
|
||||||
address = discover.getFirstService(STY_FLATBUFSERVER);
|
address = discover.getFirstService(STY_FLATBUFSERVER);
|
||||||
|
@ -58,12 +58,8 @@ int main(int argc, char ** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server searching by ssdp
|
// server searching by ssdp
|
||||||
QString address;
|
QString address = argAddress.value(parser);
|
||||||
if(parser.isSet(argAddress))
|
if(argAddress.value(parser) == "127.0.0.1:19400")
|
||||||
{
|
|
||||||
address = argAddress.value(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SSDPDiscover discover;
|
SSDPDiscover discover;
|
||||||
address = discover.getFirstService(STY_FLATBUFSERVER);
|
address = discover.getFirstService(STY_FLATBUFSERVER);
|
||||||
@ -72,6 +68,7 @@ int main(int argc, char ** argv)
|
|||||||
address = argAddress.value(parser);
|
address = argAddress.value(parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the Flabuf-connection
|
// Create the Flabuf-connection
|
||||||
FlatBufferConnection flatbuf("Framebuffer Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
FlatBufferConnection flatbuf("Framebuffer Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||||
|
|
||||||
|
@ -61,12 +61,8 @@ int main(int argc, char ** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server searching by ssdp
|
// server searching by ssdp
|
||||||
QString address;
|
QString address = argAddress.value(parser);
|
||||||
if(parser.isSet(argAddress))
|
if(argAddress.value(parser) == "127.0.0.1:19400")
|
||||||
{
|
|
||||||
address = argAddress.value(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SSDPDiscover discover;
|
SSDPDiscover discover;
|
||||||
address = discover.getFirstService(STY_FLATBUFSERVER);
|
address = discover.getFirstService(STY_FLATBUFSERVER);
|
||||||
|
@ -74,12 +74,8 @@ int main(int argc, char ** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server searching by ssdp
|
// server searching by ssdp
|
||||||
QString address;
|
QString address = argAddress.value(parser);
|
||||||
if(parser.isSet(argAddress))
|
if(argAddress.value(parser) == "127.0.0.1:19400")
|
||||||
{
|
|
||||||
address = argAddress.value(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SSDPDiscover discover;
|
SSDPDiscover discover;
|
||||||
address = discover.getFirstService(STY_FLATBUFSERVER);
|
address = discover.getFirstService(STY_FLATBUFSERVER);
|
||||||
@ -88,6 +84,7 @@ int main(int argc, char ** argv)
|
|||||||
address = argAddress.value(parser);
|
address = argAddress.value(parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the Flabuf-connection
|
// Create the Flabuf-connection
|
||||||
FlatBufferConnection flatbuf("Qt Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
FlatBufferConnection flatbuf("Qt Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||||||
effectengine
|
effectengine
|
||||||
commandline
|
commandline
|
||||||
hyperion-utils
|
hyperion-utils
|
||||||
|
ssdp
|
||||||
Qt5::Gui
|
Qt5::Gui
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Network)
|
Qt5::Network)
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
// hyperion-remote include
|
// hyperion-remote include
|
||||||
#include "JsonConnection.h"
|
#include "JsonConnection.h"
|
||||||
|
|
||||||
|
// ssdp discover
|
||||||
|
#include <ssdp/SSDPDiscover.h>
|
||||||
|
|
||||||
#include "HyperionConfig.h"
|
#include "HyperionConfig.h"
|
||||||
#include <commandline/Parser.h>
|
#include <commandline/Parser.h>
|
||||||
|
|
||||||
@ -76,7 +79,7 @@ int main(int argc, char * argv[])
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// art variable definition append art to Parser short-, long option description, optional default value //
|
// 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]", "localhost:19444");
|
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 & 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 befault it uses always the first instance");
|
Option & argInstance = parser.add<Option> ('I', "instance" , "Select a specific target instance by name for your command. By befault 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 & argPriority = parser.add<IntOption> ('p', "priority" , "Used to the provided priority channel (suggested 2-99) [default: %1]", "50");
|
||||||
@ -173,8 +176,20 @@ int main(int argc, char * argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// server searching by ssdp
|
||||||
|
QString address = argAddress.value(parser);
|
||||||
|
if(argAddress.value(parser) == "127.0.0.1:19444")
|
||||||
|
{
|
||||||
|
SSDPDiscover discover;
|
||||||
|
address = discover.getFirstService(STY_JSONSERVER);
|
||||||
|
if(address.isEmpty())
|
||||||
|
{
|
||||||
|
address = argAddress.value(parser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create the connection to the hyperion server
|
// create the connection to the hyperion server
|
||||||
JsonConnection connection(argAddress.value(parser), parser.isSet(argPrint));
|
JsonConnection connection(address, parser.isSet(argPrint));
|
||||||
|
|
||||||
// authorization token specified. Use it first
|
// authorization token specified. Use it first
|
||||||
if (parser.isSet(argToken))
|
if (parser.isSet(argToken))
|
||||||
|
@ -186,12 +186,8 @@ int main(int argc, char** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server searching by ssdp
|
// server searching by ssdp
|
||||||
QString address;
|
QString address = argAddress.value(parser);
|
||||||
if(parser.isSet(argAddress))
|
if(argAddress.value(parser) == "127.0.0.1:19400")
|
||||||
{
|
|
||||||
address = argAddress.value(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SSDPDiscover discover;
|
SSDPDiscover discover;
|
||||||
address = discover.getFirstService(STY_FLATBUFSERVER);
|
address = discover.getFirstService(STY_FLATBUFSERVER);
|
||||||
|
@ -79,12 +79,8 @@ int main(int argc, char ** argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// server searching by ssdp
|
// server searching by ssdp
|
||||||
QString address;
|
QString address = argAddress.value(parser);
|
||||||
if(parser.isSet(argAddress))
|
if(argAddress.value(parser) == "127.0.0.1:19400")
|
||||||
{
|
|
||||||
address = argAddress.value(parser);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SSDPDiscover discover;
|
SSDPDiscover discover;
|
||||||
address = discover.getFirstService(STY_FLATBUFSERVER);
|
address = discover.getFirstService(STY_FLATBUFSERVER);
|
||||||
|
@ -233,7 +233,7 @@ void HyperionDaemon::startNetworkServices()
|
|||||||
wsThread->start();
|
wsThread->start();
|
||||||
|
|
||||||
// Create SSDP server in thread
|
// Create SSDP server in thread
|
||||||
_ssdp = new SSDPHandler(_webserver, getSetting(settings::FLATBUFSERVER).object()["port"].toInt());
|
_ssdp = new SSDPHandler(_webserver, getSetting(settings::FLATBUFSERVER).object()["port"].toInt(), getSetting(settings::JSONSERVER).object()["port"].toInt());
|
||||||
QThread* ssdpThread = new QThread(this);
|
QThread* ssdpThread = new QThread(this);
|
||||||
_ssdp->moveToThread(ssdpThread);
|
_ssdp->moveToThread(ssdpThread);
|
||||||
connect( ssdpThread, &QThread::started, _ssdp, &SSDPHandler::initServer );
|
connect( ssdpThread, &QThread::started, _ssdp, &SSDPHandler::initServer );
|
||||||
|
@ -240,7 +240,7 @@ int main(int argc, char** argv)
|
|||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
|
|
||||||
BooleanOption & versionOption = parser.add<BooleanOption>(0x0, "version", "Show version information");
|
BooleanOption & versionOption = parser.add<BooleanOption>(0x0, "version", "Show version information");
|
||||||
Option & rootPathOption = parser.add<Option> (0x0, "rootPath", "Overwrite root path for all hyperion user files, defaults to home directory of current user");
|
Option & userDataOption = parser.add<Option> (0x0, "userdata", "Overwrite user data path, defaults to home directory of current user (%1)", QDir::homePath() + "/.hyperion");
|
||||||
BooleanOption & silentOption = parser.add<BooleanOption>('s', "silent", "do not print any outputs");
|
BooleanOption & silentOption = parser.add<BooleanOption>('s', "silent", "do not print any outputs");
|
||||||
BooleanOption & verboseOption = parser.add<BooleanOption>('v', "verbose", "Increase verbosity");
|
BooleanOption & verboseOption = parser.add<BooleanOption>('v', "verbose", "Increase verbosity");
|
||||||
BooleanOption & debugOption = parser.add<BooleanOption>('d', "debug", "Show debug messages");
|
BooleanOption & debugOption = parser.add<BooleanOption>('d', "debug", "Show debug messages");
|
||||||
@ -320,39 +320,24 @@ int main(int argc, char** argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle rootPath for user data, default path is home directory + /.hyperion
|
|
||||||
QString rootPath = QDir::homePath() + "/.hyperion";
|
|
||||||
if (parser.isSet(rootPathOption))
|
|
||||||
{
|
|
||||||
QDir rDir(rootPathOption.value(parser));
|
|
||||||
if(!rDir.mkpath(rootPathOption.value(parser)))
|
|
||||||
{
|
|
||||||
Error(log, "Can't create root path '%s', falling back to home directory", QSTRING_CSTR(rDir.absolutePath()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rootPath = rDir.absolutePath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// handle and create userDataPath for user data, default path is home directory + /.hyperion
|
||||||
// create /.hyperion folder for default path, check if the directory is read/writeable
|
|
||||||
// NOTE: No further checks inside Hyperion. FileUtils::writeFile() will resolve permission errors and others that occur during runtime
|
// NOTE: No further checks inside Hyperion. FileUtils::writeFile() will resolve permission errors and others that occur during runtime
|
||||||
QDir mDir(rootPath);
|
QString userDataPath(userDataOption.value(parser));
|
||||||
QFileInfo mFi(rootPath);
|
QDir mDir(userDataPath);
|
||||||
if(!mDir.mkpath(rootPath) || !mFi.isWritable() || !mDir.isReadable())
|
QFileInfo mFi(userDataPath);
|
||||||
{
|
if(!mDir.mkpath(userDataPath) || !mFi.isWritable() || !mDir.isReadable())
|
||||||
throw std::runtime_error("The specified root path can't be created or isn't read/writeable. Please setup the permissions correctly!");
|
throw std::runtime_error("The user data path '"+mDir.absolutePath().toStdString()+"' can't be created or isn't read/writeable. Please setup permissions correctly!");
|
||||||
}
|
|
||||||
|
Info(log, "Set user data path to '%s'", QSTRING_CSTR(mDir.absolutePath()));
|
||||||
|
|
||||||
HyperionDaemon* hyperiond = nullptr;
|
HyperionDaemon* hyperiond = nullptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hyperiond = new HyperionDaemon(rootPath, qApp, bool(logLevelCheck));
|
hyperiond = new HyperionDaemon(userDataPath, qApp, bool(logLevelCheck));
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user