[bluetooth] Create/destroy session implementation added 57/102857/2
authorPiotr Kosko <p.kosko@samsung.com>
Wed, 19 Oct 2016 10:33:17 +0000 (12:33 +0200)
committerPyun DoHyun <dh79.pyun@samsung.com>
Thu, 8 Dec 2016 00:10:26 +0000 (16:10 -0800)
Change-Id: I6b07882aa55f288c77e2ccf8e71b711e2b7bd9ce
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
Signed-off-by: Lukasz Bardeli <l.bardeli@samsung.com>
include/mobile/bluetooth_internal.h
include/mobile/bluetooth_type_internal.h
include/wearable/bluetooth_internal.h
include/wearable/bluetooth_type_internal.h
src/bluetooth-map-client.c

index e88f0d5d4580069b3943aac87f02700e0ad19edf..68ae39a87805734219ecad9214b065542ca3dfa2 100644 (file)
@@ -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 */
 
 /**
index 644106045bbe973be520be69fa9bac1fdc8250f3..38229060747b3d5fc81452bc81ed8ad5af7ba08f 100644 (file)
@@ -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);
index ec30bd3e8c1bef6a0332b17b455f58ee9e9c9815..02dc2bbc8ce388d3d49e24b9fc3cb95387546967 100644 (file)
@@ -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 */
 
 /**
index bd371db88b91c2692577aaab317db9308d26a876..e2714f114a6ff0f72a3553b73c3551081fe7148d 100644 (file)
@@ -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);
index 0f1bdd1de2a75bb133c4a4c317137519b573ed4f..03e1c66a7532f284d0f15ff46fbf9c147e111eb1 100644 (file)
@@ -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 */