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) {}
45 void set_handler(int num, ipc::channel_handler* handler) {}
46 void disconnect(void) {}
49 int manager_connect(ipc::channel *ch, ipc::message &msg);
50 int manager_disconnect(ipc::channel *ch, ipc::message &msg);
51 int manager_get_sensor_list(ipc::channel *ch, ipc::message &msg);
54 int listener_connect(ipc::channel *ch, ipc::message &msg);
55 int listener_disconnect(ipc::channel *ch, ipc::message &msg);
56 int listener_start(ipc::channel *ch, ipc::message &msg);
57 int listener_stop(ipc::channel *ch, ipc::message &msg);
58 int listener_set_attr_int(ipc::channel *ch, ipc::message &msg);
59 int listener_set_attr_str(ipc::channel *ch, ipc::message &msg);
60 int listener_get_data(ipc::channel *ch, ipc::message &msg);
61 int listener_get_attr_int(ipc::channel *ch, ipc::message &msg);
62 int listener_get_attr_str(ipc::channel *ch, ipc::message &msg);
63 int listener_get_data_list(ipc::channel *ch, ipc::message &msg);
65 int provider_connect(ipc::channel *ch, ipc::message &msg);
66 int provider_disconnect(ipc::channel *ch, ipc::message &msg);
67 int provider_publish(ipc::channel *ch, ipc::message &msg);
69 int has_privileges(ipc::channel *ch, ipc::message &msg);
71 bool has_privilege(int fd, std::string &priv);
72 bool has_privileges(int fd, std::string priv);
74 int send_reply(ipc::channel *ch, int error);
76 sensor_manager *m_manager;
79 static std::unordered_map<uint32_t, sensor_listener_proxy *> m_listeners;
82 static std::unordered_map<ipc::channel *, uint32_t> m_listener_ids;
84 /* {channel, application_sensor_handler} */
85 /* it should move to sensor_manager */
86 static std::unordered_map<ipc::channel *, application_sensor_handler *> m_app_sensors;
91 #endif /* __SERVER_CHANNEL_HANDLER_H__ */