xref: /haiku/headers/private/storage/NodeMonitorHandler.h (revision d01ea8ec63a34e5c78977457f0affc7e27135b74)
1e396ab58Sshatty #ifndef _NODE_MONITOR_HANDLER_H
2e396ab58Sshatty #define _NODE_MONITOR_HANDLER_H
3e396ab58Sshatty 
4e396ab58Sshatty #include <Entry.h>
5e396ab58Sshatty #include <Handler.h>
6e396ab58Sshatty #include <Message.h>
7e396ab58Sshatty #include <NodeMonitor.h>
8e396ab58Sshatty 
9e396ab58Sshatty namespace BPrivate {
10e396ab58Sshatty namespace Storage {
11e396ab58Sshatty 
12e396ab58Sshatty class NodeMonitorHandler : public BHandler {
13e396ab58Sshatty private:
14e396ab58Sshatty 	typedef BHandler inherited;
15e396ab58Sshatty public:
16e396ab58Sshatty 			NodeMonitorHandler(const char * name = "NodeMonitorHandler");
17e396ab58Sshatty 	virtual	~NodeMonitorHandler();
18e396ab58Sshatty 
19e396ab58Sshatty 	virtual void	MessageReceived(BMessage * msg);
20e396ab58Sshatty 
21e396ab58Sshatty 	// useful utility functions
22e396ab58Sshatty static status_t make_entry_ref(dev_t device, ino_t directory,
23e396ab58Sshatty 				               const char * name,
24e396ab58Sshatty 				               entry_ref * ref);
25e396ab58Sshatty static void		make_node_ref(dev_t device, ino_t node, node_ref * ref);
26e396ab58Sshatty 
27e396ab58Sshatty protected:
28e396ab58Sshatty 	// hooks for subclass
29e396ab58Sshatty 	virtual void	EntryCreated(const char *name, ino_t directory,
30e396ab58Sshatty 						dev_t device, ino_t node);
319a986950SClemens Zeidler 	virtual void	EntryRemoved(const char *name, ino_t directory,
329a986950SClemens Zeidler 						dev_t device, ino_t node);
339a986950SClemens Zeidler 	virtual void	EntryMoved(const char *name, const char *fromName,
34e4644818SClemens Zeidler 						ino_t fromDirectory, ino_t toDirectory, dev_t device,
359a986950SClemens Zeidler 						ino_t node, dev_t nodeDevice);
36*d01ea8ecSClemens Zeidler 	virtual void	StatChanged(ino_t node, dev_t device, int32 statFields);
37e396ab58Sshatty 	virtual void	AttrChanged(ino_t node, dev_t device);
38e396ab58Sshatty 	virtual void	DeviceMounted(dev_t new_device, dev_t device,
39e396ab58Sshatty 						ino_t directory);
40e396ab58Sshatty 	virtual void	DeviceUnmounted(dev_t new_device);
41e396ab58Sshatty 
42e396ab58Sshatty private:
43e396ab58Sshatty 	status_t	HandleEntryCreated(BMessage * msg);
44e396ab58Sshatty 	status_t	HandleEntryRemoved(BMessage * msg);
45e396ab58Sshatty 	status_t	HandleEntryMoved(BMessage * msg);
46e396ab58Sshatty 	status_t	HandleStatChanged(BMessage * msg);
47e396ab58Sshatty 	status_t	HandleAttrChanged(BMessage * msg);
48e396ab58Sshatty 	status_t	HandleDeviceMounted(BMessage * msg);
49e396ab58Sshatty 	status_t	HandleDeviceUnmounted(BMessage * msg);
50e396ab58Sshatty };
51e396ab58Sshatty 
52e396ab58Sshatty };	// namespace Storage
53e396ab58Sshatty };	// namespace BPrivate
54e396ab58Sshatty 
55e396ab58Sshatty using namespace BPrivate::Storage;
56e396ab58Sshatty 
57e396ab58Sshatty #endif // _NODE_MONITOR_HANDLER_H
58