Diffstat (limited to 'libopie2/opiecore/linux/ofilenotify.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/linux/ofilenotify.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libopie2/opiecore/linux/ofilenotify.h b/libopie2/opiecore/linux/ofilenotify.h index 05343b9..17e6b5d 100644 --- a/libopie2/opiecore/linux/ofilenotify.h +++ b/libopie2/opiecore/linux/ofilenotify.h | |||
@@ -90,48 +90,49 @@ class OFileNotificationEvent; | |||
90 | * | 90 | * |
91 | * This enumerate provides a means to specify the type of events that you are interest in. | 91 | * This enumerate provides a means to specify the type of events that you are interest in. |
92 | * Valid values are: | 92 | * Valid values are: |
93 | * <ul> | 93 | * <ul> |
94 | * <li>Access: The file was accessed (read) | 94 | * <li>Access: The file was accessed (read) |
95 | * <li>Modify The file was modified (write,truncate) | 95 | * <li>Modify The file was modified (write,truncate) |
96 | * <li>Attrib = The file had its attributes changed (chmod,chown,chgrp) | 96 | * <li>Attrib = The file had its attributes changed (chmod,chown,chgrp) |
97 | * <li>CloseWrite = Writable file was closed | 97 | * <li>CloseWrite = Writable file was closed |
98 | * <li>CloseNoWrite = Unwritable file was closed | 98 | * <li>CloseNoWrite = Unwritable file was closed |
99 | * <li>Open = File was opened | 99 | * <li>Open = File was opened |
100 | * <li>MovedFrom = File was moved from X | 100 | * <li>MovedFrom = File was moved from X |
101 | * <li>MovedTo = File was moved to Y | 101 | * <li>MovedTo = File was moved to Y |
102 | * <li>DeleteSubdir = Subdir was deleted | 102 | * <li>DeleteSubdir = Subdir was deleted |
103 | * <li>DeleteFile = Subfile was deleted | 103 | * <li>DeleteFile = Subfile was deleted |
104 | * <li>CreateSubdir = Subdir was created | 104 | * <li>CreateSubdir = Subdir was created |
105 | * <li>CreateFile = Subfile was created | 105 | * <li>CreateFile = Subfile was created |
106 | * <li>DeleteSelf = Self was deleted | 106 | * <li>DeleteSelf = Self was deleted |
107 | * <li>Unmount = The backing filesystem was unmounted | 107 | * <li>Unmount = The backing filesystem was unmounted |
108 | * </ul> | 108 | * </ul> |
109 | * | 109 | * |
110 | **/ | 110 | **/ |
111 | 111 | ||
112 | enum OFileNotificationType | 112 | enum OFileNotificationType |
113 | { | 113 | { |
114 | Nothing = 0, | ||
114 | Access = IN_ACCESS, | 115 | Access = IN_ACCESS, |
115 | Modify = IN_MODIFY, | 116 | Modify = IN_MODIFY, |
116 | Attrib = IN_ATTRIB, | 117 | Attrib = IN_ATTRIB, |
117 | CloseWrite = IN_CLOSE_WRITE, | 118 | CloseWrite = IN_CLOSE_WRITE, |
118 | CloseNoWrite = IN_CLOSE_NOWRITE, | 119 | CloseNoWrite = IN_CLOSE_NOWRITE, |
119 | Open = IN_OPEN, | 120 | Open = IN_OPEN, |
120 | MovedFrom = IN_MOVED_FROM, | 121 | MovedFrom = IN_MOVED_FROM, |
121 | MovedTo = IN_MOVED_TO, | 122 | MovedTo = IN_MOVED_TO, |
122 | DeleteSubdir = IN_DELETE_SUBDIR, | 123 | DeleteSubdir = IN_DELETE_SUBDIR, |
123 | DeleteFile = IN_DELETE_FILE, | 124 | DeleteFile = IN_DELETE_FILE, |
124 | CreateSubdir = IN_CREATE_SUBDIR, | 125 | CreateSubdir = IN_CREATE_SUBDIR, |
125 | CreateFile = IN_CREATE_FILE, | 126 | CreateFile = IN_CREATE_FILE, |
126 | DeleteSelf = IN_DELETE_SELF, | 127 | DeleteSelf = IN_DELETE_SELF, |
127 | Unmount = IN_UNMOUNT, | 128 | Unmount = IN_UNMOUNT, |
128 | _QueueOverflow = IN_Q_OVERFLOW, /* Internal, don't use this in client code */ | 129 | _QueueOverflow = IN_Q_OVERFLOW, /* Internal, don't use this in client code */ |
129 | _Ignored = IN_IGNORED, /* Internal, don't use this in client code */ | 130 | _Ignored = IN_IGNORED, /* Internal, don't use this in client code */ |
130 | }; | 131 | }; |
131 | 132 | ||
132 | /*====================================================================================== | 133 | /*====================================================================================== |
133 | * OFileNotification | 134 | * OFileNotification |
134 | *======================================================================================*/ | 135 | *======================================================================================*/ |
135 | 136 | ||
136 | /** | 137 | /** |
137 | * @brief Represents a file notification | 138 | * @brief Represents a file notification |
@@ -177,48 +178,52 @@ class OFileNotification : public QObject | |||
177 | * This sample program automatically terminates when the file "/tmp/quit" has been accessed. | 178 | * This sample program automatically terminates when the file "/tmp/quit" has been accessed. |
178 | * | 179 | * |
179 | * | 180 | * |
180 | * The @a receiver is the receiving object and the @a member is the slot. | 181 | * The @a receiver is the receiving object and the @a member is the slot. |
181 | **/ | 182 | **/ |
182 | static bool singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type = Modify ); | 183 | static bool singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type = Modify ); |
183 | /** | 184 | /** |
184 | * Starts to watch for @a type changes to @a path. Set @a sshot to True if you want to be notified only once. | 185 | * Starts to watch for @a type changes to @a path. Set @a sshot to True if you want to be notified only once. |
185 | * Note that in that case it may be more convenient to use @ref OFileNotification::singleShot() then. | 186 | * Note that in that case it may be more convenient to use @ref OFileNotification::singleShot() then. |
186 | **/ | 187 | **/ |
187 | int watch( const QString& path, bool sshot = false, OFileNotificationType type = Modify ); | 188 | int watch( const QString& path, bool sshot = false, OFileNotificationType type = Modify ); |
188 | /** | 189 | /** |
189 | * Stop watching for file events. | 190 | * Stop watching for file events. |
190 | **/ | 191 | **/ |
191 | void stop(); | 192 | void stop(); |
192 | /** | 193 | /** |
193 | * @returns the notification type as set by @ref start(). | 194 | * @returns the notification type as set by @ref start(). |
194 | **/ | 195 | **/ |
195 | OFileNotificationType type() const; | 196 | OFileNotificationType type() const; |
196 | /** | 197 | /** |
197 | * @returns the path to the file being watched by this instance. | 198 | * @returns the path to the file being watched by this instance. |
198 | **/ | 199 | **/ |
199 | QString path() const; | 200 | QString path() const; |
200 | /** | 201 | /** |
202 | * @returns if the notification is single-shot | ||
203 | */ | ||
204 | bool isSingleShot() const; | ||
205 | /** | ||
201 | * @returns if a file is currently being watched. | 206 | * @returns if a file is currently being watched. |
202 | **/ | 207 | **/ |
203 | bool isActive() const; | 208 | bool isActive() const; |
204 | /** | 209 | /** |
205 | * @internal | 210 | * @internal |
206 | */ | 211 | */ |
207 | int startWatching( const QString& path, bool sshot = false, OFileNotificationType type = Modify ); | 212 | int startWatching( const QString& path, bool sshot = false, OFileNotificationType type = Modify ); |
208 | 213 | ||
209 | signals: | 214 | signals: |
210 | void triggered( const QString&, unsigned int, const QString& ); | 215 | void triggered( const QString&, unsigned int, const QString& ); |
211 | void accessed( const QString& ); | 216 | void accessed( const QString& ); |
212 | void modified( const QString& ); | 217 | void modified( const QString& ); |
213 | void attributed( const QString& ); | 218 | void attributed( const QString& ); |
214 | void closed( const QString&, bool ); | 219 | void closed( const QString&, bool ); |
215 | void opened( const QString& ); | 220 | void opened( const QString& ); |
216 | void movedTo( const QString&, const QString& ); | 221 | void movedTo( const QString&, const QString& ); |
217 | void movedFrom( const QString&, const QString& ); | 222 | void movedFrom( const QString&, const QString& ); |
218 | void deletedSubdir( const QString&, const QString& ); | 223 | void deletedSubdir( const QString&, const QString& ); |
219 | void deletedFile( const QString&, const QString& ); | 224 | void deletedFile( const QString&, const QString& ); |
220 | void createdSubdir( const QString&, const QString& ); | 225 | void createdSubdir( const QString&, const QString& ); |
221 | void createdFile( const QString&, const QString& ); | 226 | void createdFile( const QString&, const QString& ); |
222 | void deleted( const QString& ); | 227 | void deleted( const QString& ); |
223 | void unmounted( const QString& ); | 228 | void unmounted( const QString& ); |
224 | 229 | ||
@@ -271,48 +276,56 @@ class ODirNotification : public QObject | |||
271 | * Starts to watch for @a type changes to @a path. Recurse @a recurse levels down the filesystem tree, | 276 | * Starts to watch for @a type changes to @a path. Recurse @a recurse levels down the filesystem tree, |
272 | * use 0 for no recursion and -1 for unlimited recursion. | 277 | * use 0 for no recursion and -1 for unlimited recursion. |
273 | * Set @a sshot to True if you want to be notified only once. | 278 | * Set @a sshot to True if you want to be notified only once. |
274 | **/ | 279 | **/ |
275 | int watch( const QString& path, bool sshot = false, OFileNotificationType type = Modify, int recurse = 0 ); | 280 | int watch( const QString& path, bool sshot = false, OFileNotificationType type = Modify, int recurse = 0 ); |
276 | 281 | ||
277 | signals: | 282 | signals: |
278 | /** | 283 | /** |
279 | * This signal is emitted if an event happens of the specified type happens to the directory being watched. | 284 | * This signal is emitted if an event happens of the specified type happens to the directory being watched. |
280 | **/ | 285 | **/ |
281 | void triggered( const QString&, unsigned int, const QString& ); | 286 | void triggered( const QString&, unsigned int, const QString& ); |
282 | void accessed( const QString& ); | 287 | void accessed( const QString& ); |
283 | void modified( const QString& ); | 288 | void modified( const QString& ); |
284 | void attributed( const QString& ); | 289 | void attributed( const QString& ); |
285 | void closed( const QString&, bool ); | 290 | void closed( const QString&, bool ); |
286 | void opened( const QString& ); | 291 | void opened( const QString& ); |
287 | void movedTo( const QString&, const QString& ); | 292 | void movedTo( const QString&, const QString& ); |
288 | void movedFrom( const QString&, const QString& ); | 293 | void movedFrom( const QString&, const QString& ); |
289 | void deletedSubdir( const QString&, const QString& ); | 294 | void deletedSubdir( const QString&, const QString& ); |
290 | void deletedFile( const QString&, const QString& ); | 295 | void deletedFile( const QString&, const QString& ); |
291 | void createdSubdir( const QString&, const QString& ); | 296 | void createdSubdir( const QString&, const QString& ); |
292 | void createdFile( const QString&, const QString& ); | 297 | void createdFile( const QString&, const QString& ); |
293 | void deleted( const QString& ); | 298 | void deleted( const QString& ); |
294 | void unmounted( const QString& ); | 299 | void unmounted( const QString& ); |
300 | |||
301 | private slots: | ||
302 | void subdirCreated( const QString&, const QString& ); | ||
303 | |||
304 | private: | ||
305 | OFileNotification* _topfilenotification; | ||
306 | OFileNotificationType _type; | ||
307 | int _depth; | ||
295 | }; | 308 | }; |
296 | 309 | ||
297 | /*====================================================================================== | 310 | /*====================================================================================== |
298 | * OFileNotificationEvent | 311 | * OFileNotificationEvent |
299 | *======================================================================================*/ | 312 | *======================================================================================*/ |
300 | 313 | ||
301 | class OFileNotificationEvent | 314 | class OFileNotificationEvent |
302 | { | 315 | { |
303 | public: | 316 | public: |
304 | OFileNotificationEvent( OFileNotification* parent, int wd, unsigned int mask, unsigned int cookie, const QString& name ); | 317 | OFileNotificationEvent( OFileNotification* parent, int wd, unsigned int mask, unsigned int cookie, const QString& name ); |
305 | ~OFileNotificationEvent(); | 318 | ~OFileNotificationEvent(); |
306 | OFileNotification* parent() const { return _parent; }; | 319 | OFileNotification* parent() const { return _parent; }; |
307 | int descriptor() const { return _wd; }; | 320 | int descriptor() const { return _wd; }; |
308 | unsigned int mask() const { return _mask; }; | 321 | unsigned int mask() const { return _mask; }; |
309 | unsigned int cookie() const { return _cookie; }; | 322 | unsigned int cookie() const { return _cookie; }; |
310 | QString name() const { return _name; }; | 323 | QString name() const { return _name; }; |
311 | void activate() { _parent->activate( this ); }; | 324 | void activate() { _parent->activate( this ); }; |
312 | 325 | ||
313 | private: | 326 | private: |
314 | OFileNotification* _parent; | 327 | OFileNotification* _parent; |
315 | int _wd; | 328 | int _wd; |
316 | unsigned int _mask; | 329 | unsigned int _mask; |
317 | unsigned int _cookie; | 330 | unsigned int _cookie; |
318 | QString _name; | 331 | QString _name; |