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