initial MAP stub implementation 56/102856/2
authorPiotr Dabrowski <p.dabrowski2@samsung.com>
Thu, 6 Oct 2016 11:43:11 +0000 (13:43 +0200)
committerPyun DoHyun <dh79.pyun@samsung.com>
Thu, 8 Dec 2016 00:10:16 +0000 (16:10 -0800)
Change-Id: I7c5ff159a312f4c887a6091f8f86e9d9dac2b559

12 files changed:
CMakeLists.txt
include/bluetooth_private.h
include/mobile/bluetooth_internal.h
include/mobile/bluetooth_type.h
include/mobile/bluetooth_type_internal.h
include/wearable/bluetooth_internal.h
include/wearable/bluetooth_type.h
include/wearable/bluetooth_type_internal.h
src/bluetooth-adapter.c
src/bluetooth-common.c
src/bluetooth-device.c
src/bluetooth-map-client.c [new file with mode: 0644]

index 8a95c78a314662ea3a3c3bb81621d5b1627cbfb7..a96ea981382c9adda6a8566befbf320423ea7211 100644 (file)
@@ -52,6 +52,7 @@ src/bluetooth-device.c
 src/bluetooth-socket.c
 src/bluetooth-opp-server.c
 src/bluetooth-opp-client.c
+src/bluetooth-map-client.c
 src/bluetooth-pan.c
 src/bluetooth-hdp.c
 src/bluetooth-hid.c
@@ -70,6 +71,7 @@ src/bluetooth-device.c
 src/bluetooth-socket.c
 src/bluetooth-opp-server.c
 src/bluetooth-opp-client.c
+src/bluetooth-map-client.c
 src/bluetooth-pan.c
 src/bluetooth-hdp.c
 src/bluetooth-hid.c
