From: Piotr Kosko
Date: Mon, 31 Oct 2016 08:19:38 +0000 (+0100)
Subject: [bluetooth] Added listFolders implementation with async result
X-Git-Tag: submit/tizen_3.0/20161208.051813~11
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca820283932df2c07fd7196c86b3dde2ba68b9a5;p=platform%2Fcore%2Fapi%2Fbluetooth.git
[bluetooth] Added listFolders implementation with async result
[Feature] added implementation for listFolders method
[Verification] function checked with sample C program:
- listing folder is possible,
- options work correctly and maxcount works fine.
- user_data is correctly passed to result callback
Change-Id: I613ffea4cec5b64fbc5d25081b7b8204bd01b822
Signed-off-by: Piotr Kosko
---
diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h
index f1d30ca..0f4352f 100644
--- a/include/bluetooth_private.h
+++ b/include/bluetooth_private.h
@@ -155,12 +155,15 @@ typedef enum {
BT_EVENT_HF_REMOTE_CALL_EVENT, /**< Audio - HF : call state event callback */
BT_EVENT_HF_CIEV_DEVICE_STATUS_CHANGED, /**< Audio - HF : device state changed callback */
#endif
+ BT_EVENT_MAP_CLIENT_LIST_FOLDERS, /**< MAP client - listFolders event*/
BT_EVENT_MAP_CLIENT_111, /**< MAP client 111 */
BT_EVENT_MAP_CLIENT_222, /**< MAP client 222 */
BT_EVENT_MAP_CLIENT_333, /**< MAP client 333 */
BT_EVENT_MAP_CLIENT_444, /**< MAP client 444 */
BT_EVENT_MAP_CLIENT_555, /**< MAP client 555 */
BT_EVENT_MAP_CLIENT_666, /**< MAP client 666 */
+ BT_EVENT_MAP_CLIENT_777, /**< MAP client 777 */
+ BT_EVENT_MAP_CLIENT_888, /**< MAP client 888 */
BT_EVENT_MAX
} bt_event_e;
diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h
index 3c65938..4205289 100644
--- a/include/mobile/bluetooth_internal.h
+++ b/include/mobile/bluetooth_internal.h
@@ -1628,7 +1628,8 @@ int bt_map_client_set_folder(
int bt_map_client_list_folders(
bt_map_client_session_info_h handle,
bt_map_client_list_folders_filter_h filter,
- bt_map_client_list_folders_cb callback
+ bt_map_client_list_folders_cb callback,
+ void* user_data
);
/**
diff --git a/include/mobile/bluetooth_type_internal.h b/include/mobile/bluetooth_type_internal.h
index 9768311..c82ca4a 100644
--- a/include/mobile/bluetooth_type_internal.h
+++ b/include/mobile/bluetooth_type_internal.h
@@ -105,10 +105,6 @@ typedef struct {
int maxcount;
} bt_map_client_list_folders_filter_s;
-typedef struct {
- char *name;
-} bt_map_client_folder_s;
-
typedef struct {
int offset;
int max_count;
@@ -171,8 +167,6 @@ typedef struct {
typedef bt_map_client_list_folders_filter_s* bt_map_client_list_folders_filter_h;
-typedef bt_map_client_folder_s* bt_map_client_folder_h;
-
typedef bt_map_client_list_messages_filter_s* bt_map_client_list_messages_filter_h;
typedef bt_map_client_message_item_s* bt_map_client_message_item_h;
@@ -181,7 +175,7 @@ typedef bt_map_client_push_message_args_s* bt_map_client_push_message_args_h;
typedef bt_map_client_message_s* bt_map_client_message_h;
-typedef void (*bt_map_client_list_folders_cb)(int result, bt_map_client_folder_h *folders, int count, void *user_data);
+typedef void (*bt_map_client_list_folders_cb)(int result, char **folders, int count, void *user_data);
typedef void (*bt_map_client_list_filter_fields_cb)(int result, char **filter_fields, int count, void *user_data);
diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h
index 565e878..c39622b 100644
--- a/include/wearable/bluetooth_internal.h
+++ b/include/wearable/bluetooth_internal.h
@@ -1598,7 +1598,8 @@ int bt_map_client_set_folder(
int bt_map_client_list_folders(
bt_map_client_session_info_h handle,
bt_map_client_list_folders_filter_h filter,
- bt_map_client_list_folders_cb callback
+ bt_map_client_list_folders_cb callback,
+ void* user_data
);
/**
diff --git a/include/wearable/bluetooth_type_internal.h b/include/wearable/bluetooth_type_internal.h
index 9033985..6fb155a 100644
--- a/include/wearable/bluetooth_type_internal.h
+++ b/include/wearable/bluetooth_type_internal.h
@@ -107,10 +107,6 @@ typedef struct {
int maxcount;
} bt_map_client_list_folders_filter_s;
-typedef struct {
- char *name;
-} bt_map_client_folder_s;
-
typedef struct {
int offset;
int max_count;
@@ -173,8 +169,6 @@ typedef struct {
typedef bt_map_client_list_folders_filter_s* bt_map_client_list_folders_filter_h;
-typedef bt_map_client_folder_s* bt_map_client_folder_h;
-
typedef bt_map_client_list_messages_filter_s* bt_map_client_list_messages_filter_h;
typedef bt_map_client_message_item_s* bt_map_client_message_item_h;
@@ -183,7 +177,7 @@ typedef bt_map_client_push_message_args_s* bt_map_client_push_message_args_h;
typedef bt_map_client_message_s* bt_map_client_message_h;
-typedef void (*bt_map_client_list_folders_cb)(int result, bt_map_client_folder_h *folders, int count, void *user_data);
+typedef void (*bt_map_client_list_folders_cb)(int result, char **folders, int count, void *user_data);
typedef void (*bt_map_client_list_filter_fields_cb)(int result, char **filter_fields, int count, void *user_data);
diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c
index 3688c88..a87f225 100644
--- a/src/bluetooth-common.c
+++ b/src/bluetooth-common.c
@@ -997,14 +997,20 @@ static bool __bt_need_to_handle(int event)
}
event_index = __bt_get_cb_index(event);
- if (event_index != -1 && bt_event_slot_container[event_index].callback)
+ if (event_index != -1 && bt_event_slot_container[event_index].callback) {
return true;
+ } else {
+ BT_DBG("Event [%d] would not handled, not found in bt_event_slot_container", event);
+ }
+
return false;
}
static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *user_data)
{
+ BT_DBG("Entered for event: %d", event);
+
int call_id;
int *avrcp_mode;
int *discoverable_timeout;
@@ -1455,8 +1461,25 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
if (device_addr != NULL)
free(device_addr);
break;
+ case BLUETOOTH_EVENT_MAP_LIST_FOLDERS_COMPLETE:
+ BT_INFO("BLUETOOTH_EVENT_MAP_LIST_FOLDERS_COMPLETE event");
+ //do not need to release memory, it is managed by bluetooth-frwk
+ bt_map_client_folders_s* folders_struct = (bt_map_client_folders_s*) param->param_data;
+ ((bt_map_client_list_folders_cb)bt_event_slot_container[event_index].callback)
+ (param->result, folders_struct->names, folders_struct->size,
+ bt_event_slot_container[event_index].user_data);
- /* TODO: MAP events, see above */
+ if (device_addr != NULL)
+ free(device_addr);
+ break;
+ /// TODO MAP place for your case 1
+ /// TODO MAP place for your case 2
+ /// TODO MAP place for your case 3
+ /// TODO MAP place for your case 4
+ /// TODO MAP place for your case 5
+ /// TODO MAP place for your case 6
+ /// TODO MAP place for your case 7
+ /// TODO MAP place for your case 8
case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED:
BT_INFO("BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED");
@@ -2666,6 +2689,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
break;
}
default:
+ BT_INFO("Unknown function");
break;
}
}
@@ -3028,7 +3052,16 @@ static int __bt_get_cb_index(int event)
return BT_EVENT_OPP_CLIENT_PUSH_PROGRESS;
case BLUETOOTH_EVENT_OPC_DISCONNECTED:
return BT_EVENT_OPP_CLIENT_PUSH_FINISHED;
- /* TODO: MAP? see above */
+ case BLUETOOTH_EVENT_MAP_LIST_FOLDERS_COMPLETE:
+ return BT_EVENT_MAP_CLIENT_LIST_FOLDERS;
+ /// TODO MAP place for your case 1
+ /// TODO MAP place for your case 2
+ /// TODO MAP place for your case 3
+ /// TODO MAP place for your case 4
+ /// TODO MAP place for your case 5
+ /// TODO MAP place for your case 6
+ /// TODO MAP place for your case 7
+ /// TODO MAP place for your case 8
case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED:
case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED:
return BT_EVENT_NAP_CONNECTION_STATE_CHANGED;
diff --git a/src/bluetooth-map-client.c b/src/bluetooth-map-client.c
index 4c4a4ad..8fdb08b 100644
--- a/src/bluetooth-map-client.c
+++ b/src/bluetooth-map-client.c
@@ -171,10 +171,33 @@ int bt_map_client_set_folder(
int bt_map_client_list_folders(
bt_map_client_session_info_h handle,
bt_map_client_list_folders_filter_h filter,
- bt_map_client_list_folders_cb callback)
+ bt_map_client_list_folders_cb callback,
+ void* user_data)
{
- /* TODO: MAP */
- return BT_ERROR_NONE;
+ LOGE("bt_map_client_list_folders");
+ //BT_CHECK_MAP_CLIENT_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_MAP_CLIENT_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(handle);
+
+ bt_map_client_session_info_s* session = (bt_map_client_session_info_s*) handle;
+
+ int offset = filter->offset;
+ int maxcount = filter->maxcount;
+
+ if (offset < -1 || maxcount < -1) {
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+ }
+
+ int error_code = _bt_get_error_code(bluetooth_map_client_list_folders(session, offset, maxcount));
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("bt_map_client_list_folders %s(0x%08x)", _bt_convert_error_to_string(error_code),
+ error_code);
+ } else {
+ _bt_set_cb(BT_EVENT_MAP_CLIENT_LIST_FOLDERS, callback, user_data);
+ }
+
+ return error_code; /* LCOV_EXCL_STOP */
}
int bt_map_client_list_filter_fields(