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_connect(ipc::channel *ch, ipc::message &msg);
48 int manager_disconnect(ipc::channel *ch, ipc::message &msg);
49 int manager_get_sensor_list(ipc::channel *ch, ipc::message &msg);
52 int listener_connect(ipc::channel *ch, ipc::message &msg);
53 int listener_disconnect(ipc::channel *ch, ipc::message &msg);
54 int listener_start(ipc::channel *ch, ipc::message &msg);
55 int listener_stop(ipc::channel *ch, ipc::message &msg);
56 int listener_attr_int(ipc::channel *ch, ipc::message &msg);
57 int listener_attr_str(ipc::channel *ch, ipc::message &msg);
58 int listener_get_data(ipc::channel *ch, ipc::message &msg);
60 int provider_connect(ipc::channel *ch, ipc::message &msg);
61 int provider_disconnect(ipc::channel *ch, ipc::message &msg);
62 int provider_publish(ipc::channel *ch, ipc::message &msg);
64 int has_privileges(ipc::channel *ch, ipc::message &msg);
66 bool has_privilege(int fd, std::string &priv);
67 bool has_privileges(int fd, std::string priv);
69 int send_reply(ipc::channel *ch, int error);
71 sensor_manager *m_manager;
74 static std::unordered_map<uint32_t, sensor_listener_proxy *> m_listeners;
77 static std::unordered_map<ipc::channel *, uint32_t> m_listener_ids;
79 /* {channel, application_sensor_handler} */
80 /* it should move to sensor_manager */
81 static std::unordered_map<ipc::channel *, application_sensor_handler *> m_app_sensors;
86 #endif /* __SERVER_CHANNEL_HANDLER_H__ */