index 36ac2ca93cde291f0a8468872f7eaa549ef49e29..f1d30ca9ed6d7339425f0f0d1840921056be49e7 100644 (file)
@@ -43,6 +43,7 @@ extern "C" {
 #define BT_ERR(fmt, args...) SLOGE(fmt, ##args)
 
 #define OPP_UUID "00001105-0000-1000-8000-00805f9b34fb"
+#define MAP_UUID "00001134-0000-1000-8000-00805f9b34fb"
 
 /* Manufacture ID for Apple iBeacons */
 #define COMPANY_ID_APPLE 0x004C
@@ -80,6 +81,8 @@ typedef enum {
        BT_EVENT_OPP_CLIENT_PUSH_RESPONSED, /**< OPP client connection is responsed */
        BT_EVENT_OPP_CLIENT_PUSH_PROGRESS, /**< OPP client push progress */
        BT_EVENT_OPP_CLIENT_PUSH_FINISHED, /**< OPP client push is finished */
+       BT_EVENT_MAP_CONNECTION_REQUESTED, /**< MAP connection is requested */
+       BT_EVENT_MAP_CLIENT_OP_COMPLETE, /**< MAP client operation is complete */
        BT_EVENT_PAN_CONNECTION_STATE_CHANGED, /**< PAN connection change */
        BT_EVENT_NAP_CONNECTION_STATE_CHANGED, /**< NAP connection change */
        BT_EVENT_HDP_CONNECTED, /**< HDP connection change */
@@ -152,6 +155,12 @@ 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_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_MAX
 } bt_event_e;
 
@@ -513,6 +522,7 @@ typedef void (*bt_adapter_passkey_notification_cb)(const char *remote_address, c
 #define BT_FEATURE_HID_HOST "tizen.org/feature/network.bluetooth.hid"
 #define BT_FEATURE_HID_DEVICE "tizen.org/feature/network.bluetooth.hid_device"
 #define BT_FEATURE_OPP "tizen.org/feature/network.bluetooth.opp"
+#define BT_FEATURE_MAP "tizen.org/feature/network.bluetooth.map"
 #define BT_FEATURE_TETHERING "tizen.org/feature/network.tethering.bluetooth"
 #define BT_FEATURE_PBAP_CLIENT "tizen.org/feature/network.bluetooth.phonebook.client"
 
index 32218e5ed3a290db4c059dca239619d25ad2ae54..e88f0d5d4580069b3943aac87f02700e0ad19edf 100644 (file)
@@ -1521,6 +1521,40 @@ int bt_opp_server_initialize(const char *destination, bt_opp_server_push_request
 int bt_opp_get_transfer_progress(bt_opp_transfer_type_t transfer_type,
                int transfer_id, unsigned char *progress);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ * @brief Initializes the Bluetooth MAP client.
+ * @since_tizen 3.0
+ * @remarks This function must be called before Bluetooth MAP client starts. \n
+ * You must free all resources of the Bluetooth service by calling bt_map_client_deinitialize()
+ * if Bluetooth MAP service is no longer needed.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_RESOURCE_BUSY  Device or resource busy
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED   Not supported
+ *
+ * @see  bt_map_client_deinitialize()
+ */
+int bt_map_client_initialize(void);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ * @brief Deinitializes the Bluetooth MAP client.
+ * @since_tizen 2.3
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED   Not supported
+ *
+ * @see  bt_map_client_initialize()
+ */
+int bt_map_client_deinitialize(void);
+
+/* TODO: MAP CAPI functions, see above */
+
 /**
  * @internal
  * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE
index aa81ff5bd4b4828078a029f1902ee12364830022..b0b7e3ba5383c6f7756b655430317b3e41e533c7 100644 (file)
@@ -287,6 +287,7 @@ typedef enum {
        BT_SC_PBAP_SERVICE_MASK = 0x00100000, /**< PBAP service class */
        BT_SC_HID_SERVICE_MASK = 0x00200000, /**< HID service class */
        BT_SC_A2DP_SOURCE_SERVICE_MASK = 0x00400000, /**< A2DP SOURCE service class */
+       BT_SC_MAP_SERVICE_MASK = 0x00800000, /**< MAP service class */
        BT_SC_ALL_SERVICE_MASK = 0x00FFFFFF, /**< ALL service class */
        BT_SC_MAX /**< MAX service class */
 } bt_service_class_t;
index f9c5686d976e2320cb19dba9b087a9eb292d5f8f..644106045bbe973be520be69fa9bac1fdc8250f3 100644 (file)
@@ -93,6 +93,68 @@ typedef enum {
        BT_TRANSFER_OUTBOUND,       /**< Outbound Transfer Type */
 } bt_opp_transfer_type_t;
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ */
+typedef struct {
+       char *name;     /**< Folder name */
+} bt_map_client_folder_s;
+
+typedef struct {
+       char *folder;
+       char *subject;
+       char *timestamp;
+       char *sender;
+       char *sender_address;
+       char *reply_to;
+       char *recipient;
+       char *recipient_address;
+       char *type;
+       int size;
+       bool text;
+       char *status;
+       int attachment_size;
+       bool priority;
+       bool read;
+       bool deleted;
+       bool sent;
+       bool protect;
+       char *content;
+} bt_map_client_message_s;
+
+typedef struct {
+       int offset;
+       int maxcount;
+} bt_map_client_list_folders_filter_s;
+
+typedef struct {
+       int offset;
+       int maxcount;
+       int subject_length;
+       char *fields;
+       char *type;
+       char *period_start;
+       char *period_end;
+       char *status;
+       char *recipient;
+       char *sender;
+       bool priority;
+} bt_map_client_list_messages_filter_s;
+
+typedef struct {
+       bool transparent;
+       bool retry;
+       bool charset;
+} bt_map_client_push_message_args_s;
+
+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);
+
+typedef void (*bt_map_client_list_messages_cb)(int result, bt_map_client_message_s *messages, int count, void *user_data);
+
+typedef void (*bt_map_client_get_message_cb)(int result, bt_map_client_message_s message, void *user_data);
+
 /**
  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
  * @brief  Called when the connectable state changes.
index a4c5ad17c37907593aa6efed654f044f2058f6b1..ec30bd3e8c1bef6a0332b17b455f58ee9e9c9815 100644 (file)
@@ -1491,6 +1491,40 @@ int bt_opp_server_initialize(const char *destination, bt_opp_server_push_request
 int bt_opp_get_transfer_progress(bt_opp_transfer_type_t transfer_type,
                int transfer_id, unsigned char *progress);
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ * @brief Initializes the Bluetooth MAP client.
+ * @since_tizen 3.0
+ * @remarks This function must be called before Bluetooth MAP client starts. \n
+ * You must free all resources of the Bluetooth service by calling bt_map_client_deinitialize()
+ * if Bluetooth MAP service is no longer needed.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_RESOURCE_BUSY  Device or resource busy
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED   Not supported
+ *
+ * @see  bt_map_client_deinitialize()
+ */
+int bt_map_client_initialize(void);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ * @brief Deinitializes the Bluetooth MAP client.
+ * @since_tizen 2.3
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED   Not supported
+ *
+ * @see  bt_map_client_initialize()
+ */
+int bt_map_client_deinitialize(void);
+
+/* TODO: MAP CAPI functions, see above */
+
 /**
  * @internal
  * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE
index 9c4402d72e091fef843155cbcba33f853d0294ad..73b8079b3d5ee5ce8dc4ba6392a61b42012be6e3 100644 (file)
@@ -286,6 +286,7 @@ typedef enum {
        BT_SC_PBAP_SERVICE_MASK = 0x00100000, /**< PBAP service class */
        BT_SC_HID_SERVICE_MASK = 0x00200000, /**< HID service class */
        BT_SC_A2DP_SOURCE_SERVICE_MASK = 0x00400000, /**< A2DP SOURCE service class */
+       BT_SC_MAP_SERVICE_MASK = 0x00800000, /**< MAP service class */
        BT_SC_ALL_SERVICE_MASK = 0x00FFFFFF, /**< ALL service class */
        BT_SC_MAX /**< MAX service class */
 } bt_service_class_t;
