parent
29c1eb8abb
commit
1ccbb8b1a0
@ -0,0 +1,38 @@
|
|||||||
|
#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();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
#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,11 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Exec=/usr/bin/lubuntu-update
|
||||||
|
Name=Lubuntu Update
|
||||||
|
GenericName=Lubuntu Update
|
||||||
|
Comment=View available updates and optionally install them
|
||||||
|
Icon=system-software-update
|
||||||
|
Type=Application
|
||||||
|
Version=0.1
|
||||||
|
Categories=System;Settings;
|
||||||
|
Keywords=upgrade;update
|
||||||
|
Terminal=false
|
Loading…
Reference in new issue