00001
00002
00003
00004
00005
00006
00007
#ifndef _KDIRWATCH_P_H
00008
#define _KDIRWATCH_P_H
00009
00010
#ifdef HAVE_FAM
00011
#include <fam.h>
00012
#endif
00013
00014
#include <ctime>
00015
00016
#define invalid_ctime ((time_t)-1)
00017
00018
00019
00020
00021
class KDirWatchPrivate :
public QObject
00022 {
00023 Q_OBJECT
00024
public:
00025
00026
enum entryStatus { Normal = 0, NonExistent };
00027
enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, FAMMode };
00028
enum { NoChange=0, Changed=1, Created=2, Deleted=4 };
00029
00030
struct Client {
00031
KDirWatch*
instance;
00032
int count;
00033
00034
bool watchingStopped;
00035
00036
int pending;
00037 };
00038
00039
class Entry
00040 {
00041
public:
00042
00043 time_t m_ctime;
00044
00045
int m_nlink;
00046 entryStatus m_status;
00047 entryMode m_mode;
00048
bool isDir;
00049
00050
QPtrList<Client> m_clients;
00051
00052
QPtrList<Entry> m_entries;
00053
QString path;
00054
00055
int msecLeft, freq;
00056
00057
void addClient(
KDirWatch*);
00058
void removeClient(
KDirWatch*);
00059
int clients();
00060
bool isValid() {
return m_clients.count() || m_entries.count(); }
00061
00062
bool dirty;
00063
void propagate_dirty();
00064
00065
#ifdef HAVE_FAM
00066
FAMRequest fr;
00067
#endif
00068
00069
#ifdef HAVE_DNOTIFY
00070
int dn_fd;
00071
#endif
00072
};
00073
00074
typedef QMap<QString,Entry> EntryMap;
00075
00076 KDirWatchPrivate();
00077 ~KDirWatchPrivate();
00078
00079
void resetList (
KDirWatch*,
bool);
00080
void useFreq(Entry* e,
int newFreq);
00081
void addEntry(
KDirWatch*,
const QString&, Entry*,
bool);
00082
void removeEntry(
KDirWatch*,
const QString&, Entry*);
00083
bool stopEntryScan(
KDirWatch*, Entry*);
00084
bool restartEntryScan(
KDirWatch*, Entry*,
bool );
00085
void stopScan(
KDirWatch*);
00086
void startScan(
KDirWatch*,
bool,
bool);
00087
00088
void removeEntries(
KDirWatch*);
00089
void statistics();
00090
00091 Entry* entry(
const QString&);
00092
int scanEntry(Entry* e);
00093
void emitEvent(Entry* e,
int event,
const QString &fileName = QString::null);
00094
00095
00096
void ref() { m_ref++; }
00097
bool deref() {
return ( --m_ref == 0 ); }
00098
00099
static bool isNoisyFile(
const char *filename );
00100
00101
public slots:
00102
void slotRescan();
00103
void famEventReceived();
00104
void slotActivated();
00105
void slotRemoveDelayed();
00106
00107
public:
00108
QTimer *timer;
00109 EntryMap m_mapEntries;
00110
00111
int freq;
00112
int statEntries;
00113
int m_nfsPollInterval, m_PollInterval;
00114
int m_ref;
00115
bool useStat(Entry*);
00116
00117
bool delayRemove;
00118
QPtrList<Entry> removeList;
00119
00120
bool rescan_all;
00121
QTimer rescan_timer;
00122
00123
#ifdef HAVE_FAM
00124
QSocketNotifier *sn;
00125 FAMConnection fc;
00126
bool use_fam;
00127
00128
void checkFAMEvent(FAMEvent*);
00129
bool useFAM(Entry*);
00130
#endif
00131
00132
#ifdef HAVE_DNOTIFY
00133
bool supports_dnotify;
00134
int mPipe[2];
00135
QSocketNotifier *mSn;
00136
QIntDict<Entry> fd_Entry;
00137
00138
static void dnotify_handler(
int, siginfo_t *si,
void *);
00139
static void dnotify_sigio_handler(
int, siginfo_t *si,
void *);
00140
bool useDNotify(Entry*);
00141
#endif
00142
};
00143
00144
#endif // KDIRWATCH_P_H
00145