Challenge : Create server requried in Question#3
[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 #include "connectivity_internal.h"
26
27 struct connectivity_resource {
28         iotcon_resource_h res;
29         iotcon_observers_h observers;
30         char *path;
31 };
32
33 typedef struct connectivity_resource connectivity_resource_s;
34
35 /**
36  * @brief Create connectivity resource and registers the resource in server.
37  * @param[in] path The path of the resource
38  * @param[in] type The string data to insert into the resource types (e.g. "org.tizen.light")
39  * @param[out] out_resource_info A structure containing information about connectivity resource
40  * @return 0 on success, otherwise a negative error value
41  * @see uri_path length must be less than 128.
42  * @see You must destroy resource by calling connectivity_unset_resource() if resource is no longer needed.
43  */
44 extern int connectivity_set_resource(const char *path, const char *type, connectivity_resource_s **out_resource_info);
45
46 /**
47  * @brief Releases all resource about connectivity.
48  * @param[in] resource_info A structure containing information about connectivity resource
49  */
50 extern void connectivity_unset_resource(connectivity_resource_s *resource);
51
52 /**
53  * @brief Notifies a resource's value to observed clients.
54  * @param[in] resource_info A structure containing information about connectivity resource
55  * @param[in] key A key to be sended.
56  * @param[in] value A value to be sended.
57  * @return 0 on success, otherwise a negative error value
58  * @see If key is already exists, current value will be replaced with new value.
59  */
60 extern int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value);
61
62 /**
63  * @brief Notifies a resource's value to observed clients.
64  * @param[in] resource_info A structure containing information about connectivity resource
65  * @param[in] key A key to be sended.
66  * @param[in] value A value to be sended.
67  * @return 0 on success, otherwise a negative error value
68  * @see If key is already exists, current value will be replaced with new value.
69  */
70 extern int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value);
71
72 /**
73  * @brief Notifies a resource's value to observed clients.
74  * @param[in] resource_info A structure containing information about connectivity resource
75  * @param[in] key A key to be sended.
76  * @param[in] value A value to be sended.
77  * @return 0 on success, otherwise a negative error value
78  * @see If key is already exists, current value will be replaced with new value.
79  */
80 extern int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value);
81
82 /**
83  * @brief Notifies a resource's value to observed clients.
84  * @param[in] resource_info A structure containing information about connectivity resource
85  * @param[in] key A key to be sended.
86  * @param[in] value A value to be sended.
87  * @return 0 on success, otherwise a negative error value
88  * @see If key is already exists, current value will be replaced with new value.
89  */
90 extern int connectivity_notify_string(connectivity_resource_s *resource_info, const char *key, char *value);
91
92 #endif /* __POSITION_FINDER_CONNECTIVITY_H__ */