xref: /haiku/src/servers/input/AddOnManager.h (revision 3cb015b1ee509d69c643506e8ff573808c86dcfc)
1 /*
2  * Copyright 2004-2005, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Marcus Overhagen, Axel Dörfler
7  *		Jérôme Duval
8  */
9 #ifndef _ADD_ON_MANAGER_H
10 #define _ADD_ON_MANAGER_H
11 
12 // Manager for input_server add-ons (devices, filters, methods)
13 
14 
15 #include <Locker.h>
16 #include <Looper.h>
17 #include <InputServerDevice.h>
18 #include <InputServerFilter.h>
19 #include <InputServerMethod.h>
20 #include "AddOnMonitor.h"
21 #include "AddOnMonitorHandler.h"
22 #include "TList.h"
23 
24 
25 class AddOnManager : public BLooper {
26 	public:
27 		AddOnManager(bool safeMode);
28 		~AddOnManager();
29 
30 		void		LoadState();
31 		void		SaveState();
32 		void 		MessageReceived(BMessage *message);
33 
34 	private:
35 		status_t	RegisterAddOn(BEntry &entry);
36 		status_t	UnregisterAddOn(BEntry &entry);
37 		void		RegisterAddOns();
38 		void		UnregisterAddOns();
39 
40 		void		RegisterDevice(BInputServerDevice *isd, const entry_ref &ref, image_id addon_image);
41 		void		RegisterFilter(BInputServerFilter *isf, const entry_ref &ref, image_id addon_image);
42 		void		RegisterMethod(BInputServerMethod *ism, const entry_ref &ref, image_id addon_image);
43 
44 		status_t HandleFindDevices(BMessage*, BMessage*);
45 		status_t HandleWatchDevices(BMessage*, BMessage*);
46 		status_t HandleIsDeviceRunning(BMessage*, BMessage*);
47 		status_t HandleStartStopDevices(BMessage*, BMessage*);
48 		status_t HandleControlDevices(BMessage*, BMessage*);
49 		status_t HandleSystemShuttingDown(BMessage*, BMessage*);
50 		status_t HandleMethodReplicant(BMessage*, BMessage*);
51 		status_t HandleNodeMonitor(BMessage*);
52 
53 		void LoadReplicant();
54 		int32 GetReplicantAt(BMessenger target, int32 index) const;
55 		status_t GetReplicantName(BMessenger target, int32 uid, BMessage *reply) const;
56 		status_t GetReplicantView(BMessenger target, int32 uid, BMessage *reply) const;
57 
58 	private:
59 		class InputServerMonitorHandler;
60 		friend class InputServerMonitorHandler;
61 
62 		struct device_info {
63 			entry_ref ref;
64 			image_id addon_image;
65 			BInputServerDevice *device;
66 		};
67 		struct filter_info {
68 			entry_ref ref;
69 			image_id addon_image;
70 			BInputServerFilter *filter;
71 		};
72 		struct method_info {
73 			entry_ref ref;
74 			image_id addon_image;
75 			BInputServerMethod *method;
76 		};
77 
78 		BLocker fLock;
79 		List<device_info> fDeviceList;
80 		List<filter_info> fFilterList;
81 		List<method_info> fMethodList;
82 
83 		AddOnMonitorHandler	*fHandler;
84 		AddOnMonitor		*fAddOnMonitor;
85 
86 		bool fSafeMode;
87 };
88 
89 #endif // _ADD_ON_MANAGER_H
90