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.
26 #include <mdg_debug.h>
27 #include <mdg_gdbus.h>
28 #include <mdg_private.h>
30 GSList *handle_list = NULL;
32 EXPORT_API int mdg_initialize(mdg_h *handle)
34 int ret = MDG_ERROR_NONE;
35 struct mdg_manager_s *mdg_manager = NULL;
37 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
39 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
43 mdg_manager = calloc(1, sizeof(mdg_manager_s));
44 if (NULL == mdg_manager) {
46 _ERR("Failed to create handle");
47 return MDG_ERROR_OUT_OF_MEMORY;
50 *handle = mdg_manager;
52 ret = gdbus_initialize(*handle);
54 handle_list = g_slist_prepend(handle_list, *handle);
61 EXPORT_API int mdg_deinitialize(mdg_h handle)
63 int ret = MDG_ERROR_NONE;
65 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
66 CHECK_HANDLE_IS_VALID(handle);
70 handle_list = g_slist_remove(handle_list, handle);
72 ret = gdbus_deinitialize(handle);
79 EXPORT_API int mdg_group_create(mdg_h handle, char *group_name)
81 int ret = MDG_ERROR_NONE;
84 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
86 mdg_manager_s *_handle = handle;
87 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
88 CHECK_HANDLE_IS_VALID(handle);
90 /* create group to daemon using gdbus */
91 group_call_create_sync(_handle->group_proxy, group_name, &ret, NULL, &error);
96 EXPORT_API void mdg_group_destroy(mdg_group_s *group)
98 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
100 mdg_check_null_ret("group", group);
102 if (group->device_id) {
103 g_free(group->device_id);
104 group->device_id = NULL;
106 if (group->group_name) {
107 g_free(group->group_name);
108 group->group_name = NULL;
115 EXPORT_API int mdg_group_find(mdg_h handle, int timeout,
116 mdg_group_found_cb found_cb, mdg_group_find_finish_cb finish_cb,
119 int ret = MDG_ERROR_NONE;
120 GError *error = NULL;
122 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
124 mdg_manager_s *_handle = handle;
125 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
126 CHECK_HANDLE_IS_VALID(handle);
128 _handle->group_found_cb.found_cb = found_cb;
129 _handle->group_find_finish_cb.finish_cb = finish_cb;
130 _handle->group_found_cb.user_data = user_data;
131 _handle->group_find_finish_cb.user_data = user_data;
133 /* get groups from daemon using gdbus */
134 group_call_find_sync(_handle->group_proxy, timeout, &ret, NULL, &error);
136 _ERR("Failed DBus call [%s]", error->message);
138 ret = MDG_ERROR_IO_ERROR;
144 EXPORT_API int mdg_device_find(mdg_h handle, int timeout, bool is_invited,
145 mdg_device_found_cb found_cb, mdg_device_find_finish_cb finish_cb,
148 int ret = MDG_ERROR_NONE;
149 GError *error = NULL;
151 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
153 mdg_manager_s *_handle = handle;
154 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
155 CHECK_HANDLE_IS_VALID(handle);
157 _handle->device_found_cb.found_cb = found_cb;
158 _handle->device_found_cb.user_data = user_data;
159 _handle->device_find_finish_cb.finish_cb = finish_cb;
160 _handle->device_find_finish_cb.user_data = user_data;
162 /* get groups from daemon using gdbus */
163 group_call_find_device_sync(_handle->group_proxy, timeout, is_invited, &ret, NULL, &error);
165 _ERR("Failed DBus call [%s]", error->message);
167 ret = MDG_ERROR_IO_ERROR;
174 * Companion Manager CAPI
176 int __add_channel_cb(mdg_manager_s *handle, char *channel_id, mdg_channel_cb channel_cb, void *user_data)
178 channel_cb_s *channel_s;
181 for (l1 = handle_list; l1 != NULL; l1 = l1->next) {
182 mdg_manager_s *tmp_handle = (mdg_manager_s *)l1->data;
183 for (l2 = tmp_handle->channel_cb_list; l2 != NULL; l2 = l2->next) {
184 channel_cb_s *tmp_channel = (channel_cb_s *)l2->data;
185 if (g_strcmp0(tmp_channel->channel_id, channel_id) == 0)
186 return MDG_ERROR_OPERATION_FAILED;
190 channel_s = g_try_new0(channel_cb_s, 1);
191 if (channel_s == NULL)
192 return MDG_ERROR_OUT_OF_MEMORY;
194 channel_s->channel_id = g_strdup(channel_id);
195 channel_s->cb = channel_cb;
196 channel_s->user_data = user_data;
198 handle->channel_cb_list = g_slist_prepend(handle->channel_cb_list, channel_s);
203 EXPORT_API int mdg_device_regist_channel(mdg_h handle, char *channel_id,
204 mdg_channel_cb channel_cb, void *user_data)
206 int ret = MDG_ERROR_NONE;
207 GError *error = NULL;
209 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
211 mdg_manager_s *_handle = handle;
212 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
213 CHECK_HANDLE_IS_VALID(_handle);
217 group_call_regist_channel_sync(_handle->group_proxy, channel_id, &ret, NULL, &error);
219 _ERR("Failed DBus call [%s]", error->message);
221 ret = MDG_ERROR_IO_ERROR;
224 if (ret == MDG_ERROR_NONE)
225 ret = __add_channel_cb(handle, channel_id, channel_cb, user_data);
232 EXPORT_API int mdg_device_unregist_channel(mdg_h handle, char *channel_id)
234 int ret = MDG_ERROR_NONE;
235 bool is_exist = false;
236 GError *error = NULL;
238 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
240 mdg_manager_s *_handle = handle;
241 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
242 CHECK_HANDLE_IS_VALID(handle);
247 for (l = _handle->channel_cb_list; l != NULL; l = l->next) {
248 channel_cb_s *tmp_channel = (channel_cb_s *)l->data;
249 if (g_strcmp0(tmp_channel->channel_id, channel_id) == 0) {
250 g_free(tmp_channel->channel_id);
251 _handle->channel_cb_list = g_slist_remove_link(_handle->channel_cb_list, l);
257 if (is_exist == false)
258 ret = MDG_ERROR_OPERATION_FAILED;
260 if (ret == MDG_ERROR_NONE) {
261 group_call_unregist_channel_sync(_handle->group_proxy, channel_id, &ret, NULL, &error);
263 _ERR("Failed DBus call [%s]", error->message);
265 ret = MDG_ERROR_IO_ERROR;
274 EXPORT_API int mdg_device_send_data(mdg_h handle,
275 mdg_device_h device, char *channel_id, unsigned char *data, int len,
276 mdg_device_send_data_finish_cb finish_cb, void *user_data)
278 int ret = MDG_ERROR_NONE;
279 unsigned char *buf = NULL;
280 GVariantBuilder *bytearray_builder = NULL;
282 GVariant *params = NULL;
283 GError *error = NULL;
285 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
287 mdg_manager_s *_handle = handle;
288 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
289 CHECK_HANDLE_IS_VALID(handle);
291 mdg_device_s *dev = (mdg_device_s *)device;
292 mdg_check_null_ret_error("dev", dev, MDG_ERROR_INVALID_PARAMETER);
294 buf = g_try_malloc0(len + 1);
296 /* LCOV_EXCL_START */
297 _ERR("g_malloc0 is failed");
298 return MDG_ERROR_OUT_OF_MEMORY;
301 memcpy(buf, data, len);
303 bytearray_builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
304 for (i = 0; i < len; i++)
305 g_variant_builder_add(bytearray_builder, "y", buf[i]);
307 params = g_variant_new("(iay)", len, bytearray_builder);
308 g_variant_builder_unref(bytearray_builder);
310 _handle->send_data_finish_cb.finish_cb = finish_cb;
311 _handle->send_data_finish_cb.user_data = user_data;
313 group_call_send_data_sync(_handle->group_proxy, dev->device_id, dev->addr,
314 dev->secure_port, channel_id, params, &ret, NULL, &error);
316 _ERR("Failed DBus call [%s]", error->message);
318 ret = MDG_ERROR_IO_ERROR;
327 EXPORT_API int mdg_device_send_file(mdg_h handle, mdg_device_h device,
328 char *file_path, mdg_send_file_progress_cb progress_cb, mdg_send_file_finish_cb finish_cb, void *user_data)
330 int ret = MDG_ERROR_NONE;
331 GError *error = NULL;
333 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
335 mdg_manager_s *_handle = handle;
336 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
337 CHECK_HANDLE_IS_VALID(handle);
339 mdg_device_s *dev = (mdg_device_s *)device;
340 mdg_check_null_ret_error("dev", dev, MDG_ERROR_INVALID_PARAMETER);
341 mdg_check_null_ret_error("file_path", file_path, MDG_ERROR_INVALID_PARAMETER);
343 mdg_device_h cloned_device = NULL;
344 mdg_device_info_clone(&cloned_device, device);
346 _handle->send_file_cb.finish_cb = finish_cb;
347 _handle->send_file_cb.progress_cb = progress_cb;
348 _handle->send_file_cb.device = cloned_device;
349 _handle->send_file_cb.user_data = user_data;
351 group_call_send_file_sync(_handle->group_proxy, dev->device_id, dev->addr,
352 dev->secure_port, file_path, &ret, NULL, &error);
354 _ERR("Failed DBus call [%s]", error->message);
356 ret = MDG_ERROR_IO_ERROR;
362 EXPORT_API int mdg_device_get_local_device(mdg_h handle,
363 mdg_device_h *device)
365 int ret = MDG_ERROR_NONE;
366 GError *error = NULL;
369 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
371 mdg_manager_s *_handle = handle;
372 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
373 CHECK_HANDLE_IS_VALID(handle);
375 group_call_get_local_device_sync(_handle->group_proxy, &va, NULL, &error);
377 _ERR("Failed DBus call [%s]", error->message);
379 ret = MDG_ERROR_IO_ERROR;
382 *device = mdg_get_device_from_variant(va);
387 EXPORT_API int mdg_group_delete(mdg_h handle, mdg_group_h group)
389 int ret = MDG_ERROR_NONE;
390 GError *error = NULL;
392 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
394 mdg_manager_s *_handle = handle;
395 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
396 CHECK_HANDLE_IS_VALID(handle);
398 mdg_group_s *grp = (mdg_group_s *)group;
399 mdg_check_null_ret_error("grp", grp, MDG_ERROR_INVALID_PARAMETER);
401 /* create group to daemon using gdbus */
402 group_call_delete_sync(_handle->group_proxy, grp->group_name, &ret, NULL, &error);
407 EXPORT_API int mdg_group_foreach_device(mdg_h handle, mdg_group_h group,
408 mdg_group_foreach_cb foreach_cb, void *user_data)
410 int ret = MDG_ERROR_NONE;
411 GError *error = NULL;
415 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
417 mdg_manager_s *_handle = handle;
418 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
419 CHECK_HANDLE_IS_VALID(handle);
421 mdg_group_s *grp = (mdg_group_s *)group;
422 mdg_check_null_ret_error("grp", grp, MDG_ERROR_INVALID_PARAMETER);
424 group_call_foreach_device_sync(_handle->group_proxy, grp->group_name, &ret, &va, NULL, &error);
425 count = g_variant_n_children(va);
428 GVariantIter *iter = NULL;
429 GVariant *device_va = NULL;
432 g_variant_get(va, "aa{sv}", &iter);
433 while ((device_va = g_variant_iter_next_value(iter)) != NULL) {
434 mdg_device_s *device;
436 device = mdg_get_device_from_variant(device_va);
438 result = foreach_cb((mdg_device_h)device, user_data);
442 g_variant_iter_free(iter);
450 EXPORT_API int mdg_group_invite_device(mdg_h handle,
451 mdg_group_h group, mdg_device_h device, char *PIN,
452 mdg_group_invite_device_finish_cb finish_cb, void *user_data)
454 int ret = MDG_ERROR_NONE;
455 GError *error = NULL;
458 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
460 mdg_manager_s *_handle = handle;
461 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
462 CHECK_HANDLE_IS_VALID(handle);
464 mdg_group_s *grp = (mdg_group_s *)group;
465 mdg_check_null_ret_error("grp", grp, MDG_ERROR_INVALID_PARAMETER);
467 mdg_device_s *dev = (mdg_device_s *)device;
468 mdg_check_null_ret_error("dev", dev, MDG_ERROR_INVALID_PARAMETER);
470 mdg_device_h cloned_device = NULL;
471 mdg_device_info_clone(&cloned_device, device);
473 va = mdg_create_variant_device(dev);
475 _handle->device_invite_finish_cb.finish_cb = finish_cb;
476 _handle->device_invite_finish_cb.user_data = user_data;
477 _handle->device_invite_finish_cb.device = cloned_device;
479 group_call_invite_device_sync(_handle->group_proxy, grp->group_name, va, PIN,
485 EXPORT_API int mdg_group_eject_device(mdg_h handle,
486 mdg_group_h group, mdg_device_h device,
487 mdg_group_eject_device_finish_cb finish_cb, void *user_data)
489 int ret = MDG_ERROR_NONE;
490 GError *error = NULL;
492 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
494 mdg_manager_s *_handle = handle;
495 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
496 CHECK_HANDLE_IS_VALID(handle);
498 mdg_device_s *dev = (mdg_device_s *)device;
499 mdg_check_null_ret_error("dev", dev, MDG_ERROR_INVALID_PARAMETER);
501 mdg_group_s *grp = (mdg_group_s *)group;
502 mdg_check_null_ret_error("grp", grp, MDG_ERROR_INVALID_PARAMETER);
504 _handle->device_eject_finish_cb.finish_cb = finish_cb;
505 _handle->device_eject_finish_cb.user_data = user_data;
507 group_call_eject_device_sync(_handle->group_proxy, grp->group_name, dev->device_id, &ret,
513 EXPORT_API int mdg_group_info_create(mdg_group_h* group)
515 int ret = MDG_ERROR_NONE;
517 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
519 mdg_group_h _group = g_malloc0(sizeof(mdg_group_s));
520 if (NULL == _group) {
521 /* LCOV_EXCL_START */
522 _ERR("Memory allocation Failed(%d)", errno);
523 return MDG_ERROR_OUT_OF_MEMORY;
531 EXPORT_API int mdg_group_info_clone(mdg_group_h *target,
534 int ret = MDG_ERROR_NONE;
536 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
538 mdg_group_s * src = (mdg_group_s *)source;
539 mdg_check_null_ret_error("source", source, MDG_ERROR_INVALID_PARAMETER);
541 *target = (mdg_group_s *)g_malloc0(sizeof(mdg_group_s));
542 mdg_check_null_ret_error("target", target, MDG_ERROR_INVALID_PARAMETER);
543 mdg_group_s *dst = *target;
546 dst->device_id = g_strdup(src->device_id);
549 dst->host_addr = g_strdup(src->host_addr);
552 dst->group_name = g_strdup(src->group_name);
554 dst->type = src->type;
559 EXPORT_API int mdg_group_info_destroy(mdg_group_h data)
561 int ret = MDG_ERROR_NONE;
563 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
565 mdg_group_s * group = (mdg_group_s *)data;
566 mdg_check_null_ret_error("group", group, MDG_ERROR_INVALID_PARAMETER);
568 if (group->device_id) {
569 g_free(group->device_id);
570 group->device_id = NULL;
572 if (group->host_addr) {
573 g_free(group->host_addr);
574 group->host_addr = NULL;
576 if (group->group_name) {
577 g_free(group->group_name);
578 group->group_name = NULL;
587 EXPORT_API int mdg_group_info_get_device_id(
588 mdg_group_h group, char **device_id)
590 int ret = MDG_ERROR_NONE;
592 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
594 *device_id = g_strdup(((mdg_group_s *)group)->device_id);
599 EXPORT_API int mdg_group_info_get_host_addr(
600 mdg_group_h group, char **host_addr)
602 int ret = MDG_ERROR_NONE;
604 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
606 *host_addr = g_strdup(((mdg_group_s *)group)->host_addr);
611 EXPORT_API int mdg_group_info_get_type(mdg_group_h group,
612 mdg_group_type_e *type)
614 int ret = MDG_ERROR_NONE;
616 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
618 *type = ((mdg_group_s *)group)->type;
623 EXPORT_API int mdg_group_info_get_name(
624 mdg_group_h group, char **name)
626 int ret = MDG_ERROR_NONE;
628 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
630 *name = g_strdup(((mdg_group_s *)group)->group_name);
635 EXPORT_API int mdg_device_info_clone(mdg_device_h *target,
638 int ret = MDG_ERROR_NONE;
640 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
642 mdg_device_s * src = (mdg_device_s *)source;
643 mdg_check_null_ret_error("source", source, MDG_ERROR_INVALID_PARAMETER);
645 *target = (mdg_device_s *)g_malloc0(sizeof(mdg_device_s));
646 mdg_check_null_ret_error("target", target, MDG_ERROR_INVALID_PARAMETER);
647 mdg_device_s *dst = *target;
650 dst->device_id = g_strdup(src->device_id);
653 dst->addr = g_strdup(src->addr);
655 dst->port = src->port;
656 dst->secure_port = src->secure_port;
657 dst->conn_type = src->conn_type;
660 dst->model_name = g_strdup(src->model_name);
662 if (src->device_name)
663 dst->device_name = g_strdup(src->device_name);
665 if (src->platform_ver)
666 dst->platform_ver = g_strdup(src->platform_ver);
669 dst->vendor_id = g_strdup(src->vendor_id);
672 dst->profile = g_strdup(src->profile);
674 dst->is_invited = src->is_invited;
675 dst->type = src->type;
680 EXPORT_API int mdg_device_info_destroy(mdg_device_h data)
682 int ret = MDG_ERROR_NONE;
684 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
686 mdg_device_s * device = (mdg_device_s *)data;
687 mdg_check_null_ret_error("data", data, MDG_ERROR_INVALID_PARAMETER);
689 if (device->device_id) {
690 g_free(device->device_id);
691 device->device_id = NULL;
695 g_free(device->addr);
699 if (device->model_name) {
700 g_free(device->model_name);
701 device->model_name = NULL;
704 if (device->device_name) {
705 g_free(device->device_name);
706 device->device_name = NULL;
709 if (device->platform_ver) {
710 g_free(device->platform_ver);
711 device->platform_ver = NULL;
714 if (device->vendor_id) {
715 g_free(device->vendor_id);
716 device->vendor_id = NULL;
719 if (device->profile) {
720 g_free(device->profile);
721 device->profile = NULL;
730 EXPORT_API int mdg_device_info_get_device_id(
731 mdg_device_h device, char **device_id)
733 int ret = MDG_ERROR_NONE;
735 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
737 *device_id = g_strdup(((mdg_device_s *)device)->device_id);
742 EXPORT_API int mdg_device_info_get_addr(
743 mdg_device_h device, char **addr)
745 int ret = MDG_ERROR_NONE;
747 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
749 *addr = g_strdup(((mdg_device_s *)device)->addr);
754 EXPORT_API int mdg_device_info_get_port(
755 mdg_device_h device, int *port)
757 int ret = MDG_ERROR_NONE;
759 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
761 *port = (((mdg_device_s *)device)->port);
766 EXPORT_API int mdg_device_info_get_secure_port(
767 mdg_device_h device, int *secure_port)
769 int ret = MDG_ERROR_NONE;
771 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
773 *secure_port = (((mdg_device_s *)device)->secure_port);
778 EXPORT_API int mdg_device_info_get_model_name(
779 mdg_device_h device, char **model_name)
781 int ret = MDG_ERROR_NONE;
783 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
785 *model_name = g_strdup(((mdg_device_s *)device)->model_name);
790 EXPORT_API int mdg_device_info_get_device_name(
791 mdg_device_h device, char **device_name)
793 int ret = MDG_ERROR_NONE;
795 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
797 *device_name = g_strdup(((mdg_device_s *)device)->device_name);
802 EXPORT_API int mdg_device_info_get_platform_ver(
803 mdg_device_h device, char **platform_ver)
805 int ret = MDG_ERROR_NONE;
807 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
809 *platform_ver = g_strdup(((mdg_device_s *)device)->platform_ver);
814 EXPORT_API int mdg_device_info_get_vendor_id(
815 mdg_device_h device, char **vendor_id)
817 int ret = MDG_ERROR_NONE;
819 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
821 *vendor_id = g_strdup(((mdg_device_s *)device)->vendor_id);
826 EXPORT_API int mdg_device_info_get_profile(
827 mdg_device_h device, char **profile)
829 int ret = MDG_ERROR_NONE;
831 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
833 *profile = g_strdup(((mdg_device_s *)device)->profile);
838 EXPORT_API int mdg_device_info_is_invited(
839 mdg_device_h device, bool *is_invited)
841 int ret = MDG_ERROR_NONE;
843 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
845 *is_invited = ((mdg_device_s *)device)->is_invited;
850 EXPORT_API int mdg_device_info_get_type(
851 mdg_device_h device, mdg_device_type_e *type)
853 int ret = MDG_ERROR_NONE;
855 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
857 *type = ((mdg_device_s *)device)->type;
862 EXPORT_API int mdg_request_create_group(mdg_h handle,
863 mdg_device_h device, char *group_name, mdg_request_result_cb cb,
866 int ret = MDG_ERROR_NONE;
867 GError *error = NULL;
872 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
874 mdg_manager_s *_handle = handle;
875 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
876 CHECK_HANDLE_IS_VALID(handle);
878 mdg_device_s *dev = (mdg_device_s *)device;
879 mdg_check_null_ret_error("device", device, MDG_ERROR_INVALID_PARAMETER);
880 mdg_check_null_ret_error("group_name", group_name,
881 MDG_ERROR_INVALID_PARAMETER);
883 _DBG("Device id : %s", dev->device_id);
885 group_call_request_create_group_sync(_handle->group_proxy, dev->device_id, dev->addr,
886 dev->secure_port, group_name, &ret, NULL, &error);
891 EXPORT_API int mdg_request_invite_device(mdg_h handle,
892 mdg_group_h group, mdg_device_h device, char *PIN,
893 mdg_request_result_cb cb, void *user_data)
895 int ret = MDG_ERROR_NONE;
896 GError *error = NULL;
901 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
903 mdg_manager_s *_handle = handle;
904 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
905 CHECK_HANDLE_IS_VALID(handle);
907 mdg_group_s *grp = (mdg_group_s *)group;
908 mdg_check_null_ret_error("group", group, MDG_ERROR_INVALID_PARAMETER);
910 mdg_device_s *dev = (mdg_device_s *)device;
911 mdg_check_null_ret_error("device", device, MDG_ERROR_INVALID_PARAMETER);
913 _DBG("%s", grp->device_id);
914 _DBG("%s", grp->group_name);
915 _DBG("%s", dev->device_id);
917 group_call_request_invite(_handle->group_proxy, grp->device_id, dev->addr,
918 dev->secure_port, grp->group_name, dev->device_id, PIN, NULL, NULL, &error);
920 _ERR("Failed DBus call [%s]", error->message);
922 ret = MDG_ERROR_IO_ERROR;
928 EXPORT_API int mdg_request_eject_device(mdg_h handle,
929 mdg_group_h group, mdg_device_h device, mdg_request_result_cb cb,
932 int ret = MDG_ERROR_NONE;
933 GError *error = NULL;
938 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
940 mdg_manager_s *_handle = handle;
941 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
942 CHECK_HANDLE_IS_VALID(handle);
944 mdg_group_s *grp = (mdg_group_s *)group;
945 mdg_check_null_ret_error("group", group, MDG_ERROR_INVALID_PARAMETER);
947 mdg_device_s *dev = (mdg_device_s *)device;
948 mdg_check_null_ret_error("device", device, MDG_ERROR_INVALID_PARAMETER);
950 _DBG("%s", grp->device_id);
951 _DBG("%s", grp->group_name);
952 _DBG("%s", dev->device_id);
954 group_call_request_eject(_handle->group_proxy, grp->device_id, dev->addr,
955 dev->secure_port, grp->group_name, dev->device_id, NULL, NULL, &error);
957 _ERR("Failed DBus call [%s]", error->message);
959 ret = MDG_ERROR_IO_ERROR;
965 EXPORT_API int mdg_request_channel_list(mdg_h handle, mdg_device_h device,
966 mdg_request_channel_list_finish_cb finish_cb, void *user_data)
968 int ret = MDG_ERROR_NONE;
969 GError *error = NULL;
971 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
973 mdg_manager_s *_handle = handle;
974 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
975 CHECK_HANDLE_IS_VALID(handle);
977 mdg_device_s *dev = (mdg_device_s *)device;
978 mdg_check_null_ret_error("device", device, MDG_ERROR_INVALID_PARAMETER);
979 _handle->request_channel_list_finish_cb.finish_cb = finish_cb;
980 _handle->request_channel_list_finish_cb.user_data = user_data;
982 _DBG("%s", dev->device_id);
984 group_call_request_channel_list(_handle->group_proxy, dev->device_id, dev->addr,
985 dev->secure_port, NULL, NULL, &error);
987 _ERR("Failed DBus call [%s]", error->message);
989 ret = MDG_ERROR_IO_ERROR;
995 EXPORT_API int mdg_request_result_callback(mdg_h handle,
996 mdg_request_result_cb result_cb, void *user_data)
998 int ret = MDG_ERROR_NONE;
1000 CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
1002 mdg_manager_s *_handle = handle;
1003 mdg_check_null_ret_error("handle", handle, MDG_ERROR_INVALID_PARAMETER);
1005 _handle->request_result_cb.result_cb = result_cb;
1006 _handle->request_result_cb.user_data = user_data;