#ifndef DCINOTIFY_H
#define DCINOTIFY_H

#ifndef WIN32

#include <QObject>
#include <QThread>
#include <QList>
#include <QDir>
#include <QMap>
#include <QMapIterator>
#include <QMutex>

enum eIEVENT_TYPE {
    eICREATE = 0,
    eIDELETE,
    eICHANGE,
    eIMOVE
};

enum eIEVENT_OBJ {
    eIFILE = 0,
    eIDIRECTORY
};

struct InotifyObject {
    eIEVENT_OBJ event_obj;
    eIEVENT_TYPE event_type;
    QString name;
};

class DCInotify : public QThread {
    Q_OBJECT

public:
    DCInotify();
    ~DCInotify();

    void run();
    void addDirectory(QString);
    bool init_inotify();
    void setRecursive(bool);
    void setInterval(int secs);
    int getInterval();

signals:
    void fs_event(InotifyObject*);

private:

    void addSubDirs(QString);

    bool recursive;

    int ino_fd;
    int shot_c;


    QMap<QDir*, int> dirs;
    QList<InotifyObject*> wait_q;

    QMutex mutex;

};

#endif //WIN32

#endif // DCINOTIFY_H
