vfs: check userland buffers before reading them.
[haiku.git] / src / servers / input / AddOnManager.h
blob38b74a1d446a0694f6175f6ad0b964c61bb26406
1 /*
2 * Copyright 2004-2013, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 * Jérôme Duval
8 * Marcus Overhagen
9 * John Scipione, jscipione@gmail.com
11 #ifndef ADD_ON_MANAGER_H
12 #define ADD_ON_MANAGER_H
15 #include <InputServerDevice.h>
16 #include <InputServerFilter.h>
17 #include <InputServerMethod.h>
18 #include <Locker.h>
19 #include <Looper.h>
21 #include <AddOnMonitor.h>
22 #include <AddOnMonitorHandler.h>
24 #include "PathList.h"
27 using namespace BPrivate;
29 class AddOnManager : public AddOnMonitor {
30 public:
31 AddOnManager();
32 ~AddOnManager();
34 virtual void MessageReceived(BMessage* message);
36 void LoadState();
37 void SaveState();
39 status_t StartMonitoringDevice(DeviceAddOn* addOn,
40 const char* device);
41 status_t StopMonitoringDevice(DeviceAddOn* addOn,
42 const char* device);
44 private:
45 void _RegisterAddOns();
46 void _UnregisterAddOns();
48 status_t _RegisterAddOn(BEntry& entry);
49 status_t _UnregisterAddOn(BEntry& entry);
51 bool _IsDevice(const char* path) const;
52 bool _IsFilter(const char* path) const;
53 bool _IsMethod(const char* path) const;
55 status_t _RegisterDevice(BInputServerDevice* device,
56 const entry_ref& ref, image_id image);
57 status_t _RegisterFilter(BInputServerFilter* filter,
58 const entry_ref& ref, image_id image);
59 status_t _RegisterMethod(BInputServerMethod* method,
60 const entry_ref& ref, image_id image);
62 status_t _HandleFindDevices(BMessage* message,
63 BMessage* reply);
64 status_t _HandleWatchDevices(BMessage* message,
65 BMessage* reply);
66 status_t _HandleIsDeviceRunning(BMessage* message,
67 BMessage* reply);
68 status_t _HandleStartStopDevices(BMessage* message,
69 BMessage* reply);
70 status_t _HandleControlDevices(BMessage* message,
71 BMessage* reply);
72 status_t _HandleSystemShuttingDown(BMessage* message,
73 BMessage* reply);
74 status_t _HandleMethodReplicant(BMessage* message,
75 BMessage* reply);
76 void _HandleDeviceMonitor(BMessage* message);
78 void _LoadReplicant();
79 void _UnloadReplicant();
80 int32 _GetReplicantAt(BMessenger target,
81 int32 index) const;
82 status_t _GetReplicantName(BMessenger target,
83 int32 uid, BMessage* reply) const;
84 status_t _GetReplicantView(BMessenger target, int32 uid,
85 BMessage* reply) const;
87 status_t _AddDevicePath(DeviceAddOn* addOn,
88 const char* path, bool& newPath);
89 status_t _RemoveDevicePath(DeviceAddOn* addOn,
90 const char* path, bool& lastPath);
92 private:
93 class MonitorHandler;
94 friend class MonitorHandler;
96 template<typename T> struct add_on_info {
97 add_on_info()
99 image(-1), add_on(NULL)
103 ~add_on_info()
105 delete add_on;
106 if (image >= 0)
107 unload_add_on(image);
110 entry_ref ref;
111 image_id image;
112 T* add_on;
114 typedef struct add_on_info<BInputServerDevice> device_info;
115 typedef struct add_on_info<BInputServerFilter> filter_info;
116 typedef struct add_on_info<BInputServerMethod> method_info;
118 BObjectList<device_info> fDeviceList;
119 BObjectList<filter_info> fFilterList;
120 BObjectList<method_info> fMethodList;
122 BObjectList<DeviceAddOn> fDeviceAddOns;
123 PathList fDevicePaths;
125 MonitorHandler* fHandler;
127 bool fSafeMode;
130 #endif // ADD_ON_MANAGER_H