summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/ofilenotify.h
Unidiff
Diffstat (limited to 'libopie2/opiecore/ofilenotify.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/ofilenotify.h63
1 files changed, 57 insertions, 6 deletions
diff --git a/libopie2/opiecore/ofilenotify.h b/libopie2/opiecore/ofilenotify.h
index 3eb917e..5bbf421 100644
--- a/libopie2/opiecore/ofilenotify.h
+++ b/libopie2/opiecore/ofilenotify.h
@@ -39,12 +39,14 @@ _;:,     .>    :=|. This program is free software; you can
39#include <qsignal.h> 39#include <qsignal.h>
40#include <qstring.h> 40#include <qstring.h>
41 41
42namespace Opie { 42namespace Opie {
43namespace Core { 43namespace Core {
44 44
45class OFileNotificationEvent;
46
45/*====================================================================================== 47/*======================================================================================
46 * OFileNotificationType 48 * OFileNotificationType
47 *======================================================================================*/ 49 *======================================================================================*/
48 50
49/** 51/**
50 * @brief An enumerate for the different types of file notifications 52 * @brief An enumerate for the different types of file notifications
@@ -165,19 +167,29 @@ class OFileNotification : public QObject
165 /** 167 /**
166 * @internal 168 * @internal
167 */ 169 */
168 int startWatching( const QString& path, bool sshot = false, OFileNotificationType type = Modify ); 170 int startWatching( const QString& path, bool sshot = false, OFileNotificationType type = Modify );
169 171
170 signals: 172 signals:
171 /** 173 void triggered( const QString&, unsigned int, const QString& );
172 * This signal is emitted if an event happens of the specified type happens to the file being watched. 174 void accessed( const QString& );
173 **/ 175 void modified( const QString& );
174 void triggered( const QString& name ); 176 void attributed( const QString& );
177 void closed( const QString&, bool );
178 void opened( const QString& );
179 void movedTo( const QString&, const QString& );
180 void movedFrom( const QString&, const QString& );
181 void deletedSubdir( const QString&, const QString& );
182 void deletedFile( const QString&, const QString& );
183 void createdSubdir( const QString&, const QString& );
184 void createdFile( const QString&, const QString& );
185 void deleted( const QString& );
186 void unmounted( const QString& );
175 187
176 protected: 188 protected:
177 bool activate(); 189 bool activate( const OFileNotificationEvent* e );
178 190
179 private slots: 191 private slots:
180 void inotifyEventHandler(); 192 void inotifyEventHandler();
181 193
182 private: 194 private:
183 bool registerEventHandler(); 195 bool registerEventHandler();
@@ -188,12 +200,14 @@ class OFileNotification : public QObject
188 QSignal _signal; 200 QSignal _signal;
189 bool _active; 201 bool _active;
190 bool _multi; 202 bool _multi;
191 static QSocketNotifier* _sn; 203 static QSocketNotifier* _sn;
192 int _wd; // inotify watch descriptor 204 int _wd; // inotify watch descriptor
193 static int _fd; // inotify device descriptor 205 static int _fd; // inotify device descriptor
206
207 friend class OFileNotificationEvent;
194}; 208};
195 209
196/*====================================================================================== 210/*======================================================================================
197 * ODirNotification 211 * ODirNotification
198 *======================================================================================*/ 212 *======================================================================================*/
199 213
@@ -224,13 +238,50 @@ class ODirNotification : public QObject
224 int watch( const QString& path, bool sshot = false, OFileNotificationType type = Modify, int recurse = 0 ); 238 int watch( const QString& path, bool sshot = false, OFileNotificationType type = Modify, int recurse = 0 );
225 239
226 signals: 240 signals:
227 /** 241 /**
228 * This signal is emitted if an event happens of the specified type happens to the directory being watched. 242 * This signal is emitted if an event happens of the specified type happens to the directory being watched.
229 **/ 243 **/
230 void triggered( const QString& name ); 244 void triggered( const QString&, unsigned int, const QString& );
245 void accessed( const QString& );
246 void modified( const QString& );
247 void attributed( const QString& );
248 void closed( const QString&, bool );
249 void opened( const QString& );
250 void movedTo( const QString&, const QString& );
251 void movedFrom( const QString&, const QString& );
252 void deletedSubdir( const QString&, const QString& );
253 void deletedFile( const QString&, const QString& );
254 void createdSubdir( const QString&, const QString& );
255 void createdFile( const QString&, const QString& );
256 void deleted( const QString& );
257 void unmounted( const QString& );
258};
259
260/*======================================================================================
261 * OFileNotificationEvent
262 *======================================================================================*/
263
264class OFileNotificationEvent
265{
266 public:
267 OFileNotificationEvent( OFileNotification* parent, int wd, unsigned int mask, unsigned int cookie, const QString& name );
268 ~OFileNotificationEvent();
269 OFileNotification* parent() const { return _parent; };
270 int descriptor() const { return _wd; };
271 unsigned int mask() const { return _mask; };
272 unsigned int cookie() const { return _cookie; };
273 QString name() const { return _name; };
274 void activate() { _parent->activate( this ); };
275
276 private:
277 OFileNotification* _parent;
278 int _wd;
279 unsigned int _mask;
280 unsigned int _cookie;
281 QString _name;
231}; 282};
232 283
233 284
234} 285}
235} 286}
236 287