mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-18 20:02:17 +03:00
c16fd94150
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.
72 lines
1.4 KiB
C++
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
|