mirror of
https://github.com/hyprwm/hyprpolkitagent.git
synced 2024-12-25 20:59:49 +01:00
core: nuke sigdaemon
This commit is contained in:
parent
b54db9cf57
commit
12f06d8037
5 changed files with 0 additions and 114 deletions
|
@ -30,8 +30,6 @@ qt_add_executable(hyprpolkitagent
|
|||
src/core/PolkitListener.cpp
|
||||
src/QMLIntegration.cpp
|
||||
src/QMLIntegration.hpp
|
||||
src/SigDaemon.hpp
|
||||
src/SigDaemon.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(hyprpolkitagent
|
||||
|
@ -42,8 +40,6 @@ qt_add_qml_module(hyprpolkitagent
|
|||
SOURCES
|
||||
src/QMLIntegration.cpp
|
||||
src/QMLIntegration.hpp
|
||||
src/SigDaemon.hpp
|
||||
src/SigDaemon.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(hyprpolkitagent
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
#include "SigDaemon.hpp"
|
||||
#include "core/Agent.hpp"
|
||||
|
||||
#include <print>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/signal.h>
|
||||
|
||||
static int sighupFd[2];
|
||||
static int sigtermFd[2];
|
||||
static int sigintFd[2];
|
||||
|
||||
//
|
||||
void CSigDaemon::onSignal(int signo) {
|
||||
char a = 1;
|
||||
if (signo == SIGHUP)
|
||||
::write(sighupFd[0], &a, sizeof(a));
|
||||
else if (signo == SIGINT)
|
||||
::write(sigintFd[0], &a, sizeof(a));
|
||||
else if (signo == SIGTERM)
|
||||
::write(sigtermFd[0], &a, sizeof(a));
|
||||
}
|
||||
|
||||
CSigDaemon::CSigDaemon(QObject* parent) : QObject(parent) {
|
||||
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sighupFd))
|
||||
qFatal("Couldn't create HUP socketpair");
|
||||
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd))
|
||||
qFatal("Couldn't create TERM socketpair");
|
||||
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigintFd))
|
||||
qFatal("Couldn't create INT socketpair");
|
||||
snHup = new QSocketNotifier(sighupFd[1], QSocketNotifier::Read, this);
|
||||
connect(snHup, SIGNAL(activated(QSocketDescriptor)), this, SLOT(handleSigHup()));
|
||||
snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this);
|
||||
connect(snTerm, SIGNAL(activated(QSocketDescriptor)), this, SLOT(handleSigTerm()));
|
||||
snInt = new QSocketNotifier(sigintFd[1], QSocketNotifier::Read, this);
|
||||
connect(snInt, SIGNAL(activated(QSocketDescriptor)), this, SLOT(handleSigInt()));
|
||||
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_handler = onSignal;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_flags |= SA_RESTART;
|
||||
|
||||
if (sigaction(SIGHUP, &sa, 0))
|
||||
std::print(stderr, "sigaction for hup failed\n");
|
||||
|
||||
if (sigaction(SIGTERM, &sa, 0))
|
||||
std::print(stderr, "sigaction for term failed\n");
|
||||
|
||||
if (sigaction(SIGINT, &sa, 0))
|
||||
std::print(stderr, "sigaction for int failed\n");
|
||||
}
|
||||
|
||||
void CSigDaemon::handleSigHup() {
|
||||
std::print("> signal received: SIGHUP\n");
|
||||
snHup->setEnabled(false);
|
||||
char tmp;
|
||||
::read(sighupFd[1], &tmp, sizeof(tmp));
|
||||
g_pAgent->resetAuthState();
|
||||
snHup->setEnabled(true);
|
||||
}
|
||||
|
||||
void CSigDaemon::handleSigInt() {
|
||||
std::print("> signal received: SIGINT\n");
|
||||
snInt->setEnabled(false);
|
||||
char tmp;
|
||||
::read(sigintFd[1], &tmp, sizeof(tmp));
|
||||
g_pAgent->resetAuthState();
|
||||
snInt->setEnabled(true);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void CSigDaemon::handleSigTerm() {
|
||||
std::print("> signal received: SIGTERM\n");
|
||||
snTerm->setEnabled(false);
|
||||
char tmp;
|
||||
::read(sigtermFd[1], &tmp, sizeof(tmp));
|
||||
g_pAgent->resetAuthState();
|
||||
snTerm->setEnabled(true);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QApplication>
|
||||
#include <QObject>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
class CSigDaemon : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
CSigDaemon(QObject* parent = nullptr);
|
||||
|
||||
static void onSignal(int signo);
|
||||
|
||||
public slots:
|
||||
void handleSigHup();
|
||||
void handleSigTerm();
|
||||
void handleSigInt();
|
||||
|
||||
private:
|
||||
QSocketNotifier* snHup = nullptr;
|
||||
QSocketNotifier* snTerm = nullptr;
|
||||
QSocketNotifier* snInt = nullptr;
|
||||
};
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "Agent.hpp"
|
||||
#include "../QMLIntegration.hpp"
|
||||
#include "../SigDaemon.hpp"
|
||||
|
||||
CAgent::CAgent() {
|
||||
;
|
||||
|
@ -24,8 +23,6 @@ bool CAgent::start() {
|
|||
char* argv = (char*)"hyprpolkitagent";
|
||||
QApplication app(argc, &argv);
|
||||
|
||||
sigDaemon = makeShared<CSigDaemon>();
|
||||
|
||||
app.setApplicationName("Hyprland Polkit Agent");
|
||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ using namespace Hyprutils::Memory;
|
|||
#define WP CWeakPointer
|
||||
|
||||
class CQMLIntegration;
|
||||
class CSigDaemon;
|
||||
|
||||
class CAgent {
|
||||
public:
|
||||
|
@ -40,7 +39,6 @@ class CAgent {
|
|||
} lastAuthResult;
|
||||
|
||||
CPolkitListener listener;
|
||||
SP<CSigDaemon> sigDaemon;
|
||||
SP<PolkitQt1::UnixSessionSubject> sessionSubject;
|
||||
|
||||
bool resultReady();
|
||||
|
|
Loading…
Reference in a new issue