1 /* 2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef VOLUME_WATCHER_H 6 #define VOLUME_WATCHER_H 7 8 9 #include <Handler.h> 10 #include <ObjectList.h> 11 12 13 class VolumeListener { 14 public: 15 virtual ~VolumeListener(); 16 17 virtual void VolumeMounted(dev_t device) = 0; 18 virtual void VolumeUnmounted(dev_t device) = 0; 19 }; 20 21 22 class VolumeWatcher : public BHandler { 23 public: 24 VolumeWatcher(); 25 virtual ~VolumeWatcher(); 26 27 void AddListener(VolumeListener* listener); 28 void RemoveListener(VolumeListener* listener); 29 int32 CountListeners() const; 30 31 virtual void MessageReceived(BMessage* message); 32 33 static void Register(VolumeListener* listener); 34 static void Unregister(VolumeListener* listener); 35 36 protected: 37 BObjectList<VolumeListener> 38 fListeners; 39 }; 40 41 42 #endif // VOLUME_WATCHER_H 43