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 #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
00066 #ifdef HAVE_FAM
00067 FAMRequest fr;
00068 #endif
00069
00070 #ifdef HAVE_DNOTIFY
00071 int dn_fd;
00072 #endif
00073 };
00074
00075 typedef QMap<QString,Entry> EntryMap;
00076
00077 KDirWatchPrivate();
00078 ~KDirWatchPrivate();
00079
00080 void resetList (KDirWatch*,bool);
00081 void useFreq(Entry* e, int newFreq);
00082 void addEntry(KDirWatch*,const QString&, Entry*, bool);
00083 void removeEntry(KDirWatch*,const QString&, Entry*);
00084 bool stopEntryScan(KDirWatch*, Entry*);
00085 bool restartEntryScan(KDirWatch*, Entry*, bool );
00086 void stopScan(KDirWatch*);
00087 void startScan(KDirWatch*, bool, bool);
00088
00089 void removeEntries(KDirWatch*);
00090 void statistics();
00091
00092 Entry* entry(const QString&);
00093 int scanEntry(Entry* e);
00094 void emitEvent(Entry* e, int event, const QString &fileName = QString::null);
00095
00096
00097 void ref() { m_ref++; }
00098 bool deref() { return ( --m_ref == 0 ); }
00099
00100 static bool isNoisyFile( const char *filename );
00101
00102 public slots:
00103 void slotRescan();
00104 void famEventReceived();
00105 void slotActivated();
00106 void slotRemoveDelayed();
00107
00108 public:
00109 QTimer *timer;
00110 EntryMap m_mapEntries;
00111
00112 int freq;
00113 int statEntries;
00114 int m_nfsPollInterval, m_PollInterval;
00115 int m_ref;
00116 bool useStat(Entry*);
00117
00118 bool delayRemove;
00119 QPtrList<Entry> removeList;
00120
00121 bool rescan_all;
00122 QTimer rescan_timer;
00123 bool dir_isRO(const QString & _path );
00124 #ifdef HAVE_FAM
00125 QSocketNotifier *sn;
00126 FAMConnection fc;
00127 bool use_fam;
00128
00129 void checkFAMEvent(FAMEvent*);
00130 bool useFAM(Entry*);
00131 #endif
00132
00133 #ifdef HAVE_DNOTIFY
00134 bool supports_dnotify;
00135 int mPipe[2];
00136 QSocketNotifier *mSn;
00137 QIntDict<Entry> fd_Entry;
00138
00139 static void dnotify_handler(int, siginfo_t *si, void *);
00140 static void dnotify_sigio_handler(int, siginfo_t *si, void *);
00141 bool useDNotify(Entry*);
00142 #endif
00143 };
00144
00145 #endif // KDIRWATCH_P_H
00146
This file is part of the documentation for kio Library Version 3.3.90.