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