Diffstat (limited to 'libopie2/opiecore/linux/ofilenotify.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/linux/ofilenotify.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/libopie2/opiecore/linux/ofilenotify.cpp b/libopie2/opiecore/linux/ofilenotify.cpp index 36ec6bf..3096f7e 100644 --- a/libopie2/opiecore/linux/ofilenotify.cpp +++ b/libopie2/opiecore/linux/ofilenotify.cpp @@ -326,76 +326,87 @@ void OFileNotification::unregisterEventHandler() ::close( OFileNotification::_fd ); qDebug( "OFileNotification::unregisterEventHandler(): done" ); } //================================================================================================= // ODirNotification //================================================================================================= ODirNotification::ODirNotification( QObject* parent, const char* name ) :QObject( parent, name ) { qDebug( "ODirNotification::ODirNotification()" ); } ODirNotification::~ODirNotification() { qDebug( "ODirNotification::~ODirNotification()" ); } int ODirNotification::watch( const QString& path, bool sshot, OFileNotificationType type, int recurse ) { qDebug( "ODirNotification::watch( %s, %d, 0x%08x, %d )", (const char*) path, sshot, type, recurse ); - if ( recurse == 0 ) - { OFileNotification* fn = new OFileNotification( this, "ODirNotification delegate" ); int result = fn->startWatching( path, sshot, type ); if ( result != -1 ) { connect( fn, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ), this, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ) ); connect( fn, SIGNAL( accessed( const QString& ) ), this, SIGNAL( accessed( const QString& ) ) ); connect( fn, SIGNAL( modified( const QString& ) ), this, SIGNAL( modified( const QString& ) ) ); connect( fn, SIGNAL( attributed( const QString& ) ), this, SIGNAL( attributed( const QString& ) ) ); connect( fn, SIGNAL( closed( const QString&, bool ) ), this, SIGNAL( closed( const QString&, bool ) ) ); connect( fn, SIGNAL( opened( const QString& ) ), this, SIGNAL( opened( const QString& ) ) ); connect( fn, SIGNAL( movedTo( const QString&, const QString& ) ), this, SIGNAL( movedTo( const QString&, const QString& ) ) ); connect( fn, SIGNAL( movedFrom( const QString&, const QString& ) ), this, SIGNAL( movedFrom( const QString&, const QString& ) ) ); connect( fn, SIGNAL( deletedSubdir( const QString&, const QString& ) ), this, SIGNAL( deletedSubdir( const QString&, const QString& ) ) ); connect( fn, SIGNAL( deletedFile( const QString&, const QString& ) ), this, SIGNAL( deletedFile( const QString&, const QString& ) ) );; connect( fn, SIGNAL( createdSubdir( const QString&, const QString& ) ), this, SIGNAL( createdSubdir( const QString&, const QString& ) ) ); connect( fn, SIGNAL( createdFile( const QString&, const QString& ) ), this, SIGNAL( createdFile( const QString&, const QString& ) ) ); connect( fn, SIGNAL( deleted( const QString& ) ), this, SIGNAL( deleted( const QString& ) ) ); connect( fn, SIGNAL( unmounted( const QString& ) ), this, SIGNAL( unmounted( const QString& ) ) ); - } - return result; - } - else + + if ( recurse ) { + QDir directory( path ); + QStringList subdirs = directory.entryList( QDir::Dirs ); - return 1; + for ( QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it ) + { + if ( (*it) == "." || (*it) == ".." ) continue; + QString subpath = QString( "%1/%2" ).arg( path ).arg( *it ); + int subresult = watch( subpath, sshot, type, recurse-1 ); + if ( subresult == -1 ) + { + qDebug( "ODirNotification::watch(): subresult for '%s' was -1. Interrupting", (const char*) (*it) ); + return -1; + } + } + } +//connect( fn, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ), this, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ) ); } + else return -1; } // void ODirNotification::subdirCreated( const QString& name ) /* Love-Trowbridge recursive directory scanning algorithm: Step 1. Start at initial directory foo. Add watch. Step 2. Setup handlers for watch created in Step 1. Specifically, ensure that a directory created in foo will result in a handled CREATE_SUBDIR event. Step 3. Read the contents of foo. Step 4. For each subdirectory of foo read in step 3, repeat 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. */ |