Add Camera Module
[apps/native/position-finder-server.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, /* default protocol */
29         CONNECTIVITY_PROTOCOL_IOTIVITY, /* IoTvity protocol */
30         CONNECTIVITY_PROTOCOL_HTTP, /* HTTP protocol */
31         CONNECTIVITY_PROTOCOL_MAX
32 } connectivity_protocol_e;
33
34 /**
35  * @brief Set connectivity protocol to communicate with other devices.
36  * @param[in] protocol_type protocol type to use
37  * @return 0 on success, otherwise a negative error value
38  * @see You should set protocol before call connectivity_set_resource(),
39  * otherwise IoTvitiy protocol will be set as default.
40  */
41 extern int connectivity_set_protocol(connectivity_protocol_e protocol_type);
42
43 /**
44  * @brief Create connectivity resource.
45  * @param[in] path The path of the resource
46  * @param[in] type The string data to insert into the resource types (e.g. "org.tizen.light")
47  * @param[out] out_resource_info A structure containing information about connectivity resource
48  * @return 0 on success, otherwise a negative error value
49  * @see uri_path length must be less than 128.
50  * @see You must destroy resource by calling connectivity_unset_resource() if resource is no longer needed.
51  */
52 extern int connectivity_set_resource(const char *path, const char *type, connectivity_resource_s **out_resource_info);
53
54 /**
55  * @brief Releases all resource about connectivity.
56  * @param[in] resource_info A structure containing information about connectivity resource
57  */
58 extern void connectivity_unset_resource(connectivity_resource_s *resource);
59
60 /**
61  * @brief Notifies a resource's value to observed devices or clouds.
62  * @param[in] resource_info A structure containing information about connectivity resource
63  * @param[in] key A key to be sended.
64  * @param[in] value A value to be sended.
65  * @return 0 on success, otherwise a negative error value
66  * @see If key is already exists, current value will be replaced with new value.
67  */
68 extern int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value);
69
70 /**
71  * @brief Notifies a resource's value to observed devices or clouds.
72  * @param[in] resource_info A structure containing information about connectivity resource
73  * @param[in] key A key to be sended.
74  * @param[in] value A value to be sended.
75  * @return 0 on success, otherwise a negative error value
76  * @see If key is already exists, current value will be replaced with new value.
77  */
78 extern int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value);
79
80 /**
81  * @brief Notifies a resource's value to observed devices or clouds.
82  * @param[in] resource_info A structure containing information about connectivity resource
83  * @param[in] key A key to be sended.
84  * @param[in] value A value to be sended.
85  * @return 0 on success, otherwise a negative error value
86  * @see If key is already exists, current value will be replaced with new value.
87  */
88 extern int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value);
89
90 /**
91  * @brief Notifies a resource's value to observed devices or clouds.
92  * @param[in] resource_info A structure containing information about connectivity resource
93  * @param[in] key A key to be sended.
94  * @param[in] value A value to be sended.
95  * @return 0 on success, otherwise a negative error value
96  * @see If key is already exists, current value will be replaced with new value.
97  */
98 extern int connectivity_notify_string(connectivity_resource_s *resource_info, const char *key, const char *value);
99
100 /* TODO : add comments for these functions */
101 /**
102  * @brief Add a boolean type value to attributes for notifying to observed devices or clouds.
103  * @param[in] resource_info A structure containing information about connectivity resource
104  * @param[in] key A key to be sended.
105  * @param[in] value A value to be added.
106  * @return 0 on success, otherwise a negative error value
107  * @see If key is already exists, current value will be replaced with new value.
108  */
109 extern int connectivity_attributes_add_bool(connectivity_resource_s *resource_info, const char *key, bool value);
110
111 /**
112  * @brief Add a integer type value to attributes for notifying to observed devices or clouds.
113  * @param[in] resource_info A structure containing information about connectivity resource
114  * @param[in] key A key to be sended.
115  * @param[in] value A value to be added.
116  * @return 0 on success, otherwise a negative error value
117  * @see If key is already exists, current value will be replaced with new value.
118  */
119 extern int connectivity_attributes_add_int(connectivity_resource_s *resource_info, const char *key, int value);
120
121 /**
122  * @brief Add a double type value to attributes for notifying to observed devices or clouds.
123  * @param[in] resource_info A structure containing information about connectivity resource
124  * @param[in] key A key to be sended.
125  * @param[in] value A value to be added.
126  * @return 0 on success, otherwise a negative error value
127  * @see If key is already exists, current value will be replaced with new value.
128  */
129 extern int connectivity_attributes_add_double(connectivity_resource_s *resource_info, const char *key, double value);
130
131 /**
132  * @brief Add a string value to attributes for notifying to observed devices or clouds.
133  * @param[in] resource_info A structure containing information about connectivity resource
134  * @param[in] key A key to be sended.
135  * @param[in] value A value to be added.
136  * @return 0 on success, otherwise a negative error value
137  * @see If key is already exists, current value will be replaced with new value.
138  */
139 extern int connectivity_attributes_add_string(connectivity_resource_s *resource_info, const char *key, const char *value);
140
141 /**
142  * @brief Notifies values in the attributs to observed devices or clouds.
143  * @param[in] resource_info A structure containing information about connectivity resource
144  * @return 0 on success, otherwise a negative error value
145  */
146 extern int connectivity_attributes_notify_all(connectivity_resource_s *resource_info);
147
148 /**
149  * @brief Remove a value from attributes for notifying to observed devices or clouds.
150  * @param[in] resource_info A structure containing information about connectivity resource
151  * @param[in] key A key to be sended.
152  * @return 0 on success, otherwise a negative error value
153  * @see If key is already exists, current value will be replaced with new value.
154  */
155 extern int connectivity_attributes_remove_value_by_key(connectivity_resource_s *resource_info, const char *key);
156
157 /**
158  * @brief Remove all values from attributes for notifying to observed devices or clouds.
159  * @param[in] resource_info A structure containing information about connectivity resource
160  * @return 0 on success, otherwise a negative error value
161  */
162 extern int connectivity_attributes_remove_all(connectivity_resource_s *resource_info);
163
164 #endif /* __POSITION_FINDER_CONNECTIVITY_H__ */