Fix build error for toolchain upgrade
[platform/core/api/multi-device-group.git] / src / mdg_private.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_NETWORK_COMMON_MDG_PRIVATE_H__
19 #define __TIZEN_NETWORK_COMMON_MDG_PRIVATE_H__
20
21 #include <gio/gio.h>
22 #include <glib.h>
23 #include <mdg.h>
24 #include <mdg_debug.h>
25 #include <mdg_gdbus.h>
26 #include <mdg_internal.h>
27 #include <system_info.h>
28
29 #define MDG_FEATURE "http://tizen.org/feature/network.mdg"
30
31 #define CHECK_INPUT_PARAMETER(arg)                  \
32         if (arg == NULL) {                          \
33                 mdg_supported("INVALID_PARAMETER"); \
34                 return MDG_ERROR_INVALID_PARAMETER; \
35         }
36
37 #if 0
38 #define CHECK_FEATURE_SUPPORTED(feature_name)                                            \
39         {                                                                                \
40                 bool mdg_supported = FALSE;                                              \
41                 if (!system_info_get_platform_bool(feature_name, &mdg_supported)) {      \
42                         if (mdg_supported == FALSE) {                                    \
43                                 _WARN("Multi Device Group Manager feature is disabled"); \
44                                 return MDG_ERROR_NOT_SUPPORTED;                          \
45                         }                                                                \
46                 } else {                                                                 \
47                         _ERR("Error - Feature getting from System Info");                \
48                         return MDG_ERROR_NOT_SUPPORTED;                                  \
49                 }                                                                        \
50         }
51 #else
52 #define CHECK_FEATURE_SUPPORTED(feature_name)         \
53         {                                             \
54                 _WARN("[Feature] Should be check !"); \
55         }
56 #endif
57
58 /**
59  * @brief New group found callback structure
60  * @since_tizen 5.0
61  */
62 typedef struct _group_found_cb_t {
63         mdg_group_found_cb found_cb; /**< User callback to be called */
64         void *user_data;             /**< User data pointer */
65 } group_found_cb_t;
66
67 /**
68  * @brief New device found callback structure
69  * @since_tizen 5.0
70  */
71 typedef struct _device_found_cb_t {
72         mdg_device_found_cb found_cb; /**< User callback to be called */
73         void *user_data;              /**< User data pointer */
74 } device_found_cb_t;
75
76 /**
77  * @brief Finding groups done callback structure
78  * @since_tizen 5.0
79  */
80 typedef struct _group_find_finish_cb_t {
81         mdg_group_find_finish_cb finish_cb; /**< User callback to be called */
82         void *user_data;                    /**< User data pointer */
83 } group_find_finish_cb_t;
84
85 /**
86  * @brief Fiding devices done callback structure
87  * @since_tizen 5.0
88  */
89 typedef struct _device_find_finish_cb_t {
90         mdg_device_find_finish_cb finish_cb;
91         void *user_data; /**< User data pointer */
92 } device_find_finish_cb_t;
93
94 /**
95  * @brief Inviting a device done callback structure
96  * @since_tizen 5.0
97  */
98 typedef struct _device_invite_finish_cb_t {
99         mdg_group_invite_device_finish_cb finish_cb; /**< User callback to be called */
100         mdg_device_h device;
101         void *user_data; /**< User data pointer */
102 } device_invite_finish_cb_t;
103
104 /**
105  * @brief Ejecting the device done callback structure
106  * @since_tizen 5.0
107  */
108 typedef struct _device_eject_finish_cb_t {
109         mdg_group_eject_device_finish_cb finish_cb; /**< User callback to be called */
110         void *user_data;                            /**< User data pointer */
111 } device_eject_finish_cb_t;
112
113 /**
114  * @brief Sending data to the device done callback structure
115  * @since_tizen 5.0
116  */
117 typedef struct _send_data_finish_cb_t {
118         mdg_device_send_data_finish_cb finish_cb; /**< User callback to be called */
119         mdg_device_h device;
120         void *user_data; /**< User data pointer */
121 } send_data_finish_cb_t;
122
123 /**
124  * @brief Sending internal commands to the device done callback structure
125  * @since_tizen 5.0
126  */
127 typedef struct _request_result_cb_t {
128         mdg_request_result_cb result_cb; /**< User callback to be called */
129         void *user_data;                 /**< User data pointer */
130 } request_result_cb_t;
131
132 typedef struct _request_channel_list_finish_cb_t {
133         mdg_request_channel_list_finish_cb finish_cb; /**< User callback to be called */
134         void *user_data;                              /**< User data pointer */
135 } request_channel_list_finish_cb_t;
136
137 typedef struct _request_channel_open_finish_cb_t {
138         mdg_channel_opened_cb channel_opened_cb; /**< User callback to be called */
139         mdg_device_h device;
140         void *user_data;                       /**< User data pointer */
141 } request_channel_open_finish_cb_t;
142
143 typedef struct _invited_event_cb_t {
144         mdg_invited_event_cb invited_event_cb; /**< User callback to be called */
145         void *user_data;                       /**< User data pointer */
146 } invited_event_cb_t;
147
148 typedef struct _ejected_event_cb_t {
149         mdg_ejected_event_cb ejected_event_cb; /**< User callback to be called */
150         void *user_data;                       /**< User data pointer */
151 } ejected_event_cb_t;
152
153 /**
154  * @brief The mdg-manager context
155  * @since_tizen 5.0
156  */
157 typedef struct _mdg_manager_s {
158         Group *group_proxy;       /**< To receive signal from cmdgd */
159         Enabler *enabler_proxy;      /**< Enbler proxy */
160         GDBusConnection *system_bus; /**< GDBus System Bus */
161         GSList *channel_cb_list;
162
163         group_found_cb_t group_found_cb;                                 /**< When it called after finding a every single group */
164         group_find_finish_cb_t group_find_finish_cb;                     /**< When it called the group finging time is up */
165         device_found_cb_t device_found_cb;                               /**< When it called after finding a every single device */
166         device_find_finish_cb_t device_find_finish_cb;                   /**< When it called the device finging time is up */
167         device_invite_finish_cb_t device_invite_finish_cb;               /**< When it called after invinting a device done or timeout */
168         device_eject_finish_cb_t device_eject_finish_cb;                 /**< When it called after ejecting the device done or timeout */
169         send_data_finish_cb_t send_data_finish_cb;                       /**< When it called after sending the device done or timeout */
170         request_result_cb_t request_result_cb;                           /**< When it called after sending private commands or timeout */
171         request_channel_list_finish_cb_t request_channel_list_finish_cb; /**< When it called after sending private commands or timeout */
172         request_channel_open_finish_cb_t request_channel_open_finish_cb;
173         invited_event_cb_t invited_event_cb;
174         ejected_event_cb_t ejected_event_cb;
175 } mdg_manager_s;
176
177 #define CHECK_HANDLE_IS_VALID(handle)                          \
178         {                                                      \
179                 if (g_slist_find(handle_list, handle) == NULL) \
180                         return MDG_ERROR_NO_DATA;              \
181         }
182
183 /**
184  * @brief The group structure
185  * @since_tizen 5.0
186  */
187 typedef struct _mdg_group_s {
188         char *device_id;       /**< Device ID of the device has this group resource */
189         char *group_name;      /**< Group Name (Friendly name) */
190         mdg_group_type_e type; /**< Mine or Remote */
191 } mdg_group_s;
192
193 /**
194  * @brief The device structure
195  * @since_tizen 5.0
196  */
197 typedef struct _mdg_device_s {
198         char *device_id; /**< Device ID */
199         char *model_name;
200         char *device_name;
201         char *platform_ver;
202         char *vendor_id;
203         char *profile;
204         bool is_invited;
205         mdg_device_type_e type; /**< Device Type */
206 } mdg_device_s;
207
208 typedef struct _mdg_channel_s {
209         char *device_id; /**< Device ID */
210         char *channel_id;
211         char *remote_address;
212         int server_sockfd;
213         int client_sockfd;
214         int remote_port;
215         mdg_channel_type_e type;
216 } mdg_channel_s;
217
218 typedef struct _mdg_channel_cb_s {
219         char *channel_id;
220         mdg_channel_receive_data_cb receive_data_cb;
221         void *receive_data_cb_user_data;
222         mdg_channel_opened_cb opened_cb;
223         void *opened_cb_user_data;
224 } mdg_channel_cb_s;
225
226 typedef enum {
227         MDG_EVENT_GROUP_FOUND = 100,
228         MDG_EVENT_GROUP_FIND_FINISH,
229         MDG_EVENT_DEVICE_FOUND,
230         MDG_EVENT_DEVICE_FIND_FINISH,
231         MDG_EVENT_INVITE_DEVICE_FINISH,
232         MDG_EVENT_EJECT_DEVICE_FINISH,
233         MDG_EVENT_REQUEST_FINISH,
234         MDG_EVENT_SEND_DATA_FINISH,
235         MDG_EVENT_REQ_CHANNEL_LIST_FINISH,
236         MDG_EVENT_REQ_CHANNEL_OPEN_FINISH,
237         MDG_EVENT_RECEIVE_DATA = 110,
238         MDG_EVENT_RECEIVE_OPEN_CHANNEL
239 } mdg_private_event_type_e;
240
241 #endif /* __TIZEN_NETWORK_COMMON_MDG_PRIVATE_H__ */