hyperion.ng/libsrc/utils/Process.cpp
LordGrey 2f573a117f
Hyperion "Light", Build improvements and minor fixes (#1400)
* Allow build, if no grabbers are enabled

* Align available functions to right Qt version

* Update to next development version

* Align available functions to right Qt version

* fix workflows (apt/nightly)

* Disable QNetworkConfigurationManager deprecation warnings

* Initial go on Smart Pointers

* Add Deallocation

* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)

* Cluster Build Variables

* Hyperion Light

* Address build warnings

* Hyperion Light - UI

* Update Protobuf to latest master

* Removed compiler warnings

* Added restart ability to systray

* Correct Protobuf

* Ignore 'no-return' warning on protobuf build

* hyperion-remote: Fix auto discovery of hyperion server

* Fix Qt version override

* Update changelog

* Remove Grabber Components, if no Grabber exists

* Standalone Grabber - Fix fps default

* Remote Control - Have Source Selction accrosswhole screen

* Enable Blackborder detection only, if relevant input sources available

* Enable Blackborder detection only, if relevant input sources available

* Remote UI - rearrange containers

* - QT5/6 path for arm64 added
- Remove ZLib Dependency
- Fix macOS bundle info details
- Cleanup

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
2022-01-07 14:47:51 +01:00

86 lines
1.8 KiB
C++

#ifdef _WIN32
#include <QCoreApplication>
#include <QProcess>
#include <utils/Logger.h>
#include <QString>
#include <QByteArray>
namespace Process {
void restartHyperion(bool asNewProcess)
{
Logger* log = Logger::getInstance("Process");
Info(log, "Restarting hyperion ...");
auto arguments = QCoreApplication::arguments();
if (!arguments.contains("--wait-hyperion"))
arguments << "--wait-hyperion";
QProcess::startDetached(QCoreApplication::applicationFilePath(), arguments);
QCoreApplication::quit();
}
QByteArray command_exec(const QString& /*cmd*/, const QByteArray& /*data*/)
{
return QSTRING_CSTR(QString());
}
};
#else
#include <utils/Process.h>
#include <utils/Logger.h>
#include <QCoreApplication>
#include <QProcess>
#include <QStringList>
#include <unistd.h>
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
namespace Process {
void restartHyperion(bool asNewProcess)
{
Logger* log = Logger::getInstance("Process");
Info(log, "Restarting hyperion ...");
std::cout << std::endl
<< " *******************************************" << std::endl
<< " * hyperion will restart now *" << std::endl
<< " *******************************************" << std::endl << std::endl;
auto arguments = QCoreApplication::arguments();
if (!arguments.contains("--wait-hyperion"))
arguments << "--wait-hyperion";
QProcess::startDetached(QCoreApplication::applicationFilePath(), arguments);
QCoreApplication::quit();
}
QByteArray command_exec(const QString& cmd, const QByteArray& data)
{
char buffer[128];
QString result;
std::shared_ptr<FILE> pipe(popen(cmd.toLocal8Bit().constData(), "r"), pclose);
if (pipe)
{
while (!feof(pipe.get()))
{
if (fgets(buffer, 128, pipe.get()) != NULL)
result += buffer;
}
}
return QSTRING_CSTR(result);
}
};
#endif