author | clem <clem> | 2004-10-06 23:52:25 (UTC) |
---|---|---|
committer | clem <clem> | 2004-10-06 23:52:25 (UTC) |
commit | 5137abdac1d6990c038170a2b3533ae85eecb7f1 (patch) (unidiff) | |
tree | 67b299caf70f5d7436ff05f012c98abcb665726c | |
parent | 14c237a2d5c60314935d51d9beea0527e337a9d8 (diff) | |
download | opie-5137abdac1d6990c038170a2b3533ae85eecb7f1.zip opie-5137abdac1d6990c038170a2b3533ae85eecb7f1.tar.gz opie-5137abdac1d6990c038170a2b3533ae85eecb7f1.tar.bz2 |
Closed a <pre> section in a Doxygen-enabled comment
-rw-r--r-- | libopie2/opiecore/ofilenotify.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libopie2/opiecore/ofilenotify.h b/libopie2/opiecore/ofilenotify.h index bd2f9d0..d820f7c 100644 --- a/libopie2/opiecore/ofilenotify.h +++ b/libopie2/opiecore/ofilenotify.h | |||
@@ -1,189 +1,190 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. Copyright (C) 2004 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. Copyright (C) 2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OFILENOTIFY_H | 29 | #ifndef OFILENOTIFY_H |
30 | #define OFILENOTIFY_H | 30 | #define OFILENOTIFY_H |
31 | #if defined (__GNUC__) && (__GNUC__ < 3) | 31 | #if defined (__GNUC__) && (__GNUC__ < 3) |
32 | #define _GNU_SOURCE | 32 | #define _GNU_SOURCE |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qobject.h> | 36 | #include <qobject.h> |
37 | #include <qsignal.h> | 37 | #include <qsignal.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | 39 | ||
40 | /* STD */ | 40 | /* STD */ |
41 | #include <signal.h> | 41 | #include <signal.h> |
42 | #include <fcntl.h> | 42 | #include <fcntl.h> |
43 | 43 | ||
44 | namespace Opie { | 44 | namespace Opie { |
45 | namespace Core { | 45 | namespace Core { |
46 | 46 | ||
47 | /*====================================================================================== | 47 | /*====================================================================================== |
48 | * OFileNotificationType | 48 | * OFileNotificationType |
49 | *======================================================================================*/ | 49 | *======================================================================================*/ |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * @brief An enumerate for the different types of file notifications | 52 | * @brief An enumerate for the different types of file notifications |
53 | * | 53 | * |
54 | * This enumerate provides a means to specify the type of events that you are interest in. | 54 | * This enumerate provides a means to specify the type of events that you are interest in. |
55 | * Valid values are: | 55 | * Valid values are: |
56 | * <ul> | 56 | * <ul> |
57 | * <li>Access: The file was accessed (read) | 57 | * <li>Access: The file was accessed (read) |
58 | * <li>Modify The file was modified (write,truncate) | 58 | * <li>Modify The file was modified (write,truncate) |
59 | * <li>Create = The file was created in the directory | 59 | * <li>Create = The file was created in the directory |
60 | * <li>Delete = The file was unlinked from directory | 60 | * <li>Delete = The file was unlinked from directory |
61 | * <li>Rename = The file was renamed | 61 | * <li>Rename = The file was renamed |
62 | * <li>Attrib = The file had its attributes changed (chmod,chown,chgrp) | 62 | * <li>Attrib = The file had its attributes changed (chmod,chown,chgrp) |
63 | * </ul> | 63 | * </ul> |
64 | * | 64 | * |
65 | **/ | 65 | **/ |
66 | 66 | ||
67 | enum OFileNotificationType { Single = 0x0000000, | 67 | enum OFileNotificationType { Single = 0x0000000, |
68 | Multi = DN_MULTISHOT, | 68 | Multi = DN_MULTISHOT, |
69 | Access = DN_ACCESS, | 69 | Access = DN_ACCESS, |
70 | Modify = DN_MODIFY, | 70 | Modify = DN_MODIFY, |
71 | Create = DN_CREATE, | 71 | Create = DN_CREATE, |
72 | Delete = DN_DELETE, | 72 | Delete = DN_DELETE, |
73 | Rename = DN_RENAME, | 73 | Rename = DN_RENAME, |
74 | Attrib = DN_ATTRIB }; | 74 | Attrib = DN_ATTRIB }; |
75 | 75 | ||
76 | /*====================================================================================== | 76 | /*====================================================================================== |
77 | * OFileNotification | 77 | * OFileNotification |
78 | *======================================================================================*/ | 78 | *======================================================================================*/ |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * @brief Represents a file notification | 81 | * @brief Represents a file notification |
82 | * | 82 | * |
83 | * This class allows to watch for events happening to files. | 83 | * This class allows to watch for events happening to files. |
84 | * It uses the dnotify kernel interface which is a very efficient signalling interface. | 84 | * It uses the dnotify kernel interface which is a very efficient signalling interface. |
85 | * | 85 | * |
86 | * @see <file:///usr/src/linux/Documentation/dnotify.txt> | 86 | * @see <file:///usr/src/linux/Documentation/dnotify.txt> |
87 | * | 87 | * |
88 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 88 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
89 | * | 89 | * |
90 | **/ | 90 | **/ |
91 | 91 | ||
92 | class OFileNotification : public QObject | 92 | class OFileNotification : public QObject |
93 | { | 93 | { |
94 | Q_OBJECT | 94 | Q_OBJECT |
95 | 95 | ||
96 | public: | 96 | public: |
97 | OFileNotification( QObject* parent = 0, const char* name = 0 ); | 97 | OFileNotification( QObject* parent = 0, const char* name = 0 ); |
98 | ~OFileNotification(); | 98 | ~OFileNotification(); |
99 | /** | 99 | /** |
100 | * This static function calls a slot when an event with @a type happens to file @a path. | 100 | * This static function calls a slot when an event with @a type happens to file @a path. |
101 | * | 101 | * |
102 | * It is very convenient to use this function because you do not need to | 102 | * It is very convenient to use this function because you do not need to |
103 | * bother with a timerEvent or to create a local QTimer object. | 103 | * bother with a timerEvent or to create a local QTimer object. |
104 | * | 104 | * |
105 | * Example: | 105 | * Example: |
106 | * <pre> | 106 | * <pre> |
107 | * | 107 | * |
108 | * #include <opie2/oapplication.h> | 108 | * #include <opie2/oapplication.h> |
109 | * #include <opie2/onitify.h> | 109 | * #include <opie2/onitify.h> |
110 | * using namespace Opie::Core; | 110 | * using namespace Opie::Core; |
111 | * | 111 | * |
112 | * int main( int argc, char **argv ) | 112 | * int main( int argc, char **argv ) |
113 | * { | 113 | * { |
114 | * OApplication a( argc, argv, "File Notification Example" ); | 114 | * OApplication a( argc, argv, "File Notification Example" ); |
115 | * OFileNotification::singleShot( "/tmp/quit", &a, SLOT(quit()), Create ); | 115 | * OFileNotification::singleShot( "/tmp/quit", &a, SLOT(quit()), Create ); |
116 | * ... // create and show your widgets | 116 | * ... // create and show your widgets |
117 | * return a.exec(); | 117 | * return a.exec(); |
118 | * } | 118 | * } |
119 | * </pre> | ||
119 | * | 120 | * |
120 | * This sample program automatically terminates when the file "/tmp/quite" has been created. | 121 | * This sample program automatically terminates when the file "/tmp/quite" has been created. |
121 | * | 122 | * |
122 | * | 123 | * |
123 | * The @a receiver is the receiving object and the @a member is the slot. | 124 | * The @a receiver is the receiving object and the @a member is the slot. |
124 | **/ | 125 | **/ |
125 | static void singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type = Modify ); | 126 | static void singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type = Modify ); |
126 | /** | 127 | /** |
127 | * Starts to watch for @a type changes to @a path. Set @a sshot to True if you want to be notified only once. | 128 | * Starts to watch for @a type changes to @a path. Set @a sshot to True if you want to be notified only once. |
128 | * Note that in that case it may be more convenient to use @ref OFileNotification::singleShot() then. | 129 | * Note that in that case it may be more convenient to use @ref OFileNotification::singleShot() then. |
129 | **/ | 130 | **/ |
130 | int start( const QString& path, bool sshot = false, OFileNotificationType type = Modify ); | 131 | int start( const QString& path, bool sshot = false, OFileNotificationType type = Modify ); |
131 | /** | 132 | /** |
132 | * Stop watching for file events. | 133 | * Stop watching for file events. |
133 | **/ | 134 | **/ |
134 | void stop(); | 135 | void stop(); |
135 | /** | 136 | /** |
136 | * @returns the notification type as set by @ref start(). | 137 | * @returns the notification type as set by @ref start(). |
137 | **/ | 138 | **/ |
138 | OFileNotificationType type() const; | 139 | OFileNotificationType type() const; |
139 | /** | 140 | /** |
140 | * @returns the path to the file being watched by this instance. | 141 | * @returns the path to the file being watched by this instance. |
141 | **/ | 142 | **/ |
142 | QString path() const; | 143 | QString path() const; |
143 | /** | 144 | /** |
144 | * @returns the UNIX file descriptor for the file being watched. | 145 | * @returns the UNIX file descriptor for the file being watched. |
145 | **/ | 146 | **/ |
146 | int fileno() const; | 147 | int fileno() const; |
147 | /** | 148 | /** |
148 | * @returns if a file is currently being watched. | 149 | * @returns if a file is currently being watched. |
149 | **/ | 150 | **/ |
150 | bool isActive() const; | 151 | bool isActive() const; |
151 | 152 | ||
152 | signals: | 153 | signals: |
153 | /** | 154 | /** |
154 | * This signal is emitted if an event happens of the specified type happens to the file being watched. | 155 | * This signal is emitted if an event happens of the specified type happens to the file being watched. |
155 | **/ | 156 | **/ |
156 | void triggered(); | 157 | void triggered(); |
157 | 158 | ||
158 | protected: | 159 | protected: |
159 | bool activate(); | 160 | bool activate(); |
160 | virtual bool hasChanged(); | 161 | virtual bool hasChanged(); |
161 | static bool registerSignalHandler(); | 162 | static bool registerSignalHandler(); |
162 | static void unregisterSignalHandler(); | 163 | static void unregisterSignalHandler(); |
163 | static void __signalHandler( int sig, siginfo_t *si, void *data ); | 164 | static void __signalHandler( int sig, siginfo_t *si, void *data ); |
164 | 165 | ||
165 | private: | 166 | private: |
166 | QString _path; | 167 | QString _path; |
167 | OFileNotificationType _type; | 168 | OFileNotificationType _type; |
168 | QSignal _signal; | 169 | QSignal _signal; |
169 | int _fd; | 170 | int _fd; |
170 | bool _active; | 171 | bool _active; |
171 | struct stat _stat; | 172 | struct stat _stat; |
172 | }; | 173 | }; |
173 | 174 | ||
174 | #if 0 | 175 | #if 0 |
175 | 176 | ||
176 | class ODirectoryNotification : public OFileNotification | 177 | class ODirectoryNotification : public OFileNotification |
177 | { | 178 | { |
178 | 179 | ||
179 | public: | 180 | public: |
180 | virtual bool hasChanged() { return true; }; | 181 | virtual bool hasChanged() { return true; }; |
181 | }; | 182 | }; |
182 | 183 | ||
183 | #endif | 184 | #endif |
184 | 185 | ||
185 | } | 186 | } |
186 | } | 187 | } |
187 | 188 | ||
188 | #endif | 189 | #endif |
189 | 190 | ||