index 2fa330ba5a782ba4bec27676ed097f8f7e41c513..bd371db88b91c2692577aaab317db9308d26a876 100644 (file)
@@ -95,6 +95,68 @@ typedef enum {
        BT_TRANSFER_OUTBOUND,       /**< Outbound Transfer Type */
 } bt_opp_transfer_type_t;
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE
+ */
+typedef struct {
+       char *name;     /**< Folder name */
+} bt_map_client_folder_s;
+
+typedef struct {
+       char *folder;
+       char *subject;
+       char *timestamp;
+       char *sender;
+       char *sender_address;
+       char *reply_to;
+       char *recipient;
+       char *recipient_address;
+       char *type;
+       int size;
+       bool text;
+       char *status;
+       int attachment_size;
+       bool priority;
+       bool read;
+       bool deleted;
+       bool sent;
+       bool protect;
+       char *content;
+} bt_map_client_message_s;
+
+typedef struct {
+       int offset;
+       int maxcount;
+} bt_map_client_list_folders_filter_s;
+
+typedef struct {
+       int offset;
+       int maxcount;
+       int subject_length;
+       char *fields;
+       char *type;
+       char *period_start;
+       char *period_end;
+       char *status;
+       char *recipient;
+       char *sender;
+       bool priority;
+} bt_map_client_list_messages_filter_s;
+
+typedef struct {
+       bool transparent;
+       bool retry;
+       bool charset;
+} bt_map_client_push_message_args_s;
+
+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);
+
+typedef void (*bt_map_client_list_messages_cb)(int result, bt_map_client_message_s *messages, int count, void *user_data);
+
+typedef void (*bt_map_client_get_message_cb)(int result, bt_map_client_message_s message, void *user_data);
+
 /**
  * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
  * @brief  Called when the connectable state changes.
index 4039c7dceb836e4e38f6de367db31c8376ed9ff6..ca358dd7f4dacce0d3b74083a23f259a6e5e2a23 100644 (file)
@@ -725,6 +725,7 @@ int bt_adapter_is_service_used(const char *service_uuid, bool *used)
                                        &is_used));
                *used = is_used ? true : false; /* LCOV_EXCL_LINE */
        }
