parent
953908831e
commit
978e9bfa5f
@ -1,38 +0,0 @@
|
||||
#include "ipcfilewatcher.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
IPCFileWatcher::IPCFileWatcher(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
QDir targetDir("/dev/shm/lubuntu-update");
|
||||
bool couldRemove = targetDir.removeRecursively();
|
||||
if (!couldRemove) {
|
||||
qCritical() << "Could not clear IPC directory. Ensure that /dev/shm and /dev/shm/lubuntu-update are world-readable and world-writable.";
|
||||
initFailed = true;
|
||||
return;
|
||||
}
|
||||
targetDir.mkdir("/dev/shm/lubuntu-update");
|
||||
QFileSystemWatcher *watcher = new QFileSystemWatcher(QStringList() << "/dev/shm/lubuntu-update");
|
||||
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &IPCFileWatcher::checkForShowWindowFile);
|
||||
initFailed = false;
|
||||
}
|
||||
|
||||
bool IPCFileWatcher::didInitFail()
|
||||
{
|
||||
return initFailed;
|
||||
}
|
||||
|
||||
void IPCFileWatcher::checkForShowWindowFile()
|
||||
{
|
||||
QFile flagFile("/dev/shm/lubuntu-update/lubuntu-update-show-win");
|
||||
if (flagFile.exists()) {
|
||||
flagFile.remove();
|
||||
emit showWindowFlagDetected();
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef IPCFILEWATCHER_H
|
||||
#define IPCFILEWATCHER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class IPCFileWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IPCFileWatcher(QObject *parent = nullptr);
|
||||
bool didInitFail();
|
||||
|
||||
signals:
|
||||
void showWindowFlagDetected();
|
||||
|
||||
private:
|
||||
bool initFailed;
|
||||
|
||||
void checkForShowWindowFile();
|
||||
};
|
||||
|
||||
#endif // IPCFILEWATCHER_H
|
@ -0,0 +1,6 @@
|
||||
#include "windowshowwatcher.h"
|
||||
|
||||
void WindowShowWatcher::showWindow()
|
||||
{
|
||||
emit showWindowTriggered();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#ifndef WINDOWSHOWWATCHER_H
|
||||
#define WINDOWSHOWWATCHER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDBusAbstractAdaptor>
|
||||
#include <QDBusVariant>
|
||||
|
||||
class WindowShowWatcher : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "me.lubuntu.LubuntuUpdate.window")
|
||||
|
||||
public:
|
||||
explicit WindowShowWatcher(QObject *obj) : QDBusAbstractAdaptor(obj) {}
|
||||
|
||||
public slots:
|
||||
void showWindow();
|
||||
|
||||
signals:
|
||||
void showWindowTriggered();
|
||||
};
|
||||
|
||||
#endif // WINDOWSHOWWATCHER_H
|
Loading…
Reference in new issue