From: Piotr Kosko
Date: Wed, 19 Oct 2016 10:33:17 +0000 (+0200)
Subject: [bluetooth] Create/destroy session implementation added
X-Git-Tag: submit/tizen_3.0/20161208.051813~15
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39b206d6fea3671f43676c4355bb29455fe55c4f;p=platform%2Fcore%2Fapi%2Fbluetooth.git
[bluetooth] Create/destroy session implementation added
Change-Id: I6b07882aa55f288c77e2ccf8e71b711e2b7bd9ce
Signed-off-by: Piotr Kosko
Signed-off-by: Lukasz Bardeli
---
diff --git a/include/mobile/bluetooth_internal.h b/include/mobile/bluetooth_internal.h
index e88f0d5..68ae39a 100644
--- a/include/mobile/bluetooth_internal.h
+++ b/include/mobile/bluetooth_internal.h
@@ -1553,6 +1553,15 @@ int bt_map_client_initialize(void);
*/
int bt_map_client_deinitialize(void);
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ * TODO ******************
+ *
+ * @see bt_map_client_initialize()
+ */
+int bt_map_client_create_session(const char* remote_address, bt_map_session_info_h* session);
+int bt_map_client_destroy_session(bt_map_session_info_h session);
+
/* TODO: MAP CAPI functions, see above */
/**
diff --git a/include/mobile/bluetooth_type_internal.h b/include/mobile/bluetooth_type_internal.h
index 6441060..3822906 100644
--- a/include/mobile/bluetooth_type_internal.h
+++ b/include/mobile/bluetooth_type_internal.h
@@ -147,6 +147,8 @@ typedef struct {
bool charset;
} bt_map_client_push_message_args_s;
+typedef void* bt_map_session_info_h;
+
typedef void (*bt_map_client_list_folders_cb)(int result, bt_map_client_folder_s *folders, int count, void *user_data);
typedef void (*bt_map_client_list_filter_fields_cb)(char **filter_fields, void *user_data);
diff --git a/include/wearable/bluetooth_internal.h b/include/wearable/bluetooth_internal.h
index ec30bd3..02dc2bb 100644
--- a/include/wearable/bluetooth_internal.h
+++ b/include/wearable/bluetooth_internal.h
@@ -1523,6 +1523,15 @@ int bt_map_client_initialize(void);
*/
int bt_map_client_deinitialize(void);
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ * TODO ******************
+ *
+ * @see bt_map_client_initialize()
+ */
+int bt_map_client_create_session(const char* remote_address, bt_map_session_info_h* session);
+int bt_map_client_destroy_session(bt_map_session_info_h session);
+
/* TODO: MAP CAPI functions, see above */
/**
diff --git a/include/wearable/bluetooth_type_internal.h b/include/wearable/bluetooth_type_internal.h
index bd371db..e2714f1 100644
--- a/include/wearable/bluetooth_type_internal.h
+++ b/include/wearable/bluetooth_type_internal.h
@@ -149,6 +149,8 @@ typedef struct {
bool charset;
} bt_map_client_push_message_args_s;
+typedef void* bt_map_session_info_h;
+
typedef void (*bt_map_client_list_folders_cb)(int result, bt_map_client_folder_s *folders, int count, void *user_data);
typedef void (*bt_map_client_list_filter_fields_cb)(char **filter_fields, void *user_data);
diff --git a/src/bluetooth-map-client.c b/src/bluetooth-map-client.c
index 0f1bdd1..03e1c66 100644
--- a/src/bluetooth-map-client.c
+++ b/src/bluetooth-map-client.c
@@ -29,7 +29,7 @@ static bool is_map_client_initialized = false;
#define BT_CHECK_MAP_CLIENT_SUPPORT() \
{ \
BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON); \
- BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_MAP); \
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_MAP); \
}
#define BT_CHECK_MAP_CLIENT_INIT_STATUS() \
@@ -50,16 +50,95 @@ int __bt_check_map_client_init_status(void)
int bt_map_client_initialize(void)
{
- /* TODO: MAP */
+ LOGE("bt_map_client_initialize");
+ int error_code = BT_ERROR_NONE;
+
+ //TODO it is not supported on TM1
+ //BT_CHECK_MAP_CLIENT_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+
+ error_code = _bt_get_error_code(bluetooth_map_init());
+
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), /* LCOV_EXCL_LINE */
+ error_code); /* LCOV_EXCL_LINE */
+ return error_code; /* LCOV_EXCL_LINE */
+ }
+
+ is_map_client_initialized = true;
return BT_ERROR_NONE;
}
int bt_map_client_deinitialize(void)
{
- /* TODO: MAP */
+ int error_code = BT_ERROR_NONE;
+
+ //BT_CHECK_MAP_CLIENT_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_MAP_CLIENT_INIT_STATUS();
+
+ error_code = _bt_get_error_code(bluetooth_map_deinit());
+
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), /* LCOV_EXCL_LINE */
+ error_code); /* LCOV_EXCL_LINE */
+ return error_code; /* LCOV_EXCL_LINE */
+ }
+
+ is_map_client_initialized = false;
return BT_ERROR_NONE;
}
+
+int bt_map_client_create_session(const char* remote_address, bt_map_session_info_h* out_h)
+{
+ BT_DBG("bt_map_client_create_session");
+ int error_code = BT_ERROR_NONE;
+
+ //BT_CHECK_MAP_CLIENT_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_MAP_CLIENT_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(remote_address);
+
+ bt_map_session_info_s* session = malloc(sizeof(bt_map_session_info_s));
+ session->remote_address = strdup(remote_address);
+
+ error_code = _bt_get_error_code(bluetooth_map_create_session(session));
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code),
+ error_code);
+ free(session->remote_address);
+ free(session);
+ } else {
+ BT_DBG("Successfully created session");
+ *out_h = session;
+ }
+ return error_code;
+
+}
+
+int bt_map_client_destroy_session(bt_map_session_info_h s)
+{
+ BT_DBG("bt_map_client_destroy_session");
+ int error_code = BT_ERROR_NONE;
+
+ //BT_CHECK_MAP_CLIENT_SUPPORT();
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_MAP_CLIENT_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(s);
+
+ bt_map_session_info_s* session = (bt_map_session_info_s*) s;
+
+ error_code = _bt_get_error_code(bluetooth_map_destroy_session(session));
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code),
+ error_code);
+ } else {
+ BT_DBG("Successfully destroyed session");
+ }
+ return error_code;
+}
+
int bt_map_client_set_folder(const char *name)
{
/* TODO: MAP */