2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __TIZEN_NETWORK_COMMON_MDG_PRIVATE_H__
19 #define __TIZEN_NETWORK_COMMON_MDG_PRIVATE_H__
24 #include <mdg_debug.h>
25 #include <mdg_gdbus.h>
26 #include <mdg_internal.h>
27 #include <system_info.h>
29 #define MDG_FEATURE "http://tizen.org/feature/network.mdg"
31 #define CHECK_INPUT_PARAMETER(arg) \
33 mdg_supported("INVALID_PARAMETER"); \
34 return MDG_ERROR_INVALID_PARAMETER; \
38 #define CHECK_FEATURE_SUPPORTED(feature_name) \
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; \
47 _ERR("Error - Feature getting from System Info"); \
48 return MDG_ERROR_NOT_SUPPORTED; \
52 #define CHECK_FEATURE_SUPPORTED(feature_name) \
54 _WARN("[Feature] Should be check !"); \
59 * @brief New group found callback structure
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 */
68 * @brief New device found callback structure
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 */
77 * @brief Finding groups done callback structure
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;
86 * @brief Fiding devices done callback structure
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;
95 * @brief Inviting a device done callback structure
98 typedef struct _device_invite_finish_cb_t {
99 mdg_group_invite_device_finish_cb finish_cb; /**< User callback to be called */
101 void *user_data; /**< User data pointer */
102 } device_invite_finish_cb_t;
105 * @brief Ejecting the device done callback structure
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;
114 * @brief Sending data to the device done callback structure
117 typedef struct _send_data_finish_cb_t {
118 mdg_device_send_data_finish_cb finish_cb; /**< User callback to be called */
120 void *user_data; /**< User data pointer */
121 } send_data_finish_cb_t;
124 * @brief Sending internal commands to the device done callback structure
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;
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;
137 typedef struct _request_channel_open_finish_cb_t {
138 mdg_channel_opened_cb channel_opened_cb; /**< User callback to be called */
140 void *user_data; /**< User data pointer */
141 } request_channel_open_finish_cb_t;
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;
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;
154 * @brief The mdg-manager context
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;
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;
177 #define CHECK_HANDLE_IS_VALID(handle) \
179 if (g_slist_find(handle_list, handle) == NULL) \
180 return MDG_ERROR_NO_DATA; \
184 * @brief The group structure
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 */
194 * @brief The device structure
197 typedef struct _mdg_device_s {
198 char *device_id; /**< Device ID */
205 mdg_device_type_e type; /**< Device Type */
208 typedef struct _mdg_channel_s {
209 char *device_id; /**< Device ID */
211 char *remote_address;
215 mdg_channel_type_e type;
218 typedef struct _mdg_channel_cb_s {
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;
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;
241 #endif /* __TIZEN_NETWORK_COMMON_MDG_PRIVATE_H__ */