Diffstat (limited to 'microkde/kio/kio/kdirwatch_p.h') (more/less context) (show whitespace changes)
-rw-r--r-- | microkde/kio/kio/kdirwatch_p.h | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/microkde/kio/kio/kdirwatch_p.h b/microkde/kio/kio/kdirwatch_p.h new file mode 100644 index 0000000..0ab482f --- a/dev/null +++ b/microkde/kio/kio/kdirwatch_p.h | |||
@@ -0,0 +1,153 @@ | |||
1 | /* Private Header for class of KDirWatchPrivate | ||
2 | * | ||
3 | * this separate header file is needed for MOC processing | ||
4 | * because KDirWatchPrivate has signals and slots | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | Enhanced Version of the file for platform independent KDE tools. | ||
9 | Copyright (c) 2004 Ulf Schenk | ||
10 | |||
11 | $Id$ | ||
12 | */ | ||
13 | |||
14 | #ifndef _KDIRWATCH_P_H | ||
15 | #define _KDIRWATCH_P_H | ||
16 | |||
17 | #ifdef HAVE_FAM | ||
18 | #include <fam.h> | ||
19 | #endif | ||
20 | |||
21 | #include <qptrlist.h> | ||
22 | |||
23 | #include <kdirwatch.h> | ||
24 | |||
25 | #include <ctime> | ||
26 | |||
27 | #define invalid_ctime ((time_t)-1) | ||
28 | |||
29 | /* KDirWatchPrivate is a singleton and does the watching | ||
30 | * for every KDirWatch instance in the application. | ||
31 | */ | ||
32 | class KDirWatchPrivate : public QObject | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | |||
37 | enum entryStatus { Normal = 0, NonExistent }; | ||
38 | enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, FAMMode }; | ||
39 | enum { NoChange=0, Changed=1, Created=2, Deleted=4 }; | ||
40 | |||
41 | struct Client { | ||
42 | KDirWatch* instance; | ||
43 | int count; | ||
44 | // did the instance stop watching | ||
45 | bool watchingStopped; | ||
46 | // events blocked when stopped | ||
47 | int pending; | ||
48 | }; | ||
49 | |||
50 | class Entry | ||
51 | { | ||
52 | public: | ||
53 | // the last observed modification time | ||
54 | time_t m_ctime; | ||
55 | // the last observed link count | ||
56 | int m_nlink; | ||
57 | entryStatus m_status; | ||
58 | entryMode m_mode; | ||
59 | bool isDir; | ||
60 | // instances interested in events | ||
61 | QPtrList<Client> m_clients; | ||
62 | // nonexistent entries of this directory | ||
63 | QPtrList<Entry> m_entries; | ||
64 | QString path; | ||
65 | |||
66 | int msecLeft, freq; | ||
67 | |||
68 | void addClient(KDirWatch*); | ||
69 | void removeClient(KDirWatch*); | ||
70 | int clients(); | ||
71 | bool isValid() { return m_clients.count() || m_entries.count(); } | ||
72 | |||
73 | #ifdef HAVE_FAM | ||
74 | FAMRequest fr; | ||
75 | #endif | ||
76 | |||
77 | #ifdef HAVE_DNOTIFY | ||
78 | int dn_fd; | ||
79 | bool dn_dirty; | ||
80 | void propagate_dirty(); | ||
81 | #endif | ||
82 | }; | ||
83 | |||
84 | typedef QMap<QString,Entry> EntryMap; | ||
85 | |||
86 | KDirWatchPrivate(); | ||
87 | ~KDirWatchPrivate(); | ||
88 | |||
89 | void resetList (KDirWatch*,bool); | ||
90 | void useFreq(Entry* e, int newFreq); | ||
91 | void addEntry(KDirWatch*,const QString&, Entry*, bool); | ||
92 | void removeEntry(KDirWatch*,const QString&, Entry*); | ||
93 | bool stopEntryScan(KDirWatch*, Entry*); | ||
94 | bool restartEntryScan(KDirWatch*, Entry*, bool ); | ||
95 | void stopScan(KDirWatch*); | ||
96 | void startScan(KDirWatch*, bool, bool); | ||
97 | |||
98 | void removeEntries(KDirWatch*); | ||
99 | void statistics(); | ||
100 | |||
101 | Entry* entry(const QString&); | ||
102 | int scanEntry(Entry* e); | ||
103 | void emitEvent(Entry* e, int event, const QString &fileName = QString::null); | ||
104 | |||
105 | // Memory management - delete when last KDirWatch gets deleted | ||
106 | void ref() { m_ref++; } | ||
107 | bool deref() { return ( --m_ref == 0 ); } | ||
108 | |||
109 | public slots: | ||
110 | void slotRescan(); | ||
111 | void famEventReceived(); // for FAM | ||
112 | void slotActivated(); // for DNOTIFY | ||
113 | void slotRemoveDelayed(); | ||
114 | |||
115 | public: | ||
116 | QTimer *timer; | ||
117 | EntryMap m_mapEntries; | ||
118 | |||
119 | private: | ||
120 | int freq; | ||
121 | int statEntries; | ||
122 | int m_nfsPollInterval, m_PollInterval; | ||
123 | int m_ref; | ||
124 | bool useStat(Entry*); | ||
125 | |||
126 | bool delayRemove; | ||
127 | QPtrList<Entry> removeList; | ||
128 | |||
129 | #ifdef HAVE_FAM | ||
130 | QSocketNotifier *sn; | ||
131 | FAMConnection fc; | ||
132 | bool use_fam; | ||
133 | |||
134 | void checkFAMEvent(FAMEvent*); | ||
135 | bool useFAM(Entry*); | ||
136 | #endif | ||
137 | |||
138 | #ifdef HAVE_DNOTIFY | ||
139 | bool supports_dnotify; | ||
140 | bool rescan_all; | ||
141 | int mPipe[2]; | ||
142 | QTimer mTimer; | ||
143 | QSocketNotifier *mSn; | ||
144 | QIntDict<Entry> fd_Entry; | ||
145 | |||
146 | static void dnotify_handler(int, siginfo_t *si, void *); | ||
147 | static void dnotify_sigio_handler(int, siginfo_t *si, void *); | ||
148 | bool useDNotify(Entry*); | ||
149 | #endif | ||
150 | }; | ||
151 | |||
152 | #endif // KDIRWATCH_P_H | ||
153 | |||