4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef __SERVER_CHANNEL_HANDLER_H__
21 #define __SERVER_CHANNEL_HANDLER_H__
24 #include <channel_handler.h>
25 #include <unordered_map>
28 #include "sensor_manager.h"
29 #include "sensor_listener_proxy.h"
30 #include "application_sensor_handler.h"
34 class server_channel_handler : public ipc::channel_handler
37 server_channel_handler(sensor_manager *manager);
38 ~server_channel_handler();
40 void connected(ipc::channel *ch);
41 void disconnected(ipc::channel *ch);
42 void read(ipc::channel *ch, ipc::message &msg);
43 void read_complete(ipc::channel *ch) {}
44 void error_caught(ipc::channel *ch, int error) {}
47 int manager_get_sensor_list(ipc::channel *ch, ipc::message &msg);
49 int listener_connect(ipc::channel *ch, ipc::message &msg);
50 int listener_disconnect(ipc::channel *ch, ipc::message &msg);
51 int listener_start(ipc::channel *ch, ipc::message &msg);
52 int listener_stop(ipc::channel *ch, ipc::message &msg);
53 int listener_attr_int(ipc::channel *ch, ipc::message &msg);
54 int listener_attr_str(ipc::channel *ch, ipc::message &msg);
55 int listener_get_data(ipc::channel *ch, ipc::message &msg);
57 int provider_connect(ipc::channel *ch, ipc::message &msg);
58 int provider_disconnect(ipc::channel *ch, ipc::message &msg);
59 int provider_post(ipc::channel *ch, ipc::message &msg);
61 int has_privileges(ipc::channel *ch, ipc::message &msg);
63 bool has_privilege(int fd, std::string &priv);
64 bool has_privileges(int fd, std::string priv);
66 int send_reply(ipc::channel *ch, int error);
68 sensor_manager *m_manager;
71 std::unordered_map<uint32_t, sensor_listener_proxy *> m_listeners;
74 std::unordered_map<ipc::channel *, uint32_t> m_listener_ids;
76 /* {name, application_sensor_handler} */
77 /* TODO: move it to sensor_manager */
78 std::unordered_map<std::string, application_sensor_handler *> m_sensors;
83 #endif /* __SERVER_CHANNEL_HANDLER_H__ */