diff --git a/src/MediaServer/DirectoryWatcher.h b/src/MediaServer/DirectoryWatcher.h index 10651cd..cb0250a 100644 --- a/src/MediaServer/DirectoryWatcher.h +++ b/src/MediaServer/DirectoryWatcher.h @@ -50,31 +50,41 @@ class DirectoryWatcher { // TODO make useful stuff with onDirectoryWatcher* void onDirectoryWatcherItemAdded( const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) { - ofSendMessage("Added: " + evt.item.path()); - filePaths.push_back(evt.item.path()); + string path = evt.item.path(); + filePaths.push_back(path); + ofNotifyEvent(onItemAdded, path, this); } void onDirectoryWatcherItemRemoved( const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) { - ofSendMessage("Removed: " + evt.item.path()); + string path = evt.item.path(); + // TODO Remove items from Vector + + ofNotifyEvent(onItemRemoved, path, this); } void onDirectoryWatcherItemModified( const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) { - ofSendMessage("Modified: " + evt.item.path()); + string path = evt.item.path(); + + ofNotifyEvent(onItemModified, path, this); } void onDirectoryWatcherItemMovedFrom( const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) { + string path = evt.item.path(); ofLogNotice("ofApp::onDirectoryWatcherItemMovedFrom") - << "Moved From: " << evt.item.path(); + << "Moved From: " << path; + ofNotifyEvent(onItemMovedFrom, path, this); } void onDirectoryWatcherItemMovedTo( const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) { + string path = evt.item.path(); ofLogNotice("ofApp::onDirectoryWatcherItemMovedTo") - << "Moved To: " << evt.item.path(); + << "Moved To: " << path; + ofNotifyEvent(onItemMovedTo, path, this); } void onDirectoryWatcherError(const Poco::Exception& exc) { @@ -83,6 +93,13 @@ class DirectoryWatcher { } std::vector filePaths; + + // Custom events + ofEvent onItemAdded; + ofEvent onItemRemoved; + ofEvent onItemModified; + ofEvent onItemMovedFrom; + ofEvent onItemMovedTo; private: ofx::IO::DirectoryWatcherManager dirWatcher;