+       /* TODO: MAP? see above */
 
        if (ret != BT_ERROR_NONE) { /* LCOV_EXCL_LINE */
                BT_ERR("%s(0x%08x) : Failed to run function",
index 16abff5835f50676527bbf78c0a19decf0c90a7e..3688c882e9126d1dafe6b639bcb089515eb63843 100644 (file)
@@ -1434,6 +1434,30 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                /* This event don't be used in CAPI */
                break;
 
+       case BLUETOOTH_EVENT_MAP_CONNECTED:
+               BT_INFO("bt_map_client_??????????_cb() will be called");
+               bd_addr = (bluetooth_device_address_t *)(param->param_data);
+               _bt_convert_address_to_string(&device_addr, bd_addr);
+
+               /* TODO: MAP, see above */
+
+               if (device_addr != NULL)
+                       free(device_addr);
+               break;
+
+       case BLUETOOTH_EVENT_MAP_DISCONNECTED:
+               BT_INFO("bt_map_client_??????????_cb() will be called");
+               bd_addr = (bluetooth_device_address_t *)(param->param_data);
+               _bt_convert_address_to_string(&device_addr, bd_addr);
+
+               /* TODO: MAP, see above */
+
+               if (device_addr != NULL)
+                       free(device_addr);
+               break;
+
+       /* TODO: MAP events, see above */
+
        case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED:
                BT_INFO("BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED");
                dev_info = (bluetooth_network_device_info_t *)(param->param_data);
@@ -3004,6 +3028,7 @@ 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_NETWORK_SERVER_CONNECTED:
        case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED:
                return BT_EVENT_NAP_CONNECTION_STATE_CHANGED;
index 315f8369793da6ce85964daf138f8b5e18163798..08999eca8c1666897645993f90a779e4f7279f8f 100644 (file)
@@ -557,6 +557,10 @@ int bt_device_get_service_mask_from_uuid_list(char **uuids,
                        service_mask |= BT_SC_OPP_SERVICE_MASK;
                        break;
 
+               case BLUETOOTH_OBEX_MESSAGE_ACCESS_SERVICE_UUID:
+                       service_mask |= BT_SC_MAP_SERVICE_MASK;
+                       break;
+
                case BLUETOOTH_OBEX_FILE_TRANSFER_UUID:
                        service_mask |= BT_SC_FTP_SERVICE_MASK;
                        break;
diff --git a/src/bluetooth-map-client.c b/src/bluetooth-map-client.c
new file mode 100644 (file)
index 0000000..0f1bdd1
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <dlog.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <bluetooth-api.h>
+
+#include "bluetooth.h"
+#include "bluetooth_private.h"
+
+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); \
+}
+
+#define BT_CHECK_MAP_CLIENT_INIT_STATUS() \
+       if (__bt_check_map_client_init_status() == BT_ERROR_NOT_INITIALIZED) { \
+               LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \
+               return BT_ERROR_NOT_INITIALIZED; \
+       }
+
+int __bt_check_map_client_init_status(void)
+{
+       if (is_map_client_initialized != true) {
+               BT_ERR("NOT_INITIALIZED(0x%08x)", BT_ERROR_NOT_INITIALIZED);
+               return BT_ERROR_NOT_INITIALIZED;
+       }
+
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_initialize(void)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_deinitialize(void)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_set_folder(const char *name)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_update_inbox(void)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_list_folders(
+               bt_map_client_list_folders_filter_s filter,
+               bt_map_client_list_folders_cb list_folders_cb,
+               void *user_data)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_list_filter_fields(
+               bt_map_client_list_filter_fields_cb list_filter_fields_cb,
+               void *user_data)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_list_messages(
+               const char *folder,
+               bt_map_client_list_messages_filter_s filter,
+               bt_map_client_list_messages_cb list_messages_cb,
+               void *user_data)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_push_message(
+               const bt_map_client_message_s message,
+               const char *folder,
+               bt_map_client_push_message_args_s args)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}
+
+int bt_map_client_get_message(
+               const char *message_id,
+               bool attachment,
+               bt_map_client_get_message_cb get_message_cb,
+               void *user_data)
+{
+       /* TODO: MAP */
+       return BT_ERROR_NONE;
+}