a33fea6bb17a13ab8e656e79ab278b3dd4b24254
[platform/core/connectivity/ua-manager.git] / include / ua-api.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 __TIZEN_UA_NETWORK_UA_API_H__
19 #define __TIZEN_UA_NETWORK_UA_API_H__
20
21 #include <gmodule.h>
22 #include <tizen_error.h>
23
24 #ifndef TIZEN_ERROR_UA
25 #define TIZEN_ERROR_UA 0x11170000 /**< To-Do: This should move to tizen_error.h */
26 #endif
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /**
33  * @brief Bitmask for sensors.
34  * @since_tizen 5.5
35  */
36 typedef enum {
37         UAM_SENSOR_BITMASK_BT = 0x00000001, /**< Bitmask for BT */
38         UAM_SENSOR_BITMASK_BLE = 0x00000002, /**< Bitmask for BLE */
39         UAM_SENSOR_BITMASK_WIFI = 0x00000004, /**< Bitmask for Wi-Fi */
40         UAM_SENSOR_BITMASK_MOTION = 0x00000008, /**< Bitmask for motion */
41         UAM_SENSOR_BITMASK_LIGHT = 0x00000010, /**< Bitmask for light */
42         UAM_SENSOR_BITMASK_AUDIO = 0x00000020, /**< Bitmask for autio */
43         UAM_SENSOR_ALL = 0xFFFFFFFF, /**< Bitmask for all sensors */
44 } uam_sensor_bitmask_e;
45
46 /**
47  * @brief Max. MAC address length.
48  * @since_tizen 5.5
49  */
50 #define UAM_MAC_ADDRESS_STRING_LEN 18
51
52 /**
53  * @brief Max. device id length.
54  * @since_tizen 5.5
55  */
56 #define UAM_DEVICE_ID_MAX_STRING_LEN 50
57
58 /**
59  * @brief Device's BLE payload DUID length.
60  * @since_tizen 5.5
61  */
62 #define UAM_BLE_PAYLOAD_DUID_LEN 17
63
64 /**
65  * @brief Max. BT MAC address length.
66  * @since_tizen 5.5
67  */
68 #define UAM_BT_MAC_ADDRESS_STRING_LEN 18
69
70 /**
71  * @brief Max. IP address length.
72  * @since_tizen 5.5
73  */
74 #define UAM_IP_ADDRESS_MAX_STRING_LEN 50
75
76 /**
77  * @brief Max. user name length.
78  * @since_tizen 5.5
79  */
80 #define UAM_USER_NAME_MAX_STRING_LEN 254
81
82 /**
83  * @brief Max. user account length.
84  * @since_tizen 5.5
85  */
86 #define UAM_USER_ACCOUNT_MAX_STRING_LEN 254
87
88 /**
89  * @brief Max. application id length.
90  * @since_tizen 5.5
91  */
92 #define UAM_APP_ID_MAX_STRING_LEN 100
93
94 /**
95  * @brief Max. service id length.
96  * @since_tizen 5.5
97  */
98 #define UAM_SERVICE_MAX_STRING_LEN 50
99
100 /**
101  * @brief Default service name.
102  * @since_tizen 5.5
103  */
104 #define UAM_SERVICE_DEFAULT "ua.service.default"
105
106 /**
107  * @brief Default presence threshold.
108  * @since_tizen 5.5
109  */
110 #define UAM_PRESENCE_THRESHOLD_DEFAULT 2
111
112 /**
113  * @brief Default absence threshold.
114  * @since_tizen 5.5
115  */
116 #define UAM_ABSENCE_THRESHOLD_DEFAULT 0
117
118 /**
119  * @brief Macro for event enum.
120  * @since_tizen 5.5
121  */
122 #define GENERATE_EVENT_ENUM(ENUM) ENUM,
123
124 /**
125  * @brief Macro to print event string out.
126  * @since_tizen 5.5
127  */
128 #define GENERATE_EVENT_STRING(STRING) #STRING,
129
130 /**
131  * @brief Max. ibeacon adv length.
132  * @since_tizen 5.5
133  */
134 #define UAM_IBEACON_ADV_MAX_LEN 31
135
136 /**
137  * @brief Maximum number of values from sensor.
138  * @since_tizen 5.5
139  */
140 #define UAM_SENSOR_MAX_VALUES 4
141
142 /**
143  * @brief Enumerations macro of UA framework event codes.
144  * @since_tizen 5.5
145  */
146 typedef enum {
147         UAM_EVENT_USER_ADDED, /**< User added */
148         UAM_EVENT_USER_REMOVED, /**< User removed */
149         UAM_EVENT_DEVICE_ADDED, /**< Device added */
150         UAM_EVENT_DEVICE_REMOVED, /**< Device removed */
151         UAM_EVENT_PRESENCE_DETECTED, /**< Presence detected */
152         UAM_EVENT_USER_PRESENCE_DETECTED, /**< User presence detected */
153         UAM_EVENT_ABSENCE_DETECTED, /**< Absence detected */
154         UAM_EVENT_USER_ABSENCE_DETECTED, /**< User absence detected */
155         UAM_EVENT_AMBIANT_MODE_ENABLED, /**< Ambient mode enabled */
156         UAM_EVENT_AMBIANT_MODE_DISABLED, /**< Ambient mode disabled */
157         UAM_EVENT_SENSOR_STATE_READY, /**< Sensor state ready */
158         UAM_EVENT_SENSOR_STATE_NOT_READY, /**< Sensor state not ready */
159         UAM_EVENT_DETECTION_STARTED, /**< Detection started */
160         UAM_EVENT_DETECTION_STOPPED, /**< Detection stopped */
161         UAM_EVENT_DEVICE_FOUND, /**< Device found */
162         UAM_EVENT_SCAN_COMPLETED, /**< Scan completed */
163         UAM_EVENT_SERVICE_REGISTERED, /**< Service registered */
164         UAM_EVENT_SERVICE_UNREGISTERED, /**< Service registered */
165         UAM_EVENT_SENSOR_STATUS_CHANGED, /**< Sensor status changed */
166         UAM_EVENT_MAX, /**< Max. event number */
167 } uam_event_e;
168
169 /**
170  * @brief Macro to print error string out.
171  * @since_tizen 5.5
172  */
173 #define GENERATE_ERROR_CASE(STRING, offset) case STRING: return #STRING;
174
175 /**
176  * @brief Enumerations macro of UA framework error codes.
177  * @since_tizen 5.5
178  */
179 typedef enum {
180         UAM_ERROR_NONE = TIZEN_ERROR_NONE, /**< Succsssful */
181         UAM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
182         UAM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
183         UAM_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
184         UAM_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Resource busy */
185         UAM_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Time out */
186         UAM_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Now in progress */
187         UAM_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
188         UAM_ERROR_NOT_INITIALIZED = TIZEN_ERROR_UA | 0x01, /**< Not initiaized */
189         UAM_ERROR_NOT_IN_OPERATION = TIZEN_ERROR_UA | 0x02, /**< Not in progress */
190         UAM_ERROR_ALREADY_DONE = TIZEN_ERROR_UA | 0x03, /**< Already done */
191         UAM_ERROR_INTERNAL = TIZEN_ERROR_UA | 0x04, /**< Internal error */
192         UAM_ERROR_NOT_FOUND = TIZEN_ERROR_UA | 0x10, /**< Not found */
193         UAM_ERROR_ALREADY_REGISTERED = TIZEN_ERROR_UA | 0x11, /**< Already registered */
194         UAM_ERROR_DB_FAILED = TIZEN_ERROR_UA | 0x12, /**< DB operation failed */
195         UAM_ERROR_NOT_REGISTERED = TIZEN_ERROR_UA | 0x13, /**< Not registered */
196 } uam_error_e;
197
198 /**
199  * @brief Eevent data structure.
200  * @since_tizen 5.5
201  */
202 typedef struct {
203         int result; /**< Result code */
204         void *data; /**< Data pointer */
205 } uam_event_data_s;
206
207 /**
208  * @brief Callback to be invoked when receiving events.
209  * @since_tizen 5.5
210  *
211  * @remarks The @a event_param should not be released.
212  * @remarks The @a event_param can be used only in the callback.
213  *
214  * @param[in] event Event type.
215  * @param[in] event_param The event data structure.
216  * @param[in] user_data The user data passed in _uam_init()
217  *
218  * @exception
219  * @pre
220  * @post
221  *
222  * @see _uam_init()
223  */
224 typedef void (*uam_event_cb)(int event, uam_event_data_s *event_param, void *user_data);
225
226 /**
227  * @brief Initializes client library.
228  * @since_tizen 5.5
229  *
230  * @param[in] cb Callback handler
231  * @param[in] user_data The user data.
232  *
233  * @return 0 on success, otherwise a negative error value
234  * @retval #UAM_ERROR_NONE Successful
235  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
236  * @rerval #UAM_ERROR_ALREADY_REGISTERED Already registered
237  * @retval #UAM_ERROR_INTERNAL Internal error
238  *
239  * @exception
240  * @pre
241  * @post
242  */
243 int _uam_init(uam_event_cb cb, void *user_data);
244
245 /**
246  * @brief De-initializes client library.
247  * @since_tizen 5.5
248  *
249  * @return 0 on success, otherwise a negative error value
250  * @retval #UAM_ERROR_NONE Successful
251  * @rerval #UAM_ERROR_NOT_REGISTERED Not registered
252  * @retval #UAM_ERROR_INTERNAL Internal error
253  *
254  * @exception
255  * @pre
256  * @post
257  */
258 int _uam_deinit(void);
259
260 /**
261  * @brief Gets available sensor list.
262  * @since_tizen 5.5
263  *
264  * @param[out] bitmask Available sensor list
265  *
266  * @return 0 on success, otherwise a negative error value
267  * @retval #UAM_ERROR_NONE Successful
268  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
269  * @retval #UAM_ERROR_INTERNAL Internal error
270  *
271  * @exception
272  * @pre
273  * @post
274  */
275 int _uam_get_available_sensors(unsigned int *bitmask);
276
277 /**
278  * @brief Gets a specific sensor availability.
279  * @since_tizen 5.5
280  *
281  * @param[in] sensor Sensor type
282  * @param[out] status Sensor state
283  *
284  * @return 0 on success, otherwise a negative error value
285  * @retval #UAM_ERROR_NONE Successful
286  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
287  * @retval #UAM_ERROR_INTERNAL Internal error
288  *
289  * @exception
290  * @pre
291  * @post
292  */
293 int _uam_is_sensor_ready(unsigned int sensor, gboolean* status);
294
295 /**
296  * @brief Starts presence detection.
297  * @since_tizen 5.5
298  *
299  * @param[in] bitmask Bitmask to detect
300  * @param[in] service Service name
301  *
302  * @return 0 on success, otherwise a negative error value
303  * @retval #UAM_ERROR_NONE Successful
304  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
305  * @retval #UAM_ERROR_INTERNAL Internal error
306  *
307  * @exception
308  * @pre
309  * @post
310  */
311 int _uam_start_presence_detection(unsigned int bitmask, const char *service);
312
313 /**
314  * @brief Stops presence detection.
315  * @since_tizen 5.5
316  *
317  * @param[in] bitmask Bitmask to detect
318  * @param[in] service Service name
319  *
320  * @return 0 on success, otherwise a negative error value
321  * @retval #UAM_ERROR_NONE Successful
322  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
323  * @retval #UAM_ERROR_INTERNAL Internal error
324  *
325  * @exception
326  * @pre
327  * @post
328  */
329 int _uam_stop_presence_detection(unsigned int bitmask, const char *service);
330
331 /**
332  * @brief Starts absence detection.
333  * @since_tizen 5.5
334  *
335  * @param[in] bitmask Bitmask to detect
336  * @param[in] service Service name
337  *
338  * @return 0 on success, otherwise a negative error value
339  * @retval #UAM_ERROR_NONE Successful
340  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
341  * @retval #UAM_ERROR_INTERNAL Internal error
342  *
343  * @exception
344  * @pre
345  * @post
346  */
347 int _uam_start_absence_detection(unsigned int bitmask, const char *service);
348
349 /**
350  * @brief Stops absence detection.
351  * @since_tizen 5.5
352  *
353  * @param[in] bitmask Bitmask to detect
354  * @param[in] service Service name
355  *
356  * @return 0 on success, otherwise a negative error value
357  * @retval #UAM_ERROR_NONE Successful
358  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
359  * @retval #UAM_ERROR_INTERNAL Internal error
360  *
361  * @exception
362  * @pre
363  * @post
364  */
365 int _uam_stop_absence_detection(unsigned int bitmask, const char *service);
366
367 /**
368  * @brief Starts active devices searching.
369  * @since_tizen 5.5
370  *
371  * @param[in] bitmask Bitmask to detect
372  * @param[in] detection_period Detection period
373  *
374  * @return 0 on success, otherwise a negative error value
375  * @retval #UAM_ERROR_NONE Successful
376  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
377  * @retval #UAM_ERROR_INTERNAL Internal error
378  *
379  * @exception
380  * @pre
381  * @post
382  */
383 int _uam_start_search_active_devices(unsigned int bitmask, int detection_period);
384
385 /**
386  * @brief Stops active devices searching.
387  * @since_tizen 5.5
388  *
389  * @param[in] bitmask Bitmask to detect
390  *
391  * @return 0 on success, otherwise a negative error value
392  * @retval #UAM_ERROR_NONE Successful
393  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
394  * @retval #UAM_ERROR_INTERNAL Internal error
395  *
396  * @exception
397  * @pre
398  * @post
399  */
400 int _uam_stop_search_active_devices(unsigned int bitmask);
401
402 /**
403  * @brief Registers application id.
404  * @since_tizen 5.5
405  *
406  * @param[in] app_id Application id
407  * @param[in] uid User id
408  *
409  * @return 0 on success, otherwise a negative error value
410  * @retval #UAM_ERROR_NONE Successful
411  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
412  * @retval #UAM_ERROR_INTERNAL Internal error
413  *
414  * @exception
415  * @pre
416  * @post
417  */
418 int _uam_register_app(const char *app_id, unsigned short uid);
419
420 /**
421  * @brief Unregisters application id.
422  * @since_tizen 5.5
423  *
424  * @param[in] app_id Application id
425  * @param[in] uid User id
426  *
427  * @return 0 on success, otherwise a negative error value
428  * @retval #UAM_ERROR_NONE Successful
429  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
430  * @retval #UAM_ERROR_INTERNAL Internal error
431  *
432  * @exception
433  * @pre
434  * @post
435  */
436 int _uam_deregister_app(const char *app_id, unsigned short uid);
437
438 /**
439  * @brief Enumerations for presence state.
440  * @since_tizen 5.5
441  */
442 typedef enum {
443         UAM_PRESENCE_STATE_INVALID = 0x00, /**< Invaild state */
444         UAM_PRESENCE_STATE_PRESENT, /**< Presence state */
445         UAM_PRESENCE_STATE_ABSENT, /**< Absence state */
446 } uam_presence_state_e;
447
448 /**
449  * @brief Enumerations for OS type.
450  * @since_tizen 5.5
451  */
452 typedef enum {
453         UAM_OS_TYPE_UNDEFINED = 0x00, /**< Undefined */
454         UAM_OS_TYPE_TIZEN, /**< Tizen */
455         UAM_OS_TYPE_ANDROID, /**< Android */
456         UAM_OS_TYPE_IOS, /**< iOS */
457         UAM_OS_TYPE_INVALID /**< Invalid */
458 } uam_os_type_e;
459
460 /**
461  * @brief Enumerations for connectivity type.
462  * @since_tizen 5.5
463  */
464 typedef enum {
465         UAM_TECH_TYPE_NONE = 0x00, /**< None */
466         UAM_TECH_TYPE_BT = 0x01, /**< BT */
467         UAM_TECH_TYPE_BLE = 0x02, /**< BLE */
468         UAM_TECH_TYPE_WIFI = 0x04, /**< Wi-Fi */
469         UAM_TECH_TYPE_P2P = 0x08, /**< Wi-Fi p2p */
470         UAM_TECH_TYPE_MAX /**< Max. connectivity type */
471 } uam_tech_type_e;
472
473 /**
474  * @brief BLE Payload info structure.
475  * @since_tizen 5.5
476  */
477 typedef struct {
478         char service_id; /** Service Id */
479         char device_icon; /** Device icon */
480         char purpose; /** Purpose */
481         char duid[UAM_BLE_PAYLOAD_DUID_LEN + 1]; /** DUID */
482         char bt_mac[UAM_BT_MAC_ADDRESS_STRING_LEN]; /** BT MAC Address */
483 } uam_ble_payload_s;
484
485 /**
486  * @brief Device info structure.
487  * @since_tizen 5.5
488  */
489 typedef struct {
490         uam_os_type_e operating_system; /**< Operating system */
491         uam_tech_type_e type; /**< Device's mac address type (BT/BLE/WIFI/P2p/...) */
492         char mac[UAM_MAC_ADDRESS_STRING_LEN]; /**< Device's MAC ADDRESS */
493         char ipv4_addr[UAM_IP_ADDRESS_MAX_STRING_LEN];/**< Device's IPv4 address optional */
494         char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's uniquie ID */
495         uam_ble_payload_s payload; /**< BLE Payload to parse BLE devices*/
496         gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
497         long last_seen; /**< Latest timestamp when device was discoverd */
498 } uam_device_info_s;
499
500 /**
501  * @brief Sensor info structure.
502  * @since_tizen 5.5
503  */
504 typedef struct {
505         unsigned int status; /**< Sensor status */
506         unsigned int sensor_bitmask; /**< sensor bitmask of discovered sensor */
507         long timestamp; /**< Latest timestamp when sensor was discoverd */
508         int accuracy; /**< Accuracy info from sensor sensor */
509         int count; /**< count of values from sensor sensor */
510         double values[UAM_SENSOR_MAX_VALUES]; /**< info from sensor */
511 } uam_sensor_info_s;
512
513 /**
514  * @brief User info structure.
515  * @since_tizen 5.5
516  */
517 typedef struct {
518         char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
519         char name[UAM_USER_NAME_MAX_STRING_LEN]; /**< User name */
520 } uam_user_info_s;
521
522 /**
523  * @brief Service info structure.
524  * @since_tizen 5.5
525  */
526 typedef struct {
527         char name[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
528         unsigned int presence_threshold;
529         unsigned int absence_threshold;
530 } uam_service_info_s;
531
532 /**
533  * @brief Detection event structure.
534  * @since_tizen 5.5
535  */
536 typedef struct {
537         unsigned int sensor_bitmask; /**< Detecting sensor's bitmask */
538         char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
539         char service[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
540         long timestamp; /**< Timestamp of detection */
541         char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's unique ID */
542 } uam_detection_event_data_s;
543
544 /**
545  * @brief User event structure.
546  * @since_tizen 5.5
547  */
548 typedef struct {
549         char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
550         char name[UAM_USER_NAME_MAX_STRING_LEN]; /**< User name */
551 } uam_user_event_data_s;
552
553 /**
554  * @brief Application info structure.
555  * @since_tizen 5.5
556  */
557 typedef struct {
558         char *sender; /**< Dbus sender */
559         unsigned short uid; /**< UID */
560         char app_id[UAM_APP_ID_MAX_STRING_LEN]; /**< Application id */
561 } uam_app_info_s;
562
563 /**
564  * @brief Gets registered user list.
565  * @since_tizen 5.5
566  *
567  * @remarks The @a user_list should be destroyed by using #g_free() and #g_ptr_array_free().
568  *
569  * @param[out] user_list User list array
570  *
571  * @return 0 on success, otherwise a negative error value
572  * @retval #UAM_ERROR_NONE Successful
573  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
574  * @retval #UAM_ERROR_INTERNAL Internal error
575  *
576  * @exception
577  * @pre
578  * @post
579  */
580 int _uam_get_registered_users(GPtrArray **user_list);
581
582 /**
583  * @brief Checks registerd device.
584  * @since_tizen 5.5
585  *
586  * @param[in] dev_info Device info
587  * @param[out] is_registered Registered or not
588  *
589  * @return 0 on success, otherwise a negative error value
590  * @retval #UAM_ERROR_NONE Successful
591  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
592  * @retval #UAM_ERROR_INTERNAL Internal error
593  *
594  * @exception
595  * @pre
596  * @post
597  */
598 int _uam_is_device_registered(
599                 uam_device_info_s *dev_info, gboolean *is_registered);
600
601 /**
602  * @brief Callback to be called when receiving events.
603  * @since_tizen 5.5
604  *
605  * @remarks The @a event_param should not be released.
606  * @remarks The @a event_param can be used only in the callback.
607  *
608  * @param[in] event Event type
609  * @param[in] event_param Event data
610  * @param[in] user_data User data passed in _uam_init().
611  *
612  * @return 0 on success, otherwise a negative error value
613  * @retval #UAM_ERROR_NONE Successful
614  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
615  * @retval #UAM_ERROR_INTERNAL Internal error
616  *
617  * @exception
618  * @pre
619  * @post
620  */
621 typedef void (*uam_event_cb)(int event, uam_event_data_s *event_param, void *user_data);
622
623 /**
624  * @brief Intializes a client library of ua-manager.
625  * @since_tizen 5.5
626  *
627  * @param[in] cb Event callback
628  * @param[in] user_data User data passed in _uam_init().
629  *
630  * @return 0 on success, otherwise a negative error value
631  * @retval #UAM_ERROR_NONE Successful
632  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
633  * @retval #UAM_ERROR_INTERNAL Internal error
634  *
635  * @exception
636  * @pre
637  * @post
638  */
639 int _uam_init(uam_event_cb cb, void *user_data);
640
641 /**
642  * @brief De-intializes a client library of ua-manager.
643  * @since_tizen 5.5
644  *
645  * @return 0 on success, otherwise a negative error value
646  * @retval #UAM_ERROR_NONE Successful
647  * @retval #UAM_ERROR_INTERNAL Internal error
648  *
649  * @exception
650  * @pre
651  * @post
652  */
653 int _uam_deinit(void);
654
655 /**
656  * @brief Retrieves available sensor list.
657  * @since_tizen 5.5
658  *
659  * @param[in] bitmask Available sensor list
660  *
661  * @return 0 on success, otherwise a negative error value
662  * @retval #UAM_ERROR_NONE Successful
663  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
664  * @retval #UAM_ERROR_INTERNAL Internal error
665  *
666  * @exception
667  * @pre
668  * @post
669  */
670 int _uam_get_available_sensors(unsigned int *bitmask);
671
672 /**
673  * @brief Gets default user info.
674  * @since_tizen 5.5
675  *
676  * @param[in] uam_user User information
677  *
678  * @return 0 on success, otherwise a negative error value
679  * @retval #UAM_ERROR_NONE Successful
680  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
681  * @retval #UAM_ERROR_INTERNAL Internal error
682  *
683  * @exception
684  * @pre
685  * @post
686  */
687 int _uam_get_default_user(uam_user_info_s *uam_user);
688
689 /**
690  * @brief Adds user info.
691  * @since_tizen 5.5
692  *
693  * @param[in] user User information.
694  *
695  * @return 0 on success, otherwise a negative error value
696  * @retval #UAM_ERROR_NONE Successful
697  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
698  * @retval #UAM_ERROR_INTERNAL Internal error
699  *
700  * @exception
701  * @pre
702  * @post
703  */
704 int _uam_add_user(uam_user_info_s *user);
705
706 /**
707  * @brief Removes user info.
708  * @since_tizen 5.5
709  *
710  * @param[in] account User account.
711  *
712  * @return 0 on success, otherwise a negative error value
713  * @retval #UAM_ERROR_NONE Successful
714  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
715  * @retval #UAM_ERROR_INTERNAL Internal error
716  *
717  * @exception
718  * @pre
719  * @post
720  */
721 int _uam_remove_user(char *account);
722
723 /**
724  * @brief Brings user information that meet the user account.
725  * @since_tizen 5.5
726  *
727  * @remarks The @a user should not be released.
728  * @remarks The @a user can be used only in the function.
729  *
730  * @param[in] account User account.
731  * @param[out] user User information.
732  *
733  * @return 0 on success, otherwise a negative error value
734  * @retval #UAM_ERROR_NONE Successful
735  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
736  * @retval #UAM_ERROR_INTERNAL Internal error
737  *
738  * @exception
739  * @pre
740  * @post
741  */
742 int _uam_request_get_user_by_account(char *account, uam_user_info_s *user);
743
744 /**
745  * @brief Brings user information that meet the device id.
746  * @since_tizen 5.5
747  *
748  * @remarks The @a user should not be released.
749  * @remarks The @a user can be used only in the function.
750  *
751  * @param[in] device_id Device id.
752  * @param[out] user User information.
753  *
754  * @return 0 on success, otherwise a negative error value
755  * @retval #UAM_ERROR_NONE Successful
756  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
757  * @retval #UAM_ERROR_INTERNAL Internal error
758  *
759  * @exception
760  * @pre
761  * @post
762  */
763 int _uam_request_get_user_by_deviceid(char *device_id, uam_user_info_s *user);
764
765 /**
766  * @brief Brings user information that meet the MAC address.
767  * @since_tizen 5.5
768  *
769  * @remarks The @a user should not be released.
770  * @remarks The @a user can be used only in the function.
771  *
772  * @param[in] mac Mac address.
773  * @param[out] user User information.
774  *
775  * @return 0 on success, otherwise a negative error value
776  * @retval #UAM_ERROR_NONE Successful
777  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
778  * @retval #UAM_ERROR_INTERNAL Internal error
779  *
780  * @exception
781  * @pre
782  * @post
783  */
784 int _uam_request_get_user_by_mac(char *mac, uam_user_info_s *user);
785
786 /**
787  * @brief Requests to add a device info to the user.
788  * @since_tizen 5.5
789  *
790  * @param[in] account User account.
791  * @param[in] device Device information.
792  *
793  * @return 0 on success, otherwise a negative error value
794  * @retval #UAM_ERROR_NONE Successful
795  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
796  * @retval #UAM_ERROR_INTERNAL Internal error
797  *
798  * @exception
799  * @pre
800  * @post
801  */
802 int _uam_request_add_device(char *account, uam_device_info_s *device);
803
804 /**
805  * @brief Requests to remove a device info to the user.
806  * @since_tizen 5.5
807  *
808  * @param[in] account User account.
809  * @param[in] device Device information.
810  *
811  * @return 0 on success, otherwise a negative error value
812  * @retval #UAM_ERROR_NONE Successful
813  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
814  * @retval #UAM_ERROR_INTERNAL Internal error
815  *
816  * @exception
817  * @pre
818  * @post
819  */
820 int _uam_request_remove_device(char *account, uam_device_info_s *device);
821
822 /**
823  * @brief Deletes device information matching device id and sensor type.
824  * @since_tizen 5.5
825  *
826  * @param[in] device_id Device id.
827  * @param[in] tech_type Sensor type.
828  *
829  * @return 0 on success, otherwise a negative error value
830  * @retval #UAM_ERROR_NONE Successful
831  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
832  * @retval #UAM_ERROR_INTERNAL Internal error
833  *
834  * @exception
835  * @pre
836  * @post
837  */
838 int _uam_request_remove_device_by_deviceid(const char *device_id,
839         uam_tech_type_e tech_type);
840
841 /**
842  * @brief Deletes device information matching device MAC.
843  * @since_tizen 5.5
844  *
845  * @param[in] mac MAC address.
846  *
847  * @return 0 on success, otherwise a negative error value
848  * @retval #UAM_ERROR_NONE Successful
849  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
850  * @retval #UAM_ERROR_INTERNAL Internal error
851  *
852  * @exception
853  * @pre
854  * @post
855  */
856 int _uam_request_remove_device_by_mac(const char *mac);
857
858 /**
859  * @brief Retrieves device information matching device id.
860  * @since_tizen 5.5
861  *
862  * @remarks The @a device should not be released.
863  * @remarks The @a device can be used only in the function.
864  *
865  * @param[in] device_id Device id.
866  * @param[in] tech_type Sensor type.
867  * @param[out] device Device information.
868  *
869  * @return 0 on success, otherwise a negative error value
870  * @retval #UAM_ERROR_NONE Successful
871  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
872  * @retval #UAM_ERROR_INTERNAL Internal error
873  *
874  * @exception
875  * @pre
876  * @post
877  */
878 int _uam_request_get_device_by_deviceid(const char *device_id,
879         uam_tech_type_e tech_type, uam_device_info_s *device);
880
881 /**
882  * @brief Retrieves device information matching MAC address.
883  * @since_tizen 5.5
884  *
885  * @remarks The @a device should not be released.
886  * @remarks The @a device can be used only in the function.
887  *
888  * @param[in] mac MAC address.
889  * @param[out] device Device information.
890  *
891  * @return 0 on success, otherwise a negative error value
892  * @retval #UAM_ERROR_NONE Successful
893  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
894  * @retval #UAM_ERROR_INTERNAL Internal error
895  *
896  * @exception
897  * @pre
898  * @post
899  */
900 int _uam_request_get_device_by_mac(const char *mac, uam_device_info_s *device);
901
902 /**
903  * @brief Gets registered devices list.
904  * @since_tizen 5.5
905  *
906  * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
907  *
908  * @param[out] devices_list Device list array
909  *
910  * @return 0 on success, otherwise a negative error value
911  * @retval #UAM_ERROR_NONE Successful
912  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
913  * @retval #UAM_ERROR_INTERNAL Internal error
914  *
915  * @exception
916  * @pre
917  * @post
918  */
919 int _uam_request_get_devices(GPtrArray **devices_list);
920
921 /**
922  * @brief Gets registered devices list per a user.
923  * @since_tizen 5.5
924  *
925  * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
926  *
927  * @param[in] account User account.
928  * @param[out] devices_list Devices list
929  *
930  * @return 0 on success, otherwise a negative error value
931  * @retval #UAM_ERROR_NONE Successful
932  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
933  * @retval #UAM_ERROR_INTERNAL Internal error
934  *
935  * @exception
936  * @pre
937  * @post
938  */
939 int _uam_request_get_user_devices(char *account, GPtrArray **devices_list);
940
941 /**
942  * @brief Sets detection threshold.
943  * @since_tizen 5.5
944  *
945  * @param[in] sensor_type Sensor type.
946  * @param[in] presence_threshold Threshold value for presence.
947  * @param[in] absence_threshold Threshold value for absence.
948  *
949  * @return 0 on success, otherwise a negative error value
950  * @retval #UAM_ERROR_NONE Successful
951  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
952  * @retval #UAM_ERROR_INTERNAL Internal error
953  *
954  * @exception
955  * @pre
956  * @post
957  */
958 int _uam_request_set_detection_threshold(unsigned int sensor_type,
959         int presence_threshold, int absence_threshold);
960
961 /**
962  * @brief Sets low-power mode.
963  * @since_tizen 5.5
964  *
965  * @param[in] sensor The sensor type
966  * @param[in] on_off Low power mode enable or not
967  *
968  * @return 0 on success, otherwise a negative error value
969  * @retval #UAM_ERROR_NONE Successful
970  * @retval #UAM_ERROR_INTERNAL Internal error
971  *
972  * @exception
973  * @pre
974  * @post
975  */
976 int _uam_set_low_power_mode(unsigned int sensor_bitmask,
977         gboolean mode);
978
979 /**
980  * @brief Gets default service info.
981  * @since_tizen 5.5
982  *
983  * @param[in] service Service information
984  *
985  * @return 0 on success, otherwise a negative error value
986  * @retval #UAM_ERROR_NONE Successful
987  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
988  * @retval #UAM_ERROR_INTERNAL Internal error
989  *
990  * @exception
991  * @pre
992  * @post
993 */
994 int _uam_get_default_service(uam_service_info_s *service);
995
996 /**
997  * @brief Registers service info.
998  * @since_tizen 5.5
999  *
1000  * @param[in] service Service information.
1001  *
1002  * @return 0 on success, otherwise a negative error value
1003  * @retval #UAM_ERROR_NONE Successful
1004  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1005  * @retval #UAM_ERROR_INTERNAL Internal error
1006  *
1007  * @exception
1008  * @pre
1009  * @post
1010  */
1011 int _uam_register_service(uam_service_info_s *service);
1012
1013 /**
1014  * @brief Updates service info.
1015  * @since_tizen 5.5
1016  *
1017  * @param[in] service Service information.
1018  *
1019  * @return 0 on success, otherwise a negative error value
1020  * @retval #UAM_ERROR_NONE Successful
1021  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1022  * @retval #UAM_ERROR_INTERNAL Internal error
1023  *
1024  * @exception
1025  * @pre
1026  * @post
1027  */
1028 int _uam_update_service(uam_service_info_s *service);
1029
1030 /**
1031  * @brief Unregisters service info.
1032  * @since_tizen 5.5
1033  *
1034  * @param[in] service Service information.
1035  *
1036  * @return 0 on success, otherwise a negative error value
1037  * @retval #UAM_ERROR_NONE Successful
1038  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1039  * @retval #UAM_ERROR_INTERNAL Internal error
1040  *
1041  * @exception
1042  * @pre
1043  * @post
1044  */
1045 int _uam_unregister_service(uam_service_info_s *service);
1046
1047 /**
1048  * @brief Gets detction window size.
1049  * @since_tizen 5.5
1050  *
1051  * @param[out] window Window size
1052  *
1053  * @return 0 on success, otherwise a negative error value
1054  * @retval #UAM_ERROR_NONE Successful
1055  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1056  * @retval #UAM_ERROR_INTERNAL Internal error
1057  *
1058  * @exception
1059  * @pre
1060  * @post
1061  */
1062 int _uam_get_detection_window(unsigned int *window);
1063
1064 /**
1065  * @brief Gets registered service list.
1066  * @since_tizen 5.5
1067  *
1068  * @remarks The @a service_list should be destroyed by using #g_free() and #g_ptr_array_free().
1069  *
1070  * @param[out] service_list Service list array
1071  *
1072  * @return 0 on success, otherwise a negative error value
1073  * @retval #UAM_ERROR_NONE Successful
1074  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1075  * @retval #UAM_ERROR_INTERNAL Internal error
1076  *
1077  * @exception
1078  * @pre
1079  * @post
1080  */
1081 int _uam_get_registered_services(GPtrArray **service_list);
1082
1083 /**
1084  * @brief Gets registered users list for a service.
1085  * @since_tizen 5.5
1086  *
1087  * @remarks The @a users_list should be destroyed by using #g_free() and #g_ptr_array_free().
1088  *
1089  * @param[in] svc_name The service name
1090  * @param[out] users_list Users list array
1091  *
1092  * @return 0 on success, otherwise a negative error value
1093  * @retval #UAM_ERROR_NONE Successful
1094  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1095  * @retval #UAM_ERROR_INTERNAL Internal error
1096  *
1097  * @exception
1098  * @pre
1099  * @post
1100  */
1101 int _uam_request_get_service_users(char *svc_name, GPtrArray **users_list);
1102
1103 /**
1104  * @brief Gets registered devices list for a service.
1105  * @since_tizen 5.5
1106  *
1107  * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
1108  *
1109  * @param[in] svc_name The service name
1110  * @param[out] devices_list Devices list array
1111  *
1112  * @return 0 on success, otherwise a negative error value
1113  * @retval #UAM_ERROR_NONE Successful
1114  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1115  * @retval #UAM_ERROR_INTERNAL Internal error
1116  *
1117  * @exception
1118  * @pre
1119  * @post
1120  */
1121 int _uam_request_get_service_devices(char *svc_name, GPtrArray **devices_list);
1122
1123 /**
1124  * @brief Sets detction window.
1125  * @since_tizen 5.5
1126  *
1127  * @param[in] window Window size
1128  *
1129  * @return 0 on success, otherwise a negative error value
1130  * @retval #UAM_ERROR_NONE Successful
1131  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1132  * @retval #UAM_ERROR_INTERNAL Internal error
1133  *
1134  * @exception
1135  * @pre
1136  * @post
1137  */
1138 int _uam_set_detection_window(unsigned int window);
1139
1140 /**
1141  * @brief Adds a user to the service.
1142  * @since_tizen 5.5
1143  *
1144  * @param[in] service Service idt.
1145  * @param[in] account User account.
1146  *
1147  * @return 0 on success, otherwise a negative error value
1148  * @retval #UAM_ERROR_NONE Successful
1149  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1150  * @retval #UAM_ERROR_INTERNAL Internal error
1151  *
1152  * @exception
1153  * @pre
1154  * @post
1155  */
1156 int _uam_service_add_user(const char *service, const char *account);
1157
1158 /**
1159  * @brief Removes a user from the service.
1160  * @since_tizen 5.5
1161  *
1162  * @param[in] service Service idt.
1163  * @param[in] account User account.
1164  *
1165  * @return 0 on success, otherwise a negative error value
1166  * @retval #UAM_ERROR_NONE Successful
1167  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1168  * @retval #UAM_ERROR_INTERNAL Internal error
1169  *
1170  * @exception
1171  * @pre
1172  * @post
1173  */
1174 int _uam_service_remove_user(const char *service, const char *account);
1175
1176 /**
1177  * @brief Adds a device to the service.
1178  * @since_tizen 5.5
1179  *
1180  * @param[in] service Service idt.
1181  * @param[in] device_id Device id.
1182  * @param[in] tech_type Sensor type.
1183  *
1184  * @return 0 on success, otherwise a negative error value
1185  * @retval #UAM_ERROR_NONE Successful
1186  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1187  * @retval #UAM_ERROR_INTERNAL Internal error
1188  *
1189  * @exception
1190  * @pre
1191  * @post
1192  */
1193 int _uam_service_add_device(const char *service, char *device_id,
1194         uam_tech_type_e tech_type);
1195
1196 /**
1197  * @brief Removes a device from the service.
1198  * @since_tizen 5.5
1199  *
1200  * @param[in] service Service idt.
1201  * @param[in] device_id Device id.
1202  * @param[in] tech_type Sensor type.
1203  *
1204  * @return 0 on success, otherwise a negative error value
1205  * @retval #UAM_ERROR_NONE Successful
1206  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1207  * @retval #UAM_ERROR_INTERNAL Internal error
1208  *
1209  * @exception
1210  * @pre
1211  * @post
1212  */
1213 int _uam_service_remove_device(const char *service, char *device_id,
1214         uam_tech_type_e tech_type);
1215
1216 /**
1217  * @brief Sets a device discriminant for the service.
1218  * @since_tizen 5.5
1219  *
1220  * @param[in] service Service idt.
1221  * @param[in] device_id Device id.
1222  * @param[in] tech_type Sensor type.
1223  * @param[in] discriminant Device discriminant.
1224  *
1225  * @return 0 on success, otherwise a negative error value
1226  * @retval #UAM_ERROR_NONE Successful
1227  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1228  * @retval #UAM_ERROR_INTERNAL Internal error
1229  *
1230  * @exception
1231  * @pre
1232  * @post
1233  */
1234 int _uam_service_set_device_discriminant(const char *service,
1235         const char *device_id, uam_tech_type_e tech_type, gboolean discriminant);
1236
1237 /**
1238  * @brief Gets a device discriminant for the service.
1239  * @since_tizen 5.5
1240  *
1241  * @param[in] service Service idt.
1242  * @param[in] device_id Device id.
1243  * @param[in] tech_type Sensor type.
1244  * @param[out] discriminant Device discriminant.
1245  *
1246  * @return 0 on success, otherwise a negative error value
1247  * @retval #UAM_ERROR_NONE Successful
1248  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1249  * @retval #UAM_ERROR_INTERNAL Internal error
1250  *
1251  * @exception
1252  * @pre
1253  * @post
1254  */
1255 int _uam_service_get_device_discriminant(const char *service,
1256         const char *device_id, uam_tech_type_e tech_type, gboolean *discriminant);
1257
1258 /**
1259  * @brief Sets detction cycle per eash service.
1260  * @since_tizen 5.5
1261  *
1262  * @param[in] service Service id
1263  * @param[in] cycle The cycle number of the service.
1264  *
1265  * @return 0 on success, otherwise a negative error value
1266  * @retval #UAM_ERROR_NONE Successful
1267  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1268  * @retval #UAM_ERROR_INTERNAL Internal error
1269  *
1270  * @exception
1271  * @pre
1272  * @post
1273  */
1274 int _uam_set_service_detection_cycle(const char *service, unsigned int cycle);
1275
1276 /**
1277  * @brief Gets detction cycle per eash service.
1278  * @since_tizen 5.5
1279  *
1280  * @param[in] service Service id
1281  * @param[out] cycle The cycle number of the service.
1282  *
1283  * @return 0 on success, otherwise a negative error value
1284  * @retval #UAM_ERROR_NONE Successful
1285  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1286  * @retval #UAM_ERROR_INTERNAL Internal error
1287  *
1288  * @exception
1289  * @pre
1290  * @post
1291  */
1292 int _uam_get_service_detection_cycle(const char *service, unsigned int *cycle);
1293
1294 /**
1295  * @brief Resets contents in database.
1296  * @since_tizen 5.5
1297  *
1298  * @return 0 on success, otherwise a negative error value
1299  * @retval #UAM_ERROR_NONE Successful
1300  * @retval #UAM_ERROR_INTERNAL Internal error
1301  *
1302  * @exception
1303  * @pre
1304  * @post
1305  */
1306 int _uam_db_reset(void);
1307
1308 /**
1309  * @brief Updates the device.
1310  * @since_tizen 5.5
1311  *
1312  * @param[in] device Device information.
1313  *
1314  * @return 0 on success, otherwise a negative error value
1315  * @retval #UAM_ERROR_NONE Successful
1316  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1317  * @retval #UAM_ERROR_INTERNAL Internal error
1318  *
1319  * @exception
1320  * @pre
1321  * @post
1322  */
1323 int _uam_request_update_device(uam_device_info_s *device);
1324
1325 /**
1326  * @brief Sets iBeacon ibeacon adevertising data.
1327  * @since_tizen 5.5
1328  *
1329  * @param[in] adv_len The iBeacon adevertising data's length.
1330  * @param[in] ibeacon_adv The iBeacon adevertising data.
1331  *
1332  * @return 0 on success, otherwise a negative error value
1333  * @retval #UAM_ERROR_NONE Successful
1334  * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameter
1335  *
1336  * @exception
1337  * @pre
1338  * @post
1339  */
1340 int _uam_add_ibeacon_adv_data(unsigned int adv_len, const char *ibeacon_adv);
1341
1342 #ifdef __cplusplus
1343 }
1344 #endif
1345 #endif /* __TIZEN_UA_NETWORK_UA_API_H__ */