nextcloud-desktop/src/mirall/inotify.h
Duncan Mac-Vicar P c16fd94150 Fix crash at shutdown.
Menu contains actions from the folders so we should
first delete the tray and the folders later.

Also change QHash in inotify watcher map to QMap as QHash
gives weird crashes with the inotify thread.
2011-04-05 18:31:19 +02:00

72 lines
1.4 KiB
C++

/**
Based on example by:
Copyright (c) Ashish Shukla
This is licensed under GNU GPL v2 or later.
For license text, Refer to the the file COPYING or visit
http://www.gnu.org/licenses/gpl.txt .
*/
#ifndef MIRALL_INOTIFY_H
#define MIRALL_INOTIFY_H
#include <QObject>
#include <QMap>
#include <QString>
#include <QThread>
namespace Mirall
{
class INotify : public QObject
{
Q_OBJECT
public:
INotify(int mask);
~INotify();
static void initialize();
static void cleanup();
void addPath(const QString &name);
void removePath(const QString &name);
QStringList directories() const;
signals:
void notifyEvent(int mask, int cookie, const QString &name);
private:
class INotifyThread : public QThread
{
int _fd;
QMap<int, INotify*> _map;
public:
INotifyThread(int fd);
~INotifyThread();
void registerForNotification(INotify*, int);
void unregisterForNotification(INotify*);
// fireEvent happens from the inotify thread
// but addPath comes from the main thread
protected:
void run();
private:
size_t _buffer_size;
char *_buffer;
};
//INotify(int wd);
void fireEvent(int mask, int cookie, int wd, char *name);
static int s_fd;
static INotifyThread* s_thread;
// the mask is shared for all paths
int _mask;
QMap<QString, int> _wds;
};
}
#endif