2 * Copyright 2004-2013, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
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>
21 #include <AddOnMonitor.h>
22 #include <AddOnMonitorHandler.h>
27 using namespace BPrivate
;
29 class AddOnManager
: public AddOnMonitor
{
34 virtual void MessageReceived(BMessage
* message
);
39 status_t
StartMonitoringDevice(DeviceAddOn
* addOn
,
41 status_t
StopMonitoringDevice(DeviceAddOn
* addOn
,
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
,
64 status_t
_HandleWatchDevices(BMessage
* message
,
66 status_t
_HandleIsDeviceRunning(BMessage
* message
,
68 status_t
_HandleStartStopDevices(BMessage
* message
,
70 status_t
_HandleControlDevices(BMessage
* message
,
72 status_t
_HandleSystemShuttingDown(BMessage
* message
,
74 status_t
_HandleMethodReplicant(BMessage
* message
,
76 void _HandleDeviceMonitor(BMessage
* message
);
78 void _LoadReplicant();
79 void _UnloadReplicant();
80 int32
_GetReplicantAt(BMessenger target
,
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
);
94 friend class MonitorHandler
;
96 template<typename T
> struct add_on_info
{
99 image(-1), add_on(NULL
)
107 unload_add_on(image
);
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
;
130 #endif // ADD_ON_MANAGER_H