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_gdbus.h>
25 #include <mdg_debug.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) { \
39 bool mdg_supported = FALSE; \
40 if (!system_info_get_platform_bool(feature_name, &mdg_supported)) { \
41 if (mdg_supported == FALSE) { \
42 _WARN("Multi Device Group Manager feature is disabled"); \
43 return MDG_ERROR_NOT_SUPPORTED; \
46 _ERR("Error - Feature getting from System Info"); \
47 return MDG_ERROR_NOT_SUPPORTED; \
51 #define CHECK_FEATURE_SUPPORTED(feature_name) { \
52 _WARN("[Feature] Should be check !"); \
58 * @brief New group found callback structure
61 typedef struct _group_found_cb_t {
62 mdg_group_found_cb found_cb; /**< User callback to be called */
63 void *user_data; /**< User data pointer */
67 * @brief New device found callback structure
70 typedef struct _device_found_cb_t {
71 mdg_device_found_cb found_cb; /**< User callback to be called */
72 void *user_data; /**< User data pointer */
76 * @brief Finding groups done callback structure
79 typedef struct _group_find_finish_cb_t {
80 mdg_group_find_finish_cb finish_cb; /**< User callback to be called */
81 void *user_data; /**< User data pointer */
82 } group_find_finish_cb_t;
85 * @brief Fiding devices done callback structure
88 typedef struct _device_find_finish_cb_t {
89 mdg_device_find_finish_cb finish_cb;
90 void *user_data; /**< User data pointer */
91 } device_find_finish_cb_t;
94 * @brief Inviting a device done callback structure
97 typedef struct _device_invite_finish_cb_t {
98 mdg_group_invite_device_finish_cb finish_cb; /**< User callback to be called */
100 void *user_data; /**< User data pointer */
101 } device_invite_finish_cb_t;
104 * @brief Ejecting the device done callback structure
107 typedef struct _device_eject_finish_cb_t {
108 mdg_group_eject_device_finish_cb finish_cb; /**< User callback to be called */
109 void *user_data; /**< User data pointer */
110 } device_eject_finish_cb_t;
113 * @brief Sending data to the device done callback structure
116 typedef struct _send_data_finish_cb_t {
117 mdg_device_send_data_finish_cb finish_cb; /**< User callback to be called */
118 void *user_data; /**< User data pointer */
119 } send_data_finish_cb_t;
122 * @brief Sending data to the device done callback structure
125 typedef struct _send_file_cb_t {
126 mdg_send_file_progress_cb progress_cb; /**< User callback to be called */
127 mdg_send_file_finish_cb finish_cb; /**< User callback to be called */
129 void *user_data; /**< User data pointer */
133 * @brief Sending internal commands to the device done callback structure
136 typedef struct _request_result_cb_t {
137 mdg_request_result_cb result_cb; /**< User callback to be called */
138 void *user_data; /**< User data pointer */
139 } request_result_cb_t;
141 typedef struct _request_channel_list_finish_cb_t {
142 mdg_request_channel_list_finish_cb finish_cb; /**< User callback to be called */
143 void *user_data; /**< User data pointer */
144 } request_channel_list_finish_cb_t;
147 * @brief The mdg-manager context
150 typedef struct _mdg_manager_s {
151 Group *group_proxy; /**< To receive signal from cmdgd */
152 Enabler *enabler_proxy; /**< Enbler proxy */
153 GDBusConnection *system_bus; /**< GDBus System Bus */
154 GSList *channel_cb_list;
156 group_found_cb_t group_found_cb; /**< When it called after finding a every single group */
157 group_find_finish_cb_t group_find_finish_cb; /**< When it called the group finging time is up */
158 device_found_cb_t device_found_cb; /**< When it called after finding a every single device */
159 device_find_finish_cb_t device_find_finish_cb; /**< When it called the device finging time is up */
160 device_invite_finish_cb_t device_invite_finish_cb; /**< When it called after invinting a device done or timeout */
161 device_eject_finish_cb_t device_eject_finish_cb; /**< When it called after ejecting the device done or timeout */
162 send_data_finish_cb_t send_data_finish_cb; /**< When it called after sending the device done or timeout */
163 send_file_cb_t send_file_cb; /**< When it called after sending the device done or timeout */
164 request_result_cb_t request_result_cb; /**< When it called after sending private commands or timeout */
165 request_channel_list_finish_cb_t request_channel_list_finish_cb; /**< When it called after sending private commands or timeout */
168 #define CHECK_HANDLE_IS_VALID(handle) { \
169 if (g_slist_find(handle_list, handle) == NULL) \
170 return MDG_ERROR_OPERATION_FAILED; \
174 * @brief The group structure
177 typedef struct _mdg_group_s {
178 char *device_id; /**< Device ID of the device has this group resource */
179 char *host_addr; /**< Host address */
180 char *group_name; /**< Group Name (Friendly name) */
181 mdg_group_type_e type; /**< Mine or Remote */
185 * @brief The device structure
188 typedef struct _mdg_device_s {
189 char *device_id; /**< Device ID */
190 char *addr; /**< Device IP */
191 int port; /**< Port Number */
192 int secure_port; /**< Secure Port Number */
193 unsigned int conn_type; /**< Connection type */
200 mdg_device_type_e type; /**< Device Type */
203 typedef struct _channel_cb_s {
210 MDG_EVENT_GROUP_FOUND = 0,
211 MDG_EVENT_GROUP_FIND_FINISH,
212 MDG_EVENT_DEVICE_FOUND,
213 MDG_EVENT_DEVICE_FIND_FINISH,
214 MDG_EVENT_INVITE_DEVICE_FINISH,
215 MDG_EVENT_EJECT_DEVICE_FINISH,
216 MDG_EVENT_REQUEST_FINISH,
217 MDG_EVENT_SEND_DATA_FINISH,
218 MDG_EVENT_REQ_CHANNEL_LIST_FINISH,
219 MDG_EVENT_RECEIVE_DATA,
220 MDG_EVENT_RECEIVE_FILE = 10,
221 MDG_EVENT_SEND_FILE_PROGRESS,
222 MDG_EVENT_SEND_FILE_FINISH,
225 #endif /* __TIZEN_NETWORK_COMMON_MDG_PRIVATE_H__ */