-rw-r--r-- | libopie2/opiecore/linux/ofilenotify.cpp | 40 | ||||
-rw-r--r-- | libopie2/opiecore/linux/ofilenotify.h | 3 |
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 @@ -235,8 +235,10 @@ bool OFileNotification::isSingleShot() const bool OFileNotification::activate( const OFileNotificationEvent* e ) { qDebug( "OFileNotification::activate(): e = ( %s, %d, 0x%08x, %d, %s )", (const char*) _path, e->descriptor(), e->mask(), e->cookie(), (const char*) e->name() ); + //FIXME: Should we really deliver QueueOverflow and/or Ignore to user level code? + // dumb signal _signal.activate(); // generic signal @@ -244,25 +246,29 @@ bool OFileNotification::activate( const OFileNotificationEvent* e ) // specialized signals switch ( e->mask() ) { - case Access: emit accessed( _path ); break; - case Modify: emit modified( _path ); break; - case Attrib: emit attributed( _path); break; - case CloseWrite: emit closed( _path, true ); break; - case CloseNoWrite: emit closed( _path, false ); break; - case Open: emit opened( _path ); break; - case MovedFrom: emit movedFrom( _path, e->name() ); break; - case MovedTo: emit movedTo( _path, e->name() ); break; - case DeleteSubdir: emit deletedSubdir( _path, e->name() ); break; - case DeleteFile: emit deletedFile( _path, e->name() ); break; - case CreateSubdir: emit createdSubdir( _path, e->name() ); break; - case CreateFile: emit createdFile( _path, e->name() ); break; - case DeleteSelf: emit deleted( _path ); break; - case Unmount: emit unmounted( _path ); break; + case Access: emit accessed( _path ); break; + case Modify: emit modified( _path ); break; + case Attrib: emit attributed( _path); break; + case CloseWrite: emit closed( _path, true ); break; + case CloseNoWrite: emit closed( _path, false ); break; + case Open: emit opened( _path ); break; + case MovedFrom: emit movedFrom( _path, e->name() ); break; + case MovedTo: emit movedTo( _path, e->name() ); break; + case DeleteSubdir: emit deletedSubdir( _path, e->name() ); break; + case DeleteFile: emit deletedFile( _path, e->name() ); break; + case CreateSubdir: emit createdSubdir( _path, e->name() ); break; + case CreateFile: emit createdFile( _path, e->name() ); break; + case DeleteSelf: emit deleted( _path ); break; + case Unmount: emit unmounted( _path ); break; + case _QueueOverflow: qFatal( "OFileNotification::activate() - Inotify Event Queue Overload!" ); break; + case _Ignored: qWarning( "OFileNotification::activate() - Further Events for '%s' will be ignored", (const char*) _path ); break; default: assert( 0 ); } + delete e; + if ( !_multi ) stop(); return true; } @@ -316,9 +322,9 @@ bool OFileNotification::registerEventHandler() qWarning( "OFileNotification::registerEventHandler(): couldn't register event handler: %s", strerror( errno ) ); return false; } - OFileNotification::_sn = new QSocketNotifier( _fd, QSocketNotifier::Read, this, "inotify event" ); + OFileNotification::_sn = new QSocketNotifier( _fd, QSocketNotifier::Read ); connect( OFileNotification::_sn, SIGNAL( activated(int) ), this, SLOT( inotifyEventHandler() ) ); qDebug( "OFileNotification::registerEventHandler(): done" ); return true; @@ -347,9 +353,9 @@ ODirNotification::~ODirNotification() { qDebug( "ODirNotification::~ODirNotification()" ); } -/* +/** Love-Trowbridge recursive directory scanning algorithm: Step 1. Start at initial directory foo. Add watch. @@ -364,9 +370,9 @@ ODirNotification::~ODirNotification() step 1. Step 5. For any CREATE_SUBDIR event on bar, if a watch is not yet created on bar, repeat step 1 on bar. -*/ +**/ int ODirNotification::watch( const QString& path, bool sshot, OFileNotificationType type, int recurse ) { if ( _type == Nothing ) _type = type; // only set it once - for the top level call 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 @@ -256,9 +256,10 @@ class OFileNotification : public QObject /** * @brief Represents a directory notification * * This class allows to watch for events happening to directories - * It uses the OFileNotification class + * It uses the OFileNotification class and (for recursive watches) + * implements the Love-Trowbridge recursive directory scanning algorithm. * * @see http://www.kernel.org/pub/linux/kernel/people/rml/inotify/ * * @author Michael 'Mickey' Lauer <mickey@vanille.de> |