mirror of
https://github.com/QuasarApp/Patronum.git
synced 2025-04-26 07:34:32 +00:00
update quasarapp
This commit is contained in:
parent
7582318f77
commit
7d9eb0b09f
@ -83,7 +83,7 @@ bool Controller::send() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot(1000, nullptr, []() {
|
QTimer::singleShot(1000, nullptr, []() {
|
||||||
QuasarAppUtils::Params::log(errorToString(PatronumError::TimeOutError), QuasarAppUtils::Error);
|
qCritical() << errorToString(PatronumError::TimeOutError);
|
||||||
QCoreApplication::exit(static_cast<int>(PatronumError::TimeOutError));
|
QCoreApplication::exit(static_cast<int>(PatronumError::TimeOutError));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -120,8 +120,7 @@ QuasarAppUtils::Help::Section Controller::help() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Controller::handleError(PatronumError error) {
|
void Controller::handleError(PatronumError error) {
|
||||||
QuasarAppUtils::Params::log(errorToString(error),
|
qCritical() << errorToString(error);
|
||||||
QuasarAppUtils::Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::handleFeatures(const QList<Feature> &features) {
|
void Controller::handleFeatures(const QList<Feature> &features) {
|
||||||
|
@ -23,15 +23,12 @@ bool BaseInstaller::install(const QString &executable, const QString &user) {
|
|||||||
Q_UNUSED(user)
|
Q_UNUSED(user)
|
||||||
|
|
||||||
if (!QFile::exists(executable)) {
|
if (!QFile::exists(executable)) {
|
||||||
QuasarAppUtils::Params::log(QObject::tr("The service executable file is not exists %0\n").arg(executable),
|
qCritical() << "The service executable file is not exists " << executable;
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInstalled()) {
|
if (isInstalled()) {
|
||||||
QuasarAppUtils::Params::log(QObject::tr("the service %0 alredy installed \n").
|
qInfo() << "The service " << PCommon::instance()->getServiceName() << " alredy installed";
|
||||||
arg(PCommon::instance()->getServiceName()),
|
|
||||||
QuasarAppUtils::Info);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,9 +37,8 @@ bool BaseInstaller::install(const QString &executable, const QString &user) {
|
|||||||
|
|
||||||
bool BaseInstaller::uninstall() {
|
bool BaseInstaller::uninstall() {
|
||||||
if (!isInstalled()) {
|
if (!isInstalled()) {
|
||||||
QuasarAppUtils::Params::log(QObject::tr("the service %0 alredy uninstalled \n").
|
|
||||||
arg(PCommon::instance()->getServiceName()),
|
qInfo() << "The service " << PCommon::instance()->getServiceName() << " alredy uninstalled";
|
||||||
QuasarAppUtils::Info);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,9 +47,10 @@ bool BaseInstaller::uninstall() {
|
|||||||
|
|
||||||
bool BaseInstaller::enable() {
|
bool BaseInstaller::enable() {
|
||||||
if (!isInstalled()) {
|
if (!isInstalled()) {
|
||||||
QuasarAppUtils::Params::log(QObject::tr("Cannot enabled the service %0 not installed, run install command befor enable. \n").
|
|
||||||
arg(PCommon::instance()->getServiceName()),
|
qInfo() << QObject::tr("Cannot enabled the service %0 not installed, run install command befor enable. \n").
|
||||||
QuasarAppUtils::Info);
|
arg(PCommon::instance()->getServiceName());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,9 +59,9 @@ bool BaseInstaller::enable() {
|
|||||||
|
|
||||||
bool BaseInstaller::disable() {
|
bool BaseInstaller::disable() {
|
||||||
if (!isInstalled()) {
|
if (!isInstalled()) {
|
||||||
QuasarAppUtils::Params::log(QObject::tr("Cannot disabled the service %0 not installed, run install command befor enable. \n").
|
|
||||||
arg(PCommon::instance()->getServiceName()),
|
qInfo() << QObject::tr("Cannot disabled the service %0 not installed, run install command befor enable. \n").
|
||||||
QuasarAppUtils::Info);
|
arg(PCommon::instance()->getServiceName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -39,8 +39,9 @@ ControllerPrivate::~ControllerPrivate() {
|
|||||||
|
|
||||||
bool ControllerPrivate::sendFeaturesRequest() {
|
bool ControllerPrivate::sendFeaturesRequest() {
|
||||||
if (!_socket->isValid()) {
|
if (!_socket->isValid()) {
|
||||||
QuasarAppUtils::Params::log("scoket is closed!",
|
|
||||||
QuasarAppUtils::Debug);
|
qDebug() << "scoket is closed!";
|
||||||
|
|
||||||
_controller->handleError(PatronumError::ServiceUnavailable);
|
_controller->handleError(PatronumError::ServiceUnavailable);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -50,8 +51,9 @@ bool ControllerPrivate::sendFeaturesRequest() {
|
|||||||
|
|
||||||
bool ControllerPrivate::sendCmd(const QSet<Feature> &result) {
|
bool ControllerPrivate::sendCmd(const QSet<Feature> &result) {
|
||||||
if (!_socket->isValid()) {
|
if (!_socket->isValid()) {
|
||||||
QuasarAppUtils::Params::log("scoket is closed!",
|
|
||||||
QuasarAppUtils::Debug);
|
qDebug() << "scoket is closed!";
|
||||||
|
|
||||||
_controller->handleError(PatronumError::ServiceUnavailable);
|
_controller->handleError(PatronumError::ServiceUnavailable);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -92,8 +94,9 @@ bool ControllerPrivate::connectToHost(bool echo) const {
|
|||||||
if (!_socket->connectToTarget()) {
|
if (!_socket->connectToTarget()) {
|
||||||
|
|
||||||
if (echo) {
|
if (echo) {
|
||||||
QuasarAppUtils::Params::log("Connect to service fail !",
|
|
||||||
QuasarAppUtils::Debug);
|
qDebug() << "Fail to connect to service!";
|
||||||
|
|
||||||
_controller->handleError(PatronumError::ServiceUnavailable);
|
_controller->handleError(PatronumError::ServiceUnavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,8 +115,7 @@ void ControllerPrivate::setEcho(bool echo) {
|
|||||||
void ControllerPrivate::handleReceve(QByteArray data) {
|
void ControllerPrivate::handleReceve(QByteArray data) {
|
||||||
|
|
||||||
if (!_controller) {
|
if (!_controller) {
|
||||||
QuasarAppUtils::Params::log("System error, controller is not inited!",
|
qCritical() << "System error, controller is not inited!";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +127,7 @@ void ControllerPrivate::handleReceve(QByteArray data) {
|
|||||||
for (const auto& pkg: std::as_const(packages)) {
|
for (const auto& pkg: std::as_const(packages)) {
|
||||||
if (!pkg.isValid()) {
|
if (!pkg.isValid()) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Received invalid package!",
|
qDebug() << "Invalid Package received. ";
|
||||||
QuasarAppUtils::Debug);
|
|
||||||
|
|
||||||
_controller->handleError(PatronumError::InvalidPackage);
|
_controller->handleError(PatronumError::InvalidPackage);
|
||||||
|
|
||||||
@ -167,8 +168,8 @@ void ControllerPrivate::handleReceve(QByteArray data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
QuasarAppUtils::Params::log("Wrong command!",
|
qDebug() << "Wrong command!";
|
||||||
QuasarAppUtils::Debug);
|
|
||||||
_controller->handleError(PatronumError::WrongCommand);
|
_controller->handleError(PatronumError::WrongCommand);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -36,9 +36,8 @@ bool InstallerSystemD::install(const QString &executable, const QString& user) {
|
|||||||
QFile templ(":/systemd/SystemD/service.service");
|
QFile templ(":/systemd/SystemD/service.service");
|
||||||
QString name = PCommon::instance()->getServiceName();
|
QString name = PCommon::instance()->getServiceName();
|
||||||
if (!templ.open(QIODevice::ReadOnly)) {
|
if (!templ.open(QIODevice::ReadOnly)) {
|
||||||
QuasarAppUtils::Params::log(QString{"Cannot install %0. The service template not available.\n"}.
|
|
||||||
arg(name),
|
qCritical() << "Cannot install " << name << ". The service template not available.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -59,9 +58,8 @@ bool InstallerSystemD::install(const QString &executable, const QString& user) {
|
|||||||
templ.setFileName(absaluteServicePath());
|
templ.setFileName(absaluteServicePath());
|
||||||
|
|
||||||
if (!templ.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (!templ.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
QuasarAppUtils::Params::log(QString{"Cannot install %0. %1\n"}.
|
|
||||||
arg(name, templ.errorString()),
|
qCritical() << "Cannot install " << name << ". " << templ.errorString();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +85,8 @@ bool InstallerSystemD::uninstall() {
|
|||||||
QString name = PCommon::instance()->getServiceName();
|
QString name = PCommon::instance()->getServiceName();
|
||||||
|
|
||||||
if (!(disable() && QFile::remove(absaluteServicePath()))) {
|
if (!(disable() && QFile::remove(absaluteServicePath()))) {
|
||||||
QuasarAppUtils::Params::log(QString("Cannot uninstall %0. Cannot remove %1. Check permissions.\n").
|
|
||||||
arg(name,
|
qCritical() << "Cannot uninstall " << name << ". Cannot remove " << absaluteServicePath() << ". Check permissions.";
|
||||||
absaluteServicePath()),
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -76,8 +76,7 @@ bool LocalSocket::listen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_server->listen(m_target)) {
|
if (!m_server->listen(m_target)) {
|
||||||
QuasarAppUtils::Params::log("listen is failed! " + m_server->errorString(),
|
qCritical() << "Can't start local server! " << m_server->errorString();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +88,8 @@ bool LocalSocket::connectToTarget() {
|
|||||||
if (!m_socket) {
|
if (!m_socket) {
|
||||||
m_socket = new QLocalSocket(this);
|
m_socket = new QLocalSocket(this);
|
||||||
if (!registerSokcet(m_socket)) {
|
if (!registerSokcet(m_socket)) {
|
||||||
QuasarAppUtils::Params::log("registerSokcet is failed!",
|
|
||||||
QuasarAppUtils::Error);
|
qCritical() << "registerSokcet is failed!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,12 +137,11 @@ void LocalSocket::handleSocketError(QLocalSocket::LocalSocketError) {
|
|||||||
auto _sender = dynamic_cast<QLocalSocket*>(sender());
|
auto _sender = dynamic_cast<QLocalSocket*>(sender());
|
||||||
|
|
||||||
if (!_sender) {
|
if (!_sender) {
|
||||||
QuasarAppUtils::Params::log("Unknown error occurred!", QuasarAppUtils::Error);
|
qCritical() << "Unknown error occurred!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Socket connection fail: " + _sender->errorString(),
|
qWarning() << "Socket connection fail: " << _sender->errorString();
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ bool Parser::parse(const QByteArray &array,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_data.m_data.size() > _data.m_hdr.size) {
|
if (_data.m_data.size() > _data.m_hdr.size) {
|
||||||
QuasarAppUtils::Params::log("Invalid Package received. ",
|
|
||||||
QuasarAppUtils::Warning);
|
qWarning() << "Invalid Package received. ";
|
||||||
_data.reset();
|
_data.reset();
|
||||||
_hdrArray.clear();
|
_hdrArray.clear();
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
void handleTermSignals(int sig) {
|
void handleTermSignals(int sig) {
|
||||||
QuasarAppUtils::Params::log(QString("Shutdown application with %0 signal.").arg(sig),
|
|
||||||
QuasarAppUtils::Info);
|
qInfo() << "Shutdown application with " << sig << " signal.";
|
||||||
QCoreApplication::exit(0);
|
QCoreApplication::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,8 +61,8 @@ ServicePrivate::~ServicePrivate() {
|
|||||||
bool ServicePrivate::sendCmdResult(const QVariantMap &result) {
|
bool ServicePrivate::sendCmdResult(const QVariantMap &result) {
|
||||||
|
|
||||||
if (!_socket->isValid()) {
|
if (!_socket->isValid()) {
|
||||||
QuasarAppUtils::Params::log("scoket is closed!",
|
qCritical() << "socket is closed!";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,8 +71,8 @@ bool ServicePrivate::sendCmdResult(const QVariantMap &result) {
|
|||||||
|
|
||||||
bool ServicePrivate::sendCloseConnection() {
|
bool ServicePrivate::sendCloseConnection() {
|
||||||
if (!_socket->isValid()) {
|
if (!_socket->isValid()) {
|
||||||
QuasarAppUtils::Params::log("scoket is closed!",
|
qCritical() << "socket is closed!";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,8 +82,7 @@ bool ServicePrivate::sendCloseConnection() {
|
|||||||
bool ServicePrivate::install(const QString &user) {
|
bool ServicePrivate::install(const QString &user) {
|
||||||
|
|
||||||
if (!_installer) {
|
if (!_installer) {
|
||||||
QuasarAppUtils::Params::log(errorToString(UnsupportedPlatform),
|
qCritical() << errorToString(UnsupportedPlatform);
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,14 +90,14 @@ bool ServicePrivate::install(const QString &user) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("The service installed successful", QuasarAppUtils::Info);
|
qInfo() << "The service installed successful";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServicePrivate::uninstall() {
|
bool ServicePrivate::uninstall() {
|
||||||
if (!_installer) {
|
if (!_installer) {
|
||||||
QuasarAppUtils::Params::log(errorToString(UnsupportedPlatform),
|
qCritical() << errorToString(UnsupportedPlatform);
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,15 +105,15 @@ bool ServicePrivate::uninstall() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("The service uninstalled successful", QuasarAppUtils::Info);
|
qInfo() << "The service uninstalled successful";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServicePrivate::start() {
|
bool ServicePrivate::start() {
|
||||||
|
|
||||||
if (!_socket->listen()) {
|
if (!_socket->listen()) {
|
||||||
QuasarAppUtils::Params::log("Fail to create a terminal socket!",
|
|
||||||
QuasarAppUtils::Error);
|
qCritical() << "Fail to create a terminal socket!";
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -124,8 +123,7 @@ bool ServicePrivate::start() {
|
|||||||
bool ServicePrivate::startDeamon() {
|
bool ServicePrivate::startDeamon() {
|
||||||
|
|
||||||
if (_socket->isRunning()) {
|
if (_socket->isRunning()) {
|
||||||
QuasarAppUtils::Params::log("Failed to start a service because an another service alredy started",
|
qCritical() << "Failed to start a service because an another service alredy started";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,8 +136,7 @@ bool ServicePrivate::startDeamon() {
|
|||||||
|
|
||||||
qint64 pid;
|
qint64 pid;
|
||||||
if (!proc.startDetached(&pid)) {
|
if (!proc.startDetached(&pid)) {
|
||||||
QuasarAppUtils::Params::log("fail to start detached process: " + proc.errorString(),
|
qCritical() << "fail to start detached process: " + proc.errorString();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +148,7 @@ bool ServicePrivate::startDeamon() {
|
|||||||
pidFile.write(QByteArray::number(pid));
|
pidFile.write(QByteArray::number(pid));
|
||||||
pidFile.close();
|
pidFile.close();
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("The service started successful", QuasarAppUtils::Info);
|
qInfo() << "The service started successful";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,20 +200,20 @@ void ServicePrivate::handleReceve(QByteArray data) {
|
|||||||
|
|
||||||
for (const auto &pkg: std::as_const(packages)) {
|
for (const auto &pkg: std::as_const(packages)) {
|
||||||
if (!pkg.isValid()) {
|
if (!pkg.isValid()) {
|
||||||
QuasarAppUtils::Params::log("receive package is not valid!",
|
|
||||||
QuasarAppUtils::Warning);
|
qWarning() << "Invalid Package received. ";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_service) {
|
if (!_service) {
|
||||||
QuasarAppUtils::Params::log("System error, service is not inited!",
|
|
||||||
QuasarAppUtils::Error);
|
qCritical() << "System error, service is not inited!";
|
||||||
return;;
|
return;;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_socket->isValid()) {
|
if (!_socket->isValid()) {
|
||||||
QuasarAppUtils::Params::log("scoket is closed!",
|
|
||||||
QuasarAppUtils::Error);
|
qCritical() << "scoket is closed!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,8 +223,7 @@ void ServicePrivate::handleReceve(QByteArray data) {
|
|||||||
|
|
||||||
if (!_socket->send(_parser->createPackage(Command::Features,
|
if (!_socket->send(_parser->createPackage(Command::Features,
|
||||||
_service->supportedFeatures()))) {
|
_service->supportedFeatures()))) {
|
||||||
QuasarAppUtils::Params::log("Fail to send ",
|
qCritical() << "Fail to send supported features!";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -251,8 +246,7 @@ void ServicePrivate::handleReceve(QByteArray data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
QuasarAppUtils::Params::log("Wrong command!",
|
qCritical() << "Wrong command!";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8b5fce889fb0819d1614962f315eb2f113511114
|
Subproject commit 8b710eaa67ebc1ae11b071a33936e376198984b0
|
Loading…
x
Reference in New Issue
Block a user