From 9b765af7335f1b448104f5c943fc56b822a074ca Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Tue, 24 Jul 2018 18:15:18 +0900 Subject: [PATCH] Add handle in invite callback Signed-off-by: Jihoon Jung Change-Id: Idef956d4043c452fa90e4c6338ef1e79c159b6a5 --- include/mdg.h | 3 ++- src/mdg.c | 4 ++++ src/mdg_dbus.c | 6 +++++- src/mdg_private.h | 1 + test/mdg-manager.c | 5 ++++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/mdg.h b/include/mdg.h index 18f858f..4c8a88a 100755 --- a/include/mdg.h +++ b/include/mdg.h @@ -325,7 +325,8 @@ int mdg_group_get_member_devices(mdg_h handle, * * @see mdg_group_invite_device() */ -typedef void (*mdg_group_invite_device_finish_cb)(int result, void *user_data); +typedef void (*mdg_group_invite_device_finish_cb)(int result, + mdg_device_h invited_device, void *user_data); /** * @brief Called after mdg_group_eject_device(). diff --git a/src/mdg.c b/src/mdg.c index 5a1d7a5..7f32107 100755 --- a/src/mdg.c +++ b/src/mdg.c @@ -403,8 +403,12 @@ EXPORT_API int mdg_group_invite_device(mdg_h handle, mdg_device_s *dev = (mdg_device_s *)device; mdg_check_null_ret_error("dev", dev, MDG_ERROR_INVALID_PARAMETER); + mdg_device_h cloned_device = NULL; + mdg_device_info_clone(&cloned_device, device); + _handle->device_invite_finish_cb.finish_cb = finish_cb; _handle->device_invite_finish_cb.user_data = user_data; + _handle->device_invite_finish_cb.device = cloned_device; group_call_invite_device_sync(_handle->group_proxy, grp->group_name, dev->device_id, PIN, &ret, NULL, &error); diff --git a/src/mdg_dbus.c b/src/mdg_dbus.c index 6038c3d..bd304de 100755 --- a/src/mdg_dbus.c +++ b/src/mdg_dbus.c @@ -77,7 +77,11 @@ static void __event_cb(Group *object, } } else if (event_type == MDG_EVENT_INVITE_DEVICE_FINISH) { if (handle->device_invite_finish_cb.finish_cb) { - handle->device_invite_finish_cb.finish_cb(ret, + mdg_device_s *device = (mdg_device_s *)(handle->device_invite_finish_cb.device); + if (device != NULL) { + device->is_invited = true; + } + handle->device_invite_finish_cb.finish_cb(ret, device, handle->device_invite_finish_cb.user_data); } else { _ERR("The callback not exists"); diff --git a/src/mdg_private.h b/src/mdg_private.h index 35f6beb..486de50 100755 --- a/src/mdg_private.h +++ b/src/mdg_private.h @@ -96,6 +96,7 @@ typedef struct _device_find_finish_cb_t { */ typedef struct _device_invite_finish_cb_t { mdg_group_invite_device_finish_cb finish_cb; /**< User callback to be called */ + mdg_device_h device; void *user_data; /**< User data pointer */ } device_invite_finish_cb_t; diff --git a/test/mdg-manager.c b/test/mdg-manager.c index 01a5b3b..b030ce1 100755 --- a/test/mdg-manager.c +++ b/test/mdg-manager.c @@ -158,9 +158,12 @@ static int run_device_eject(MManager *mm, struct menu_data *menu) return RET_SUCCESS; } -void _device_invite_result_cb(int result, void *user_data) +void _device_invite_result_cb(int result, mdg_device_h device, void *user_data) { + bool is_invited; + mdg_device_info_is_invited(device, &is_invited); msgb("\rInvite Device Finished [%s]", mdg_error_to_string(result)); + msgb("\rThe device invited is : %d", is_invited); } static int run_device_invite(MManager *mm, struct menu_data *menu) -- 2.7.4