Remove address information
[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 <glib.h>
22 #include <gio/gio.h>
23 #include <mdg.h>
24 #include <mdg_internal.h>
25 #include <mdg_gdbus.h>
26 #include <mdg_debug.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         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; \
44                 } \
45         } else { \
46                 _ERR("Error - Feature getting from System Info"); \
47                 return MDG_ERROR_NOT_SUPPORTED; \
48         } \
49 }
50 #else
51 #define CHECK_FEATURE_SUPPORTED(feature_name) { \
52                 _WARN("[Feature] Should be check !"); \
53         }
54 #endif
55
56
57 /**
58  * @brief New group found callback structure
59  * @since_tizen 5.0
60  */
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 */
64 } group_found_cb_t;
65
66 /**
67  * @brief New device found callback structure
68  * @since_tizen 5.0
69  */
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 */
73 } device_found_cb_t;
74
75 /**
76  * @brief Finding groups done callback structure
77  * @since_tizen 5.0
78  */
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;
83
84 /**
85  * @brief Fiding devices done callback structure
86  * @since_tizen 5.0
87  */
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;
92
93 /**
94  * @brief Inviting a device done callback structure
95  * @since_tizen 5.0
96  */
97 typedef struct _device_invite_finish_cb_t {
98         mdg_group_invite_device_finish_cb finish_cb; /**< User callback to be called */
99         mdg_device_h device;
100         void *user_data; /**< User data pointer */
101 } device_invite_finish_cb_t;
102
103 /**
104  * @brief Ejecting the device done callback structure
105  * @since_tizen 5.0
106  */
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;
111
112 /**
113  * @brief Sending data to the device done callback structure
114  * @since_tizen 5.0
115  */
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;
120
121 /**
122  * @brief Sending data to the device done callback structure
123  * @since_tizen 5.0
124  */
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 */
128         mdg_device_h device;
129         void *user_data; /**< User data pointer */
130 } send_file_cb_t;
131
132 typedef struct _receive_file_cb_t {
133         mdg_receive_file_cb receive_cb; /**< User callback to be called */
134         void *user_data; /**< User data pointer */
135 } receive_file_cb_t;
136
137 /**
138  * @brief Sending internal commands to the device done callback structure
139  * @since_tizen 5.0
140  */
141 typedef struct _request_result_cb_t {
142         mdg_request_result_cb result_cb; /**< User callback to be called */
143         void *user_data; /**< User data pointer */
144 } request_result_cb_t;
145
146 typedef struct _request_channel_list_finish_cb_t {
147         mdg_request_channel_list_finish_cb finish_cb; /**< User callback to be called */
148         void *user_data; /**< User data pointer */
149 } request_channel_list_finish_cb_t;
150
151 /**
152  * @brief The mdg-manager context
153  * @since_tizen 5.0
154  */
155 typedef struct _mdg_manager_s {
156         Group *group_proxy; /**< To receive signal from cmdgd */
157         Enabler *enabler_proxy; /**< Enbler proxy */
158         GDBusConnection *system_bus; /**< GDBus System Bus */
159         GSList *channel_cb_list;
160
161         group_found_cb_t group_found_cb; /**< When it called after finding a every single group */
162         group_find_finish_cb_t group_find_finish_cb; /**< When it called the group finging time is up */
163         device_found_cb_t device_found_cb; /**< When it called after finding a every single device */
164         device_find_finish_cb_t device_find_finish_cb; /**< When it called the device finging time is up */
165         device_invite_finish_cb_t device_invite_finish_cb; /**< When it called after invinting a device done or timeout */
166         device_eject_finish_cb_t device_eject_finish_cb; /**< When it called after ejecting the device done or timeout */
167         send_data_finish_cb_t send_data_finish_cb; /**< When it called after sending the device done or timeout */
168         send_file_cb_t send_file_cb; /**< When it called after sending the device done or timeout */
169         receive_file_cb_t receive_file_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 } mdg_manager_s;
173
174 #define CHECK_HANDLE_IS_VALID(handle) { \
175         if (g_slist_find(handle_list, handle) == NULL) \
176                 return MDG_ERROR_OPERATION_FAILED; \
177 }
178
179 /**
180  * @brief The group structure
181  * @since_tizen 5.0
182  */
183 typedef struct _mdg_group_s {
184         char *device_id; /**< Device ID of the device has this group resource */
185         char *group_name; /**< Group Name (Friendly name) */
186         mdg_group_type_e type; /**< Mine or Remote */
187 } mdg_group_s;
188
189 /**
190  * @brief The device structure
191  * @since_tizen 5.0
192  */
193 typedef struct _mdg_device_s {
194         char *device_id; /**< Device ID */
195         char *model_name;
196         char *device_name;
197         char *platform_ver;
198         char *vendor_id;
199         char *profile;
200         bool is_invited;
201         mdg_device_type_e type; /**< Device Type */
202 } mdg_device_s;
203
204 typedef struct _channel_cb_s {
205         char *channel_id;
206         mdg_channel_cb cb;
207         void *user_data;
208 } channel_cb_s;
209
210 typedef enum {
211         MDG_EVENT_GROUP_FOUND = 0,
212         MDG_EVENT_GROUP_FIND_FINISH,
213         MDG_EVENT_DEVICE_FOUND,
214         MDG_EVENT_DEVICE_FIND_FINISH,
215         MDG_EVENT_INVITE_DEVICE_FINISH,
216         MDG_EVENT_EJECT_DEVICE_FINISH,
217         MDG_EVENT_REQUEST_FINISH,
218         MDG_EVENT_SEND_DATA_FINISH,
219         MDG_EVENT_REQ_CHANNEL_LIST_FINISH,
220         MDG_EVENT_RECEIVE_DATA,
221         MDG_EVENT_RECEIVE_FILE = 10,
222         MDG_EVENT_SEND_FILE_PROGRESS,
223         MDG_EVENT_SEND_FILE_FINISH,
224 } mdg_event_type_e;
225
226 #endif /* __TIZEN_NETWORK_COMMON_MDG_PRIVATE_H__ */