2011-04-06 13:48:02 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
|
|
|
*
|
|
|
|
* Originally based on example copyright (c) Ashish Shukla
|
|
|
|
*
|
2012-07-20 19:13:23 +04:00
|
|
|
* Ported to use QSocketNotifier later instead of a thread loop
|
|
|
|
*
|
2011-04-06 13:48:02 +04:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
2011-03-16 16:50:34 +03:00
|
|
|
|
|
|
|
#ifndef MIRALL_INOTIFY_H
|
|
|
|
#define MIRALL_INOTIFY_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2011-04-04 20:41:14 +04:00
|
|
|
#include <QMap>
|
2011-03-16 16:50:34 +03:00
|
|
|
#include <QString>
|
|
|
|
#include <QThread>
|
|
|
|
|
2012-07-20 19:13:23 +04:00
|
|
|
class QSocketNotifier;
|
|
|
|
|
2011-03-16 16:50:34 +03:00
|
|
|
namespace Mirall
|
|
|
|
{
|
|
|
|
|
|
|
|
class INotify : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-12-04 21:15:37 +04:00
|
|
|
INotify(QObject *parent, int mask);
|
2011-03-16 16:50:34 +03:00
|
|
|
~INotify();
|
|
|
|
|
2013-08-07 16:59:41 +04:00
|
|
|
bool addPath(const QString &name);
|
2011-03-17 09:13:30 +03:00
|
|
|
void removePath(const QString &name);
|
|
|
|
|
|
|
|
QStringList directories() const;
|
2011-03-16 16:50:34 +03:00
|
|
|
|
2012-07-20 19:13:23 +04:00
|
|
|
protected slots:
|
|
|
|
void slotActivated(int);
|
|
|
|
|
|
|
|
signals:
|
2011-03-19 23:18:43 +03:00
|
|
|
void notifyEvent(int mask, int cookie, const QString &name);
|
2011-03-16 16:50:34 +03:00
|
|
|
|
|
|
|
private:
|
2012-07-20 19:13:23 +04:00
|
|
|
int _fd;
|
|
|
|
QSocketNotifier *_notifier;
|
2011-03-17 09:13:30 +03:00
|
|
|
// the mask is shared for all paths
|
|
|
|
int _mask;
|
2011-04-04 20:41:14 +04:00
|
|
|
QMap<QString, int> _wds;
|
2012-07-20 19:13:23 +04:00
|
|
|
|
|
|
|
size_t _buffer_size;
|
|
|
|
char *_buffer;
|
2011-03-16 16:50:34 +03:00
|
|
|
};
|
2012-07-20 19:13:23 +04:00
|
|
|
|
2011-03-16 16:50:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|