9adfcb62912b8e1ec17dee9487ebcdb5699f4fa0
[apps/native/rcc.git] / inc / connectivity.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Contact: Jin Yoon <jinny.yoon@samsung.com>
5  *          Geunsun Lee <gs86.lee@samsung.com>
6  *          Eunyoung Lee <ey928.lee@samsung.com>
7  *          Junkyu Han <junkyu.han@samsung.com>
8  *
9  * Licensed under the Flora License, Version 1.1 (the License);
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://floralicense.org/license/
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an AS IS BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifndef __POSITION_FINDER_CONNECTIVITY_H__
23 #define __POSITION_FINDER_CONNECTIVITY_H__
24
25 typedef struct _connectivity_resource connectivity_resource_s;
26
27 typedef enum {
28         CONNECTIVITY_PROTOCOL_DEFAULT = 0,
29         CONNECTIVITY_PROTOCOL_IOTIVITY,
30         CONNECTIVITY_PROTOCOL_HTTP,
31         CONNECTIVITY_PROTOCOL_MAX
32    } connectivity_protocol_e;
33
34 /**
35  * @brief Create connectivity resource and registers the resource in server.
36  * @param[in] path The path of the resource
37  * @param[in] type The string data to insert into the resource types (e.g. "org.tizen.light")
38  * @param[out] out_resource_info A structure containing information about connectivity resource
39  * @return 0 on success, otherwise a negative error value
40  * @see uri_path length must be less than 128.
41  * @see You must destroy resource by calling connectivity_unset_resource() if resource is no longer needed.
42  */
43 extern int connectivity_set_resource(const char *path, const char *type, connectivity_resource_s **out_resource_info);
44
45 /**
46  * @brief Releases all resource about connectivity.
47  * @param[in] resource_info A structure containing information about connectivity resource
48  */
49 extern void connectivity_unset_resource(connectivity_resource_s *resource);
50
51 /**
52  * @brief Notifies a resource's value to observed clients.
53  * @param[in] resource_info A structure containing information about connectivity resource
54  * @param[in] key A key to be sended.
55  * @param[in] value A value to be sended.
56  * @return 0 on success, otherwise a negative error value
57  * @see If key is already exists, current value will be replaced with new value.
58  */
59 extern int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value);
60
61 /**
62  * @brief Notifies a resource's value to observed clients.
63  * @param[in] resource_info A structure containing information about connectivity resource
64  * @param[in] key A key to be sended.
65  * @param[in] value A value to be sended.
66  * @return 0 on success, otherwise a negative error value
67  * @see If key is already exists, current value will be replaced with new value.
68  */
69 extern int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value);
70
71 /**
72  * @brief Notifies a resource's value to observed clients.
73  * @param[in] resource_info A structure containing information about connectivity resource
74  * @param[in] key A key to be sended.
75  * @param[in] value A value to be sended.
76  * @return 0 on success, otherwise a negative error value
77  * @see If key is already exists, current value will be replaced with new value.
78  */
79 extern int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value);
80
81 /**
82  * @brief Notifies a resource's value to observed clients.
83  * @param[in] resource_info A structure containing information about connectivity resource
84  * @param[in] key A key to be sended.
85  * @param[in] value A value to be sended.
86  * @return 0 on success, otherwise a negative error value
87  * @see If key is already exists, current value will be replaced with new value.
88  */
89 extern int connectivity_notify_string(connectivity_resource_s *resource_info, const char *key, const char *value);
90
91 /* TODO : add comments for these functions */
92 extern int connectivity_set_protocol(connectivity_protocol_e protocol_type);
93 extern int connectivity_attributes_add_bool(connectivity_resource_s *resource_info, const char *key, bool value);
94 extern int connectivity_attributes_add_int(connectivity_resource_s *resource_info, const char *key, int value);
95 extern int connectivity_attributes_add_double(connectivity_resource_s *resource_info, const char *key, double value);
96 extern int connectivity_attributes_add_string(connectivity_resource_s *resource_info, const char *key, const char *value);
97 extern int connectivity_attributes_notify_all(connectivity_resource_s *resource_info);
98 extern int connectivity_attributes_remove_value_by_key(connectivity_resource_s *resource_info, const char *key);
99 extern int connectivity_attributes_remove_all(connectivity_resource_s *resource_info);
100
101 #endif /* __POSITION_FINDER_CONNECTIVITY_H__ */