1 /* 2 * Copyright 2004-2008, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _ADD_ON_MONITOR_HANDLER_H 6 #define _ADD_ON_MONITOR_HANDLER_H 7 8 #include <list> 9 10 #include "NodeMonitorHandler.h" 11 12 13 namespace BPrivate { 14 namespace Storage { 15 16 struct add_on_entry_info { 17 char name[B_FILE_NAME_LENGTH]; 18 node_ref nref; 19 node_ref dir_nref; 20 }; 21 22 struct add_on_directory_info { 23 node_ref nref; 24 std::list<add_on_entry_info> entries; 25 }; 26 27 class AddOnMonitorHandler : public NodeMonitorHandler { 28 public: 29 AddOnMonitorHandler(const char* name = NULL); 30 virtual ~AddOnMonitorHandler(); 31 32 virtual void MessageReceived(BMessage* msg); 33 34 // supply the add-on directories here, in the order you want them checked 35 virtual status_t AddDirectory(const node_ref* nref); 36 37 protected: 38 // hooks for subclass 39 virtual void AddOnCreated(const add_on_entry_info* entryInfo); 40 virtual void AddOnEnabled(const add_on_entry_info* entryInfo); 41 virtual void AddOnDisabled(const add_on_entry_info* entryInfo); 42 virtual void AddOnRemoved(const add_on_entry_info* entryInfo); 43 44 protected: 45 virtual void EntryCreated(const char* name, ino_t directory, 46 dev_t device, ino_t node); 47 virtual void EntryRemoved(ino_t directory, dev_t device, ino_t node); 48 virtual void EntryMoved(const char* name, ino_t fromDirectory, 49 ino_t toDirectory, dev_t device, ino_t node); 50 51 private: 52 typedef NodeMonitorHandler inherited; 53 54 void _HandlePulse(); 55 56 std::list<add_on_directory_info> fDirectories; 57 std::list<add_on_entry_info> fPendingEntries; 58 std::list<add_on_entry_info> fFormerEntries; 59 }; 60 61 62 }; // namespace Storage 63 }; // namespace BPrivate 64 65 using namespace BPrivate::Storage; 66 67 #endif // _ADD_ON_MONITOR_HANDLER_H 68