Modify to add the sensor status to sensor information
[platform/core/connectivity/ua-manager.git] / ua-daemon / include / ua-manager-core.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License")
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef __UAM_MANAGER_CORE_H__
19 #define __UAM_MANAGER_CORE_H__
20
21 #include <dlog.h>
22 #include <glib.h>
23 #include <gio/gio.h>
24 #include <ua-api.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 typedef enum {
31         UAM_ADDR_TYPE_BT = 0x01,
32         UAM_ADDR_TYPE_BLE,
33         UAM_ADDR_TYPE_WIFI,
34         UAM_ADDR_TYPE_P2P,
35         UAM_ADDR_TYPE_IPv4,
36         UAM_ADDR_TYPE_IPv6,
37         UAM_ADDR_TYPE_MAX
38 } uam_addr_type_e;
39
40 #define UAM_DETECTION_WINDOW_DEFAULT 55 /* 55 seconds */
41 #define UAM_DETECTION_WINDOW_MAX  55 /* 55 seconds */
42 #define UAM_DETECTION_WINDOW_STEP 5 /* 5 seconds */
43
44 #define UAM_DETECTION_CYCLE_DEFAULT 900 /* 900 seconds */
45 #define UAM_DETECTION_CYCLE_MIN 60 /* 60 seconds */
46
47 typedef struct {
48         char *name;
49         unsigned int cycle;
50         int remaining_time;
51         int presence_threshold;
52         int absence_threshold;
53         GSList *monitors;
54         GSList *dev_techs;
55 } uam_db_service_info_t;
56
57 typedef struct {
58         char *device_id;
59         uam_tech_type_e tech_type;
60         char *service;
61         int discriminant;
62 } uam_svc_dev_info_t;
63
64 typedef struct {
65         uam_addr_type_e addr_type;
66         char *address;
67 } uam_db_address_info_t;
68
69 typedef struct {
70         char service_id; /** Service Id */
71         char device_icon; /** Device icon */
72         char purpose; /** Purpose */
73         char *duid; /** DUID */
74         char *bt_mac; /** BT MAC Address */
75 } uam_db_ble_payload_t;
76
77 typedef struct {
78         uam_tech_type_e tech_type;
79         GSList *addresses;
80         int presence_state;
81         unsigned long long timestamp;
82         gboolean discriminant;
83         struct uam_db_device_info *device;
84         GSList *svc_list;
85         uam_db_ble_payload_t *payload;
86 } uam_db_tech_info_t;
87
88 typedef struct uam_db_device_info {
89         int os;
90         char *device_id;
91         GSList *tech_list;
92         unsigned int supported_techs;
93 //      int presence_state;
94 //      long timestamp;
95         struct uam_db_user_info *user;
96         gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
97 } uam_db_device_info_t;
98
99 typedef struct uam_db_user_info {
100         int user_id;
101         char *name;
102         char *account;
103         GSList *devices;
104 //      int presence_state;
105         unsigned long long timestamp;
106 } uam_db_user_info_t;
107
108
109 typedef enum {
110         UAM_ACTIVE_DEVICE_FOUND = 0x01,
111         UAM_ACTIVE_SCAN_COMPLETED = 0x02
112 } uam_active_scan_event_e;
113
114 int _uam_core_add_user(const char *account, const char *name);
115
116 int _uam_core_remove_user(const char *account);
117
118 int _uam_core_add_device(const char *account, const uam_device_info_s *dev_info);
119
120 int _uam_core_remove_device(const char *account, const uam_device_info_s *dev_info);
121
122 int _uam_core_remove_device_by_device_id(const char *device_id, int tech_type);
123
124 int _uam_core_remove_device_by_mac(const char *mac);
125
126 int _uam_core_get_default_user(uam_user_info_s *user_info);
127
128 int _uam_core_get_users(int *count, uam_user_info_s **user_list);
129
130 int _uam_core_get_user_by_account(const char *account, uam_user_info_s *user);
131
132 int _uam_core_get_devcie_by_device_id(
133                 const char *device_id, int tech_type, uam_device_info_s *device);
134
135 int _uam_core_get_devcie_by_mac(const char *mac, uam_device_info_s *device);
136
137 int _uam_core_get_user_by_device_id(const char *device_id, uam_user_info_s *user);
138
139 int _uam_core_get_user_by_mac(const char *mac, uam_user_info_s *user);
140
141 int _uam_core_get_devices(int *count, uam_device_info_s **device_list);
142
143 int _uam_core_get_user_devices(const char *account,
144                 int *count, uam_device_info_s **device_list);
145
146 int _uam_core_is_device_added(uam_device_info_s *dev, gboolean *is_added);
147
148 int _uam_core_get_available_sensors(unsigned int *sensor_bitmask);
149
150 gboolean _uam_core_is_sensor_ready(unsigned int sensor);
151
152 int _uam_core_set_detection_threshold(unsigned int sensor,
153                 int presence_threshold, int absence_threshold);
154
155 int _uam_core_start_presence_detection(const char *svc_name, char *sender, unsigned int sensors);
156
157 int _uam_core_stop_presence_detection(const char *svc_name, char *sender, unsigned int sensors);
158
159 int _uam_core_start_absence_detection(const char *svc_name, char *sender, unsigned int sensors);
160
161 int _uam_core_stop_absence_detection(const char *svc_name, char *sender, unsigned int sensors);
162
163 int _uam_core_set_low_power_mode(unsigned int bit_mask, gboolean mode);
164
165 int _uam_core_get_detection_window(unsigned int *window);
166
167 int _uam_core_set_detection_window(unsigned int window);
168
169 int _uam_core_init(void);
170
171 void _uam_core_deinit(void);
172
173 void _uam_core_handle_sensor_ready(unsigned int sensor, gboolean is_ready);
174
175 int _uam_core_handle_device_added(int status,
176                 int user_id, const uam_device_info_s *dev_info);
177
178 void _uam_core_handle_presence_detected(unsigned int sensor,
179                 int user_id, void *sensor_info);
180
181 void _uam_core_handle_absence_detected(unsigned int sensor,
182                 int user_id, void *sensor_info);
183
184 void _uam_core_cleanup_monitor(char *name);
185
186 void _uam_core_reset_database(void);
187
188 unsigned int _uam_core_get_active_sensors(int detection_mode);
189
190 void _uam_core_handle_detection_started(unsigned int sensor);
191
192 void _uam_core_handle_detection_stopped(unsigned int sensor);
193
194 int _uam_core_start_active_device_scan(char *sender, unsigned int sensors, int detection_period);
195
196 int _uam_core_stop_active_device_scan(char *sender, unsigned int sensors);
197
198 void _uam_core_handle_active_device(uam_active_scan_event_e event, unsigned int sensor, const uam_device_info_s *dev_info);
199
200 int _uam_core_get_default_service(uam_service_info_s *service_info);
201
202 int _uam_core_register_service(uam_service_info_s *svc);
203
204 int _uam_core_update_service(uam_service_info_s *svc);
205
206 int _uam_core_unregister_service(const char *svc_name);
207
208 int _uam_core_get_service_devices(const char *svc_name, int *count, uam_device_info_s **device_list);
209
210 int _uam_core_get_service_users(const char *svc_name, int *count, uam_user_info_s **user_list);
211
212 int _uam_core_get_services(int *count, uam_service_info_s **service_list);
213
214 int _uam_core_service_add_user(const char *service_name, const char *account);
215
216 int _uam_core_service_remove_user(const char *service, const char *account);
217
218 int _uam_core_service_add_device(const char *service_name, const char *device_id, int tech_type);
219
220 int _uam_core_service_remove_device(const char *service_name, const char *device_id, int tech_type);
221
222 int _uam_core_service_set_device_discriminant(const char *service_name, const char *device_id, int tech_type, gboolean discriminant);
223
224 int _uam_core_service_get_device_discriminant(const char *service_name, const char *device_id, int tech_type, gboolean *discriminant);
225
226 int _uam_core_set_service_detection_cycle(const char *svc_name, unsigned int cycle);
227
228 int _uam_core_get_service_detection_cycle(const char *svc_name, unsigned int *cycle);
229
230 int _uam_core_update_device(const uam_device_info_s *a_device);
231
232 int _uam_core_add_ibeacon_adv(unsigned int adv_len, const char *iadv);
233
234 void _uam_core_handle_status_changed(unsigned int sensor, void *info);
235
236 #ifdef __cplusplus
237 }
238 #endif
239 #endif /* __UAM_MANAGER_CORE_H__ */