summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-06-02 21:44:41 (UTC)
committer mickeyl <mickeyl>2005-06-02 21:44:41 (UTC)
commitd0f6a0721d7ab67a115d08990143944ee71d54ba (patch) (unidiff)
treeba22ad18027419a6417f3d6439a2faf67917ab74 /libopie2
parentf55a56f54de1d3fa9084160159a379079a317d96 (diff)
downloadopie-d0f6a0721d7ab67a115d08990143944ee71d54ba.zip
opie-d0f6a0721d7ab67a115d08990143944ee71d54ba.tar.gz
opie-d0f6a0721d7ab67a115d08990143944ee71d54ba.tar.bz2
- move addLanguage.sh and mkipks to scripts/ directory
- finish recursive directory locks and mention in ChangeLog beginning with `CVS:' are removed automatically CVS: CVS: Committing in . CVS: CVS: Modified Files: CVS: ChangeLog libopie2/opiecore/linux/ofilenotify.cpp CVS: libopie2/opiecore/linux/ofilenotify.h CVS: examples/opiecore/onotifytest/main.cpp CVS: examples/opiecore/onotifytest/main.h CVS: Added Files: CVS: scripts/addLanguage.sh scripts/mkipks CVS: ----------------------------------------------------------------------
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/ofilenotify.cpp40
-rw-r--r--libopie2/opiecore/linux/ofilenotify.h3
2 files changed, 25 insertions, 18 deletions
diff --git a/libopie2/opiecore/linux/ofilenotify.cpp b/libopie2/opiecore/linux/ofilenotify.cpp
index a7820ee..68c5a96 100644
--- a/libopie2/opiecore/linux/ofilenotify.cpp
+++ b/libopie2/opiecore/linux/ofilenotify.cpp
@@ -227,50 +227,56 @@ QString OFileNotification::path() const
227 227
228 228
229bool OFileNotification::isSingleShot() const 229bool OFileNotification::isSingleShot() const
230{ 230{
231 return !_multi; 231 return !_multi;
232} 232}
233 233
234 234
235bool OFileNotification::activate( const OFileNotificationEvent* e ) 235bool OFileNotification::activate( const OFileNotificationEvent* e )
236{ 236{
237 qDebug( "OFileNotification::activate(): e = ( %s, %d, 0x%08x, %d, %s )", (const char*) _path, e->descriptor(), e->mask(), e->cookie(), (const char*) e->name() ); 237 qDebug( "OFileNotification::activate(): e = ( %s, %d, 0x%08x, %d, %s )", (const char*) _path, e->descriptor(), e->mask(), e->cookie(), (const char*) e->name() );
238 238
239 //FIXME: Should we really deliver QueueOverflow and/or Ignore to user level code?
240
239 // dumb signal 241 // dumb signal
240 _signal.activate(); 242 _signal.activate();
241 243
242 // generic signal 244 // generic signal
243 emit triggered( _path, e->mask(), e->name() ); 245 emit triggered( _path, e->mask(), e->name() );
244 246
245 // specialized signals 247 // specialized signals
246 switch ( e->mask() ) 248 switch ( e->mask() )
247 { 249 {
248 case Access: emit accessed( _path ); break; 250 case Access: emit accessed( _path ); break;
249 case Modify: emit modified( _path ); break; 251 case Modify: emit modified( _path ); break;
250 case Attrib: emit attributed( _path); break; 252 case Attrib: emit attributed( _path); break;
251 case CloseWrite: emit closed( _path, true ); break; 253 case CloseWrite: emit closed( _path, true ); break;
252 case CloseNoWrite: emit closed( _path, false ); break; 254 case CloseNoWrite: emit closed( _path, false ); break;
253 case Open: emit opened( _path ); break; 255 case Open: emit opened( _path ); break;
254 case MovedFrom: emit movedFrom( _path, e->name() ); break; 256 case MovedFrom: emit movedFrom( _path, e->name() ); break;
255 case MovedTo: emit movedTo( _path, e->name() ); break; 257 case MovedTo: emit movedTo( _path, e->name() ); break;
256 case DeleteSubdir: emit deletedSubdir( _path, e->name() ); break; 258 case DeleteSubdir: emit deletedSubdir( _path, e->name() ); break;
257 case DeleteFile: emit deletedFile( _path, e->name() ); break; 259 case DeleteFile: emit deletedFile( _path, e->name() ); break;
258 case CreateSubdir: emit createdSubdir( _path, e->name() ); break; 260 case CreateSubdir: emit createdSubdir( _path, e->name() ); break;
259 case CreateFile: emit createdFile( _path, e->name() ); break; 261 case CreateFile: emit createdFile( _path, e->name() ); break;
260 case DeleteSelf: emit deleted( _path ); break; 262 case DeleteSelf: emit deleted( _path ); break;
261 case Unmount: emit unmounted( _path ); break; 263 case Unmount: emit unmounted( _path ); break;
264 case _QueueOverflow: qFatal( "OFileNotification::activate() - Inotify Event Queue Overload!" ); break;
265 case _Ignored: qWarning( "OFileNotification::activate() - Further Events for '%s' will be ignored", (const char*) _path ); break;
262 default: assert( 0 ); 266 default: assert( 0 );
263 } 267 }
264 268
269 delete e;
270
265 if ( !_multi ) stop(); 271 if ( !_multi ) stop();
266 272
267 return true; 273 return true;
268} 274}
269 275
270 276
271bool OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type ) 277bool OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type )
272{ 278{
273 OFileNotification* ofn = new OFileNotification(); 279 OFileNotification* ofn = new OFileNotification();
274 ofn->_signal.connect( receiver, member ); 280 ofn->_signal.connect( receiver, member );
275 return ofn->watch( path, true, type ) != -1; 281 return ofn->watch( path, true, type ) != -1;
276} 282}
@@ -308,25 +314,25 @@ void OFileNotification::inotifyEventHandler()
308} 314}
309 315
310 316
311bool OFileNotification::registerEventHandler() 317bool OFileNotification::registerEventHandler()
312{ 318{
313 OFileNotification::_fd = ::open( INOTIFY_DEVICE, O_RDONLY ); 319 OFileNotification::_fd = ::open( INOTIFY_DEVICE, O_RDONLY );
314 if ( OFileNotification::_fd < 0 ) 320 if ( OFileNotification::_fd < 0 )
315 { 321 {
316 qWarning( "OFileNotification::registerEventHandler(): couldn't register event handler: %s", strerror( errno ) ); 322 qWarning( "OFileNotification::registerEventHandler(): couldn't register event handler: %s", strerror( errno ) );
317 return false; 323 return false;
318 } 324 }
319 325
320 OFileNotification::_sn = new QSocketNotifier( _fd, QSocketNotifier::Read, this, "inotify event" ); 326 OFileNotification::_sn = new QSocketNotifier( _fd, QSocketNotifier::Read );
321 connect( OFileNotification::_sn, SIGNAL( activated(int) ), this, SLOT( inotifyEventHandler() ) ); 327 connect( OFileNotification::_sn, SIGNAL( activated(int) ), this, SLOT( inotifyEventHandler() ) );
322 328
323 qDebug( "OFileNotification::registerEventHandler(): done" ); 329 qDebug( "OFileNotification::registerEventHandler(): done" );
324 return true; 330 return true;
325} 331}
326 332
327 333
328void OFileNotification::unregisterEventHandler() 334void OFileNotification::unregisterEventHandler()
329{ 335{
330 if ( _sn ) delete _sn; 336 if ( _sn ) delete _sn;
331 if ( OFileNotification::_fd ) 337 if ( OFileNotification::_fd )
332 ::close( OFileNotification::_fd ); 338 ::close( OFileNotification::_fd );
@@ -339,42 +345,42 @@ void OFileNotification::unregisterEventHandler()
339ODirNotification::ODirNotification( QObject* parent, const char* name ) 345ODirNotification::ODirNotification( QObject* parent, const char* name )
340 :QObject( parent, name ), _topfilenotification( 0 ), _type( Nothing ), _depth( -123 ) 346 :QObject( parent, name ), _topfilenotification( 0 ), _type( Nothing ), _depth( -123 )
341{ 347{
342 qDebug( "ODirNotification::ODirNotification()" ); 348 qDebug( "ODirNotification::ODirNotification()" );
343} 349}
344 350
345 351
346ODirNotification::~ODirNotification() 352ODirNotification::~ODirNotification()
347{ 353{
348 qDebug( "ODirNotification::~ODirNotification()" ); 354 qDebug( "ODirNotification::~ODirNotification()" );
349} 355}
350 356
351/* 357/**
352 Love-Trowbridge recursive directory scanning algorithm: 358 Love-Trowbridge recursive directory scanning algorithm:
353 359
354 Step 1. Start at initial directory foo. Add watch. 360 Step 1. Start at initial directory foo. Add watch.
355 361
356 Step 2. Setup handlers for watch created in Step 1. 362 Step 2. Setup handlers for watch created in Step 1.
357 Specifically, ensure that a directory created 363 Specifically, ensure that a directory created
358 in foo will result in a handled CREATE_SUBDIR 364 in foo will result in a handled CREATE_SUBDIR
359 event. 365 event.
360 366
361 Step 3. Read the contents of foo. 367 Step 3. Read the contents of foo.
362 368
363 Step 4. For each subdirectory of foo read in step 3, repeat 369 Step 4. For each subdirectory of foo read in step 3, repeat
364 step 1. 370 step 1.
365 371
366 Step 5. For any CREATE_SUBDIR event on bar, if a watch is 372 Step 5. For any CREATE_SUBDIR event on bar, if a watch is
367 not yet created on bar, repeat step 1 on bar. 373 not yet created on bar, repeat step 1 on bar.
368*/ 374**/
369 375
370int ODirNotification::watch( const QString& path, bool sshot, OFileNotificationType type, int recurse ) 376int ODirNotification::watch( const QString& path, bool sshot, OFileNotificationType type, int recurse )
371{ 377{
372 if ( _type == Nothing ) _type = type; // only set it once - for the top level call 378 if ( _type == Nothing ) _type = type; // only set it once - for the top level call
373 OFileNotificationType subtype = ( recurse != 0 ) ? (OFileNotificationType) int( _type | CreateSubdir ) : _type; 379 OFileNotificationType subtype = ( recurse != 0 ) ? (OFileNotificationType) int( _type | CreateSubdir ) : _type;
374 qDebug( "ODirNotification::watch( %s, %d, 0x%08x, %d )", (const char*) path, sshot, subtype, recurse ); 380 qDebug( "ODirNotification::watch( %s, %d, 0x%08x, %d )", (const char*) path, sshot, subtype, recurse );
375 OFileNotification* fn = new OFileNotification( this, "ODirNotification delegate" ); 381 OFileNotification* fn = new OFileNotification( this, "ODirNotification delegate" );
376 382
377 int result = fn->startWatching( path, sshot, subtype ); 383 int result = fn->startWatching( path, sshot, subtype );
378 if ( result != -1 ) 384 if ( result != -1 )
379 { 385 {
380 386
diff --git a/libopie2/opiecore/linux/ofilenotify.h b/libopie2/opiecore/linux/ofilenotify.h
index 17e6b5d..c713b30 100644
--- a/libopie2/opiecore/linux/ofilenotify.h
+++ b/libopie2/opiecore/linux/ofilenotify.h
@@ -248,25 +248,26 @@ class OFileNotification : public QObject
248 248
249 friend class OFileNotificationEvent; 249 friend class OFileNotificationEvent;
250}; 250};
251 251
252/*====================================================================================== 252/*======================================================================================
253 * ODirNotification 253 * ODirNotification
254 *======================================================================================*/ 254 *======================================================================================*/
255 255
256/** 256/**
257 * @brief Represents a directory notification 257 * @brief Represents a directory notification
258 * 258 *
259 * This class allows to watch for events happening to directories 259 * This class allows to watch for events happening to directories
260 * It uses the OFileNotification class 260 * It uses the OFileNotification class and (for recursive watches)
261 * implements the Love-Trowbridge recursive directory scanning algorithm.
261 * 262 *
262 * @see http://www.kernel.org/pub/linux/kernel/people/rml/inotify/ 263 * @see http://www.kernel.org/pub/linux/kernel/people/rml/inotify/
263 * 264 *
264 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 265 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
265 * 266 *
266 **/ 267 **/
267 268
268class ODirNotification : public QObject 269class ODirNotification : public QObject
269{ 270{
270 Q_OBJECT 271 Q_OBJECT
271 272
272 public: 273 public: