Clean up codes 13/25613/1
authorWu Jiangbo <jiangbox.wu@intel.com>
Wed, 6 Aug 2014 07:52:13 +0000 (15:52 +0800)
committerWu Jiangbo <jiangbox.wu@intel.com>
Wed, 6 Aug 2014 07:52:13 +0000 (15:52 +0800)
Remove independent header file from bluez-lib.

Change-Id: I1dd196612adedb104227b2fa3b379ac6e6b13756
Signed-off-by: Wu Jiangbo <jiangbox.wu@intel.com>
capi/bluetooth.c
include/bluez.h
include/common.h
lib/bluez-hdp.c
lib/bluez.c
lib/common.c
src/media.c
test/bluez-lib-test.c

index 732f2e8..a337636 100644 (file)
@@ -502,7 +502,7 @@ static void bluez_avrcp_shuffle_changed(gboolean shuffle,
                data->cb(shuffle_mode, data->user_data);
 }
 
-static void bluez_nap_connection_changed(bool connected,
+static void bluez_nap_connection_changed(gboolean connected,
                                const char *remote_address,
                                const char *interface_name,
                                void *user_data)
@@ -529,26 +529,31 @@ static void bluez_set_data_received_changed(
                                data_node->user_data);
 }
 
-
 static void bluez_hdp_state_changed(int result,
                                const char *remote_address,
                                const char *app_id,
-                               bt_hdp_channel_type_e type,
+                               enum hdp_channel_type type,
                                unsigned int channel,
                                void *user_data)
 {
-       struct hdp_connection_changed_cb_node *data =
-                                               user_data;
+       struct hdp_connection_changed_cb_node *data = user_data;
+       bt_hdp_channel_type_e channel_type;
 
-       if (app_id != NULL) {
-               if (data->conn_cb)
-                       data->conn_cb(result, remote_address,
-                                       app_id, type, channel,
-                                       data->user_data);
-               else if (data->disconn_cb)
-                       data->disconn_cb(result, remote_address,
-                                       channel, data->user_data);
-       }
+       if (app_id == NULL)
+               return;
+
+       if (type == HDP_CHANNEL_RELIABLE)
+               channel_type = BT_HDP_CHANNEL_TYPE_RELIABLE;
+       else
+               channel_type = BT_HDP_CHANNEL_TYPE_STREAMING;
+
+       if (data->conn_cb)
+               data->conn_cb(result, remote_address, app_id,
+                               channel_type, channel, data->user_data);
+
+       if (data->disconn_cb)
+               data->disconn_cb(result, remote_address,
+                               channel, data->user_data);
 }
 
 static void bluez_avrcp_target_state_changed(const char *remote_address,
@@ -568,7 +573,7 @@ static void bluez_avrcp_target_state_changed(const char *remote_address,
 static void bluez_audio_state_changed(int result,
                                        gboolean connected,
                                        const char *remote_address,
-                                       bt_audio_profile_type_e type,
+                                       enum audio_profile_type type,
                                        void *user_data)
 {
        struct audio_connection_state_changed_cb_node *data =
@@ -4889,8 +4894,8 @@ int bt_hdp_register_sink_app(unsigned short data_type, char **app_id)
        if (default_adapter == NULL)
                return BT_ERROR_ADAPTER_NOT_FOUND;
 
-       result = bluetooth_hdp_activate(data_type,
-                       HDP_ROLE_SINK, HDP_QOS_ANY, app_id);
+       result = bluez_hdp_activate(data_type,
+                       HDP_ROLE_SINK, HDP_CHANNEL_ANY, app_id);
        return result;
 }
 
@@ -4906,7 +4911,7 @@ int bt_hdp_unregister_sink_app(const char *app_id)
        if (default_adapter == NULL)
                return BT_ERROR_ADAPTER_NOT_FOUND;
 
-       result = bluetooth_hdp_deactivate(app_id);
+       result = bluez_hdp_deactivate(app_id);
 
        return result;
 }
@@ -4924,16 +4929,14 @@ int bt_hdp_send_data(unsigned int channel, const char *data,
        if (default_adapter == NULL)
                return BT_ERROR_ADAPTER_NOT_FOUND;
 
-       result = bluetooth_hdp_send_data(channel, data, size);
+       result = bluez_hdp_send_data(channel, data, size);
 
        return result;
 }
 
-int bt_hdp_connect_to_source(const char *remote_address,
-                                               const char *app_id)
+int bt_hdp_connect_to_source(const char *remote_address, const char *app_id)
 {
        int result = BT_ERROR_NONE;
-       bluetooth_device_address_t addr_hex = { {0,} };
 
        DBG("");
 
@@ -4946,9 +4949,7 @@ int bt_hdp_connect_to_source(const char *remote_address,
        if (remote_address == NULL)
                return BT_ERROR_INVALID_PARAMETER;
 
-       convert_address_to_hex(&addr_hex, remote_address);
-
-       result = bluetooth_hdp_connect(app_id, HDP_QOS_ANY, &addr_hex);
+       result = bluez_hdp_connect(app_id, HDP_CHANNEL_ANY, remote_address);
 
        return result;
 }
@@ -4956,7 +4957,6 @@ int bt_hdp_connect_to_source(const char *remote_address,
 int bt_hdp_disconnect(const char *remote_address, unsigned int channel)
 {
        int result = BT_ERROR_NONE;
-       bluetooth_device_address_t addr_hex = { {0,} };
 
        DBG("");
 
@@ -4969,9 +4969,7 @@ int bt_hdp_disconnect(const char *remote_address, unsigned int channel)
        if (remote_address == NULL)
                return BT_ERROR_INVALID_PARAMETER;
 
-       convert_address_to_hex(&addr_hex, remote_address);
-
-       result = bluetooth_hdp_disconnect(channel, &addr_hex);
+       result = bluez_hdp_disconnect(channel, remote_address);
 
        return result;
 }
index 0a88a3b..d03589b 100644 (file)
@@ -23,8 +23,6 @@
 #include <glib.h>
 
 #include "common.h"
-#include "bluetooth.h"
-#include "bluetooth-api.h"
 
 #define BT_GENERIC_AUDIO_UUID      "00001203-0000-1000-8000-00805f9b34fb"
 
@@ -347,10 +345,16 @@ void bluez_set_data_received_changed_cb(
 
 void bluez_unset_data_received_changed_cb(struct _bluez_device *device);
 
+enum hdp_channel_type {
+       HDP_CHANNEL_RELIABLE,
+       HDP_CHANNEL_STREAMING,
+       HDP_CHANNEL_ANY
+};
+
 typedef void (*bluez_hdp_state_changed_t)(int result,
                                const char *remote_address,
                                const char *app_id,
-                               bt_hdp_channel_type_e type,
+                               enum hdp_channel_type type,
                                unsigned int channel,
                                gpointer user_data);
 
@@ -371,7 +375,7 @@ void bluez_set_avrcp_target_cb(
                                gpointer user_data);
 void bluez_unset_avrcp_target_cb();
 
-typedef void (*bluez_nap_connection_state_cb_t)(bool connected,
+typedef void (*bluez_nap_connection_state_cb_t)(gboolean connected,
                                const char *remote_address,
                                const char *interface_name,
                                gpointer user_data);
@@ -380,10 +384,14 @@ void bluez_set_nap_connection_state_cb(
                                gpointer user_data);
 void bluez_unset_nap_connection_state_cb(void);
 
+enum audio_profile_type {
+       AUDIO_TYPE_A2DP,
+};
+
 typedef void (*bluez_audio_state_cb_t)(int result,
                                gboolean connected,
                                const char *remote_address,
-                               bt_audio_profile_type_e type,
+                               enum audio_profile_type type,
                                void *user_data);
 
 void bluez_set_audio_state_cb(
@@ -579,23 +587,28 @@ int bluez_media_player_change_property(struct _bluez_adapter *adapter,
 int bluez_media_player_set_properties(struct _bluez_adapter *adapter,
                                media_player_settings_t *properties);
 
-int bluetooth_hdp_activate(unsigned short data_type,
-                                       bt_hdp_role_type_t role,
-                                       bt_hdp_qos_type_t channel_type,
-                                       char **app_handle);
+enum hdp_role_type {
+       HDP_ROLE_SOURCE,
+       HDP_ROLE_SINK
+};
+
+int bluez_hdp_activate(unsigned short data_type,
+                               enum hdp_role_type role,
+                               enum hdp_channel_type channel_type,
+                               char **app_handle);
 
-int bluetooth_hdp_deactivate(const char *app_handle);
+int bluez_hdp_deactivate(const char *app_handle);
 
-int bluetooth_hdp_send_data(unsigned int channel_id,
-                                       const char *buffer,
-                                       unsigned int size);
+int bluez_hdp_send_data(unsigned int channel_id,
+                               const char *buffer,
+                               unsigned int size);
 
-int bluetooth_hdp_connect(const char *app_handle,
-                       bt_hdp_qos_type_t channel_type,
-                       const bluetooth_device_address_t *device_address);
+int bluez_hdp_connect(const char *app_handle,
+                               enum hdp_channel_type channel_type,
+                               const char *device_address);
 
-int bluetooth_hdp_disconnect(unsigned int channel_id,
-                       const bluetooth_device_address_t *device_address);
+int bluez_hdp_disconnect(unsigned int channel_id,
+                               const char *device_address);
 
 void hdp_internal_handle_disconnect(gpointer user_data,
                                                GVariant *param);
index c68e5bb..f7fbfcb 100644 (file)
@@ -23,7 +23,6 @@
 #include <stdio.h>
 
 #include <gio/gio.h>
-#include "bluetooth-api.h"
 
 #ifndef TIZEN
 #define DBG(fmt, arg...) printf("%s:%d %s()" fmt "\n", __FILE__, __LINE__, __func__, ## arg)
@@ -123,18 +122,9 @@ void comms_service_plugin_cleanup(void);
 void convert_device_path_to_address(const gchar *device_path,
                                        gchar *device_address);
 
-void convert_address_to_hex(bluetooth_device_address_t *addr_hex,
-                                       const char *addr_str);
-
-void convert_addr_type_to_string(char *address,
-                                       unsigned char *addr);
-
 void device_path_to_address(const char *device_path,
                                        char *device_address);
 
-void convert_addr_string_to_type(unsigned char *addr,
-                                       const char *address);
-
 GDBusConnection *get_system_lib_dbus_connect(void);
 
 #endif
index 9d4a21e..07b8dce 100644 (file)
@@ -17,6 +17,18 @@ typedef struct {
        GSList *obj_info;
 } hdp_app_list_t;
 
+struct bluez_hdp_connected_t {
+       const char *app_handle;
+       unsigned int channel_id;
+       enum hdp_channel_type type;
+       char *device_address;
+};
+
+struct bluez_hdp_disconnect_t {
+       unsigned int channel_id;
+       char *device_address;
+};
+
 #define HDP_BUFFER_SIZE 1024
 
 struct _bluez_device {
@@ -152,9 +164,8 @@ static void hdp_internal_handle_disconnect_cb(int sk, const char *path)
        device_path_to_address(path, address);
 
        if (device->hdp_state_changed_cb)
-               device->hdp_state_changed_cb(BLUETOOTH_ERROR_NONE,
-                               address, NULL, 0, sk,
-                               device->hdp_state_changed_cb_data);
+               device->hdp_state_changed_cb(0, address, NULL, 0, sk,
+                                       device->hdp_state_changed_cb_data);
 
        DBG(" Removed connection from list\n");
 
@@ -176,11 +187,11 @@ static gboolean hdp_internal_data_received(GIOChannel *gio,
 
        adapter = bluez_adapter_get_adapter(DEFAULT_ADAPTER_NAME);
        if (adapter == NULL)
-               return BT_ERROR_OPERATION_FAILED;
+               return FALSE;
 
        device = bluez_adapter_get_device_by_path(adapter, path);
        if (device == NULL)
-               return BT_ERROR_OPERATION_FAILED;
+               return FALSE;
 
        sk = g_io_channel_unix_get_fd(gio);
 
@@ -232,7 +243,7 @@ static int hdp_internal_acquire_fd(struct _bluez_device *device,
        char *device_name = NULL;
        char *app_handle = NULL;
        hdp_app_list_t *list = NULL;
-       bt_hdp_channel_type_e type = HDP_QOS_RELIABLE;
+       enum hdp_channel_type type = HDP_CHANNEL_RELIABLE;
        hdp_obj_info_t *info;
        gint fd = 0;
        GVariant *val;
@@ -247,7 +258,7 @@ static int hdp_internal_acquire_fd(struct _bluez_device *device,
 
        conn = get_system_lib_dbus_connect();
        if (conn == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -261,7 +272,7 @@ static int hdp_internal_acquire_fd(struct _bluez_device *device,
        if (msg_reply && g_dbus_message_get_message_type(msg_reply)
                                == G_DBUS_MESSAGE_TYPE_ERROR) {
                DBG(" HDP:****** dbus Can't create application ****");
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -270,7 +281,7 @@ static int hdp_internal_acquire_fd(struct _bluez_device *device,
 
        if (fd == 0) {
                DBG("HDP:dbus Can't get reply arguments");
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -285,7 +296,7 @@ static int hdp_internal_acquire_fd(struct _bluez_device *device,
                DBG(" HDP:dbus Can't get the reply");
                DBG("error %s", error->message);
                g_error_free(error);
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -315,18 +326,18 @@ static int hdp_internal_acquire_fd(struct _bluez_device *device,
 
        if (NULL == type_qos || NULL == app_handle) {
                DBG("Pasing failed\n");
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
        type = (g_strcmp0(type_qos, "Reliable") == 0) ?
-               HDP_QOS_RELIABLE : HDP_QOS_STREAMING;
+               HDP_CHANNEL_RELIABLE : HDP_CHANNEL_STREAMING;
 
        list = hdp_internal_gslist_find_app_handler((void *)app_handle);
 
        if (NULL == list) {
                DBG("**** Could not locate the list for %s*****\n", app_handle);
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -341,26 +352,20 @@ static int hdp_internal_acquire_fd(struct _bluez_device *device,
 
        DBG("Going to give callback\n");
 
-       if (device)
-               if (device->hdp_state_changed_cb)
-                       device->hdp_state_changed_cb(
-                               BLUETOOTH_ERROR_NONE,
-                               address, app_handle, type, fd,
-                               device->hdp_state_changed_cb_data);
+       if (device && device->hdp_state_changed_cb)
+               device->hdp_state_changed_cb(0, address, app_handle, type, fd,
+                                       device->hdp_state_changed_cb_data);
 
        DBG("Updated fd in the list*\n");
        DBG("-\n");
 
-       ret = BT_ERROR_NONE;
+       ret = 0;
 done:
        DBG("error");
 
-       if (device)
-               if (device->hdp_state_changed_cb)
-                       device->hdp_state_changed_cb(
-                               BLUETOOTH_ERROR_CONNECTION_ERROR,
-                               address, app_handle, type, fd,
-                               device->hdp_state_changed_cb_data);
+       if (device && device->hdp_state_changed_cb)
+               device->hdp_state_changed_cb(-1, address, app_handle, type, fd,
+                                       device->hdp_state_changed_cb_data);
 
        return ret;
 }
@@ -417,8 +422,8 @@ void hdp_internal_handle_disconnect(gpointer user_data,
        device_path_to_address(device->object_path, address);
 
        if (device->hdp_state_changed_cb)
-               device->hdp_state_changed_cb(BLUETOOTH_ERROR_NONE, address,
-                       NULL, 0, info->fd, device->hdp_state_changed_cb_data);
+               device->hdp_state_changed_cb(0, address, NULL, 0, info->fd,
+                                       device->hdp_state_changed_cb_data);
 
        DBG(" Removed connection from list\n");
 
@@ -427,7 +432,7 @@ void hdp_internal_handle_disconnect(gpointer user_data,
 
 static int hdp_internal_create_application(unsigned int data_type,
                                        int role,
-                                       bt_hdp_qos_type_t channel_type,
+                                       enum hdp_channel_type channel_type,
                                        char **app_handle)
 {
        GVariantBuilder *opts;
@@ -442,7 +447,7 @@ static int hdp_internal_create_application(unsigned int data_type,
 
        connection = get_system_lib_dbus_connect();
        if (connection == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -460,9 +465,9 @@ static int hdp_internal_create_application(unsigned int data_type,
                                g_variant_new("s", "Health Device"));
 
        if (role == HDP_ROLE_SOURCE) {
-               if (channel_type == HDP_QOS_RELIABLE)
+               if (channel_type == HDP_CHANNEL_RELIABLE)
                        svalue = "Reliable";
-               else if (channel_type == HDP_QOS_STREAMING)
+               else if (channel_type == HDP_CHANNEL_STREAMING)
                        svalue = "Streaming";
                else
                        svalue = "";
@@ -482,7 +487,7 @@ static int hdp_internal_create_application(unsigned int data_type,
        if (error) {
                DBG("error %s", error->message);
                g_error_free(error);
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -496,23 +501,23 @@ static int hdp_internal_create_application(unsigned int data_type,
 
        g_app_list = g_slist_append(g_app_list, list);
 
-       ret = BT_ERROR_NONE;
+       ret = 0;
 done:
        return ret;
 }
 
-int bluetooth_hdp_activate(unsigned short data_type,
-                                       bt_hdp_role_type_t role,
-                                       bt_hdp_qos_type_t channel_type,
+int bluez_hdp_activate(unsigned short data_type,
+                                       enum hdp_role_type role,
+                                       enum hdp_channel_type channel_type,
                                        char **app_handle)
 {
-       int result = BT_ERROR_NONE;
+       int result = 0;
 
        DBG("");
 
-       if (role == HDP_ROLE_SOURCE && channel_type == HDP_QOS_ANY) {
+       if (role == HDP_ROLE_SOURCE && channel_type == HDP_CHANNEL_ANY) {
                DBG("For source, type is mandatory - Reliable/Streaming");
-               return BT_ERROR_INVALID_PARAMETER;
+               return -1;
        }
 
        result = hdp_internal_create_application(data_type, role,
@@ -613,7 +618,7 @@ static int hdp_internal_destroy_application(const char *app_handle)
 
        connection = get_system_lib_dbus_connect();
        if (connection == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -628,7 +633,7 @@ static int hdp_internal_destroy_application(const char *app_handle)
        if (error) {
                DBG("error %s", error->message);
                g_error_free(error);
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -637,17 +642,17 @@ static int hdp_internal_destroy_application(const char *app_handle)
        g_idle_add(hdp_internal_destroy_application_cb,
                                        (gpointer)app_handle);
 
-       ret = BT_ERROR_NONE;
+       ret = 0;
 done:
        return ret;
 }
 
-int bluetooth_hdp_deactivate(const char *app_handle)
+int bluez_hdp_deactivate(const char *app_handle)
 {
        return hdp_internal_destroy_application(app_handle);
 }
 
-int bluetooth_hdp_send_data(unsigned int channel_id,
+int bluez_hdp_send_data(unsigned int channel_id,
                                        const char *buffer,
                                        unsigned int size)
 {
@@ -658,20 +663,20 @@ int bluetooth_hdp_send_data(unsigned int channel_id,
 
        if ((channel_id == 0) || (NULL == buffer) || (size == 0)) {
                DBG("Invalid arguments..\n");
-               return BT_ERROR_INVALID_PARAMETER;
+               return -1;
        } else {
                while (wbytes < size) {
                        written = write(channel_id, buffer + wbytes,
                                                size - wbytes);
                        if (written <= 0) {
                                DBG("write failed..\n");
-                               return BT_ERROR_OPERATION_FAILED;
+                               return -1;
                        }
                        wbytes += written;
                }
        }
 
-       return BT_ERROR_NONE;
+       return 0;
 }
 
 static void hdp_connect_request_cb(GObject *source_object,
@@ -681,17 +686,14 @@ static void hdp_connect_request_cb(GObject *source_object,
        GVariant *result;
        char *obj_connect_path;
        GDBusConnection *conn;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       bt_hdp_connected_t *conn_ind = user_data;
+       struct bluez_hdp_connected_t *conn_ind = user_data;
        bluez_adapter_t *adapter = NULL;
        struct _bluez_device *device = NULL;
 
        conn = get_system_lib_dbus_connect();
        if (conn == NULL)
                goto done;
-       result = g_dbus_connection_call_finish(conn,
-                                                       res,
-                                                       &error);
+       result = g_dbus_connection_call_finish(conn, res, &error);
        if (error) {
                DBG("HDP connection  Dbus Call Error: %s\n", error->message);
                g_error_free(error);
@@ -700,19 +702,15 @@ static void hdp_connect_request_cb(GObject *source_object,
                if (adapter == NULL)
                        goto done;
 
-               convert_addr_type_to_string(address,
-                       (unsigned char *)conn_ind->device_address.addr);
-
                device = bluez_adapter_get_device_by_address(adapter,
-                                                               address);
+                                               conn_ind->device_address);
                if (device == NULL)
                        goto done;
 
                if (device->hdp_state_changed_cb)
-                       device->hdp_state_changed_cb(
-                               BLUETOOTH_ERROR_CONNECTION_ERROR,
-                               address, conn_ind->app_handle,
-                               conn_ind->type, 0,
+                       device->hdp_state_changed_cb(-1,
+                               conn_ind->device_address,
+                               conn_ind->app_handle, conn_ind->type, 0,
                                device->hdp_state_changed_cb_data);
        } else {
                g_variant_get(result, "(o)", &obj_connect_path);
@@ -724,12 +722,10 @@ done:
        g_free(conn_ind);
 }
 
-int bluetooth_hdp_connect(const char *app_handle,
-                       bt_hdp_qos_type_t channel_type,
-                       const bluetooth_device_address_t *device_address)
+int bluez_hdp_connect(const char *app_handle,
+               enum hdp_channel_type channel_type, const char *device_address)
 {
-       bt_hdp_connected_t *param;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       struct bluez_hdp_connected_t *param;
        char *dev_path = NULL;
        char *role;
        bluez_adapter_t *adapter = NULL;
@@ -741,36 +737,33 @@ int bluetooth_hdp_connect(const char *app_handle,
        adapter = bluez_adapter_get_adapter(DEFAULT_ADAPTER_NAME);
 
        if (adapter == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
-       if (channel_type == HDP_QOS_RELIABLE) {
+       if (channel_type == HDP_CHANNEL_RELIABLE) {
                role = "Reliable";
-       } else if (channel_type == HDP_QOS_STREAMING) {
+       } else if (channel_type == HDP_CHANNEL_STREAMING) {
                role = "Streaming";
-       } else if (channel_type == HDP_QOS_ANY) {
+       } else if (channel_type == HDP_CHANNEL_ANY) {
                role = "Any";
        } else {
                DBG("Invalid channel_type %d", channel_type);
-               return BT_ERROR_INVALID_PARAMETER;
+               return -1;
        }
 
        conn = get_system_lib_dbus_connect();
        if (conn == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
-       convert_addr_type_to_string(address,
-                       (unsigned char *)device_address->addr);
-
-       DBG("create conection to %s", address);
+       DBG("create conection to %s", device_address);
 
        dev_path = g_strdup_printf("/org/bluez/%s/dev_%s",
-                                       DEFAULT_ADAPTER_NAME, address);
+                               DEFAULT_ADAPTER_NAME, device_address);
        if (dev_path == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -778,10 +771,9 @@ int bluetooth_hdp_connect(const char *app_handle,
 
        DBG("path: %s", dev_path);
 
-       param = g_new0(bt_hdp_connected_t, 1);
+       param = g_new0(struct bluez_hdp_connected_t, 1);
        param->app_handle = g_strdup(app_handle);
-       memcpy(&param->device_address, device_address,
-                                       BLUETOOTH_ADDRESS_LENGTH);
+       param->device_address = g_strdup(device_address);
        param->type = channel_type;
 
        g_dbus_connection_call(conn, BLUEZ_NAME,
@@ -794,7 +786,7 @@ int bluetooth_hdp_connect(const char *app_handle,
 
        g_free(dev_path);
 
-       ret = BT_ERROR_NONE;
+       ret = 0;
 done:
        return ret;
 }
@@ -802,8 +794,7 @@ done:
 static void hdp_disconnect_request_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data)
 {
-       bt_hdp_disconnected_t *disconn_ind = user_data;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       struct bluez_hdp_connected_t *disconn_ind = user_data;
        GError *error;
        GDBusConnection *conn;
        bluez_adapter_t *adapter = NULL;
@@ -823,17 +814,14 @@ static void hdp_disconnect_request_cb(GObject *source_object,
                if (adapter == NULL)
                        goto done;
 
-               convert_addr_type_to_string(address,
-                       (unsigned char *)disconn_ind->device_address.addr);
                device = bluez_adapter_get_device_by_address(adapter,
-                                                               address);
+                                               disconn_ind->device_address);
                if (device == NULL)
                        goto done;
 
                if (device->hdp_state_changed_cb)
-                       device->hdp_state_changed_cb(
-                                       BLUETOOTH_ERROR_CONNECTION_ERROR,
-                                       address, NULL,
+                       device->hdp_state_changed_cb(-1,
+                                       disconn_ind->device_address, NULL,
                                        0, disconn_ind->channel_id,
                                        device->hdp_state_changed_cb_data);
        } else {
@@ -844,11 +832,9 @@ done:
        g_free(disconn_ind);
 }
 
-int bluetooth_hdp_disconnect(unsigned int channel_id,
-               const bluetooth_device_address_t *device_address)
+int bluez_hdp_disconnect(unsigned int channel_id, const char *device_address)
 {
-       bt_hdp_disconnected_t *param;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       struct bluez_hdp_connected_t *param;
        char *dev_path = NULL;
        bluez_adapter_t *adapter = NULL;
        GDBusConnection *conn;
@@ -860,32 +846,29 @@ int bluetooth_hdp_disconnect(unsigned int channel_id,
        adapter = bluez_adapter_get_adapter(DEFAULT_ADAPTER_NAME);
 
        if (adapter == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
        info = hdp_internal_gslist_obj_find_using_fd(channel_id);
        if (NULL == info) {
                DBG("*** Could not locate the list for %d*****\n", channel_id);
-               ret = BT_ERROR_INVALID_PARAMETER;
+               ret = -1;
                goto done;
        }
 
        conn = get_system_lib_dbus_connect();
        if (conn == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
-       convert_addr_type_to_string(address,
-               (unsigned char *)device_address->addr);
-
-       DBG("create conection to %s", address);
+       DBG("create conection to %s", device_address);
 
        dev_path = g_strdup_printf("/org/bluez/%s/dev_%s",
-                                       DEFAULT_ADAPTER_NAME, address);
+                               DEFAULT_ADAPTER_NAME, device_address);
        if (dev_path == NULL) {
-               ret = BT_ERROR_OPERATION_FAILED;
+               ret = -1;
                goto done;
        }
 
@@ -893,10 +876,9 @@ int bluetooth_hdp_disconnect(unsigned int channel_id,
 
        DBG("path: %s", dev_path);
 
-       param = g_new0(bt_hdp_disconnected_t, 1);
+       param = g_new0(struct bluez_hdp_connected_t, 1);
        param->channel_id = channel_id;
-       memcpy(&param->device_address, device_address,
-                                       BLUETOOTH_ADDRESS_LENGTH);
+       param->device_address = g_strdup(device_address);
 
        g_dbus_connection_call(conn, BLUEZ_NAME,
                                dev_path,
@@ -908,7 +890,7 @@ int bluetooth_hdp_disconnect(unsigned int channel_id,
 
        g_free(dev_path);
 
-       ret = BT_ERROR_NONE;
+       ret = 0;
 done:
        return ret;
 }
index b0b8661..b6190b9 100644 (file)
@@ -74,7 +74,7 @@ static struct player_settinngs_t shuffle_settings[] = {
 
 struct _bluez_object {
        char *path_name;
-       bt_audio_profile_type_e media_type;
+       enum audio_profile_type media_type;
        GDBusObject *obj;
        GList *interfaces;
        GDBusProxy *properties_proxy;
@@ -375,9 +375,9 @@ static void networkserver_on_signal(GDBusProxy *proxy,
        DBG("sender_name = %s, signal_name = %s",
                                sender_name, signal_name);
        if (strcasecmp(signal_name, "PeerConnected"))
-               connected = true;
+               connected = TRUE;
        else if (strcasecmp(signal_name, "PeerDisconnected"))
-               connected = false;
+               connected = FALSE;
        else
                return;
 
@@ -995,7 +995,7 @@ static void parse_bluez_control_interfaces(gpointer data, gpointer user_data)
        if (g_strcmp0(iface_name, MEDIATRANSPORT_INTERFACE) == 0) {
                gchar *uuid, *device_address;
                gchar *device_path;
-               bt_audio_profile_type_e type;
+               enum audio_profile_type type;
 
                path = g_dbus_proxy_get_object_path(proxy);
 
@@ -1032,7 +1032,7 @@ static void parse_bluez_control_interfaces(gpointer data, gpointer user_data)
                DBG("uuid = %s", uuid);
 
                if (g_strcmp0(uuid, BT_A2DP_SINK_UUID) == 0) {
-                       type = BT_AUDIO_PROFILE_TYPE_A2DP;
+                       type = AUDIO_TYPE_A2DP;
                        object->media_type = type;
                }
 
@@ -3634,8 +3634,7 @@ static gboolean bluez_set_metadata(struct _bluez_adapter *adapter,
 }
 
 static int bluez_avrcp_set_interal_property(struct _bluez_adapter *adapter,
-                       int type,
-                       media_player_settings_t *properties)
+                               int type, media_player_settings_t *properties)
 {
        int value;
        gboolean shuffle;
@@ -3651,7 +3650,7 @@ static int bluez_avrcp_set_interal_property(struct _bluez_adapter *adapter,
                val = g_variant_new("s", loopstatus_settings[value].property);
                if (!bluez_set_property(adapter, "LoopStatus", val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
                break;
        case SHUFFLE:
@@ -3663,7 +3662,7 @@ static int bluez_avrcp_set_interal_property(struct _bluez_adapter *adapter,
                val = g_variant_new("b", shuffle);
                if (!bluez_set_property(adapter, "Shuffle", val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
                break;
        case PLAYBACKSTATUS:
@@ -3671,7 +3670,7 @@ static int bluez_avrcp_set_interal_property(struct _bluez_adapter *adapter,
                val = g_variant_new("s", playback_status[value].property);
                if (!bluez_set_property(adapter, "PlaybackStatus", val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
                break;
        case POSITION:
@@ -3679,15 +3678,15 @@ static int bluez_avrcp_set_interal_property(struct _bluez_adapter *adapter,
                val = g_variant_new("x", value);
                if (!bluez_set_property(adapter, "Position", val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
                break;
        default:
                DBG("Invalid Type\n");
-               return BT_ERROR_INVALID_PARAMETER;
+               return -1;
        }
 
-       return BT_SUCCESS;
+       return -1;
 }
 
 int bluez_media_player_set_track_info(struct _bluez_adapter *adapter,
@@ -3703,7 +3702,7 @@ int bluez_media_player_set_track_info(struct _bluez_adapter *adapter,
                val = g_variant_new("s", meta_data->title);
                if (!bluez_set_metadata(adapter, "xesam:title", val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
        }
 
@@ -3716,7 +3715,7 @@ int bluez_media_player_set_track_info(struct _bluez_adapter *adapter,
                if (!bluez_set_metadata(adapter, "xesam:artist",
                                                        val_array)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
        }
 
@@ -3724,7 +3723,7 @@ int bluez_media_player_set_track_info(struct _bluez_adapter *adapter,
                val = g_variant_new("s", meta_data->album);
                if (!bluez_set_metadata(adapter, "xesam:album", val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
        }
 
@@ -3737,7 +3736,7 @@ int bluez_media_player_set_track_info(struct _bluez_adapter *adapter,
                if (!bluez_set_metadata(adapter, "xesam:genre",
                                                        val_array)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
        }
 
@@ -3746,7 +3745,7 @@ int bluez_media_player_set_track_info(struct _bluez_adapter *adapter,
                if (!bluez_set_metadata(adapter, "xesam:trackNumber",
                                                                val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
        }
 
@@ -3754,11 +3753,11 @@ int bluez_media_player_set_track_info(struct _bluez_adapter *adapter,
                val = g_variant_new("x", meta_data->duration);
                if (!bluez_set_metadata(adapter, "mpris:length", val)) {
                        DBG("Error sending the PropertyChanged signal\n");
-                       return BT_ERROR_OPERATION_FAILED;
+                       return -1;
                }
        }
 
-       return BT_SUCCESS;
+       return -1;
 }
 
 int bluez_media_player_change_property(struct _bluez_adapter *adapter,
@@ -3785,7 +3784,7 @@ int bluez_media_player_change_property(struct _bluez_adapter *adapter,
                break;
        default:
                DBG("Invalid Type\n");
-               return BT_ERROR_INVALID_PARAMETER;
+               return -1;
        }
 
        ret = bluez_avrcp_set_interal_property(adapter,
@@ -3800,27 +3799,22 @@ int bluez_media_player_set_properties(struct _bluez_adapter *adapter,
 {
 
        if (bluez_avrcp_set_interal_property(adapter,
-               LOOPSTATUS, properties) != 1) {
-               return BT_ERROR_OPERATION_FAILED;
-       }
+                               LOOPSTATUS, properties) != 1)
+               return -1;
 
        if (bluez_avrcp_set_interal_property(adapter,
-               SHUFFLE, properties) != 1) {
-               return BT_ERROR_OPERATION_FAILED;
-       }
+                               SHUFFLE, properties) != 1)
+               return -1;
 
        if (bluez_avrcp_set_interal_property(adapter,
-               PLAYBACKSTATUS,
-                       properties) != 1) {
-               return BT_ERROR_OPERATION_FAILED;
-       }
+                               PLAYBACKSTATUS, properties) != 1)
+               return -1;
 
        if (bluez_avrcp_set_interal_property(adapter,
-               POSITION, properties) != 1) {
-               return BT_ERROR_OPERATION_FAILED;
-       }
+                               POSITION, properties) != 1)
+               return -1;
 
-       return BT_SUCCESS;
+       return 0;
 }
 
 static void bluez_device_connect_cb(GObject *source_object,
@@ -3953,7 +3947,7 @@ gboolean bluez_get_media_type(const char *remote_address)
        struct _bluez_object *object;
        GList *list, *next;
        int length;
-       gboolean is_type = false;
+       gboolean is_type = FALSE;
        gchar device_address[BT_ADDRESS_STRING_SIZE];
 
        DBG("");
@@ -3961,7 +3955,7 @@ gboolean bluez_get_media_type(const char *remote_address)
        length = g_list_length(bluez_object_list);
 
        if (length == 0)
-               return false;
+               return FALSE;
 
        for (list = g_list_first(bluez_object_list); list; list = next) {
                next = g_list_next(list);
@@ -3971,8 +3965,8 @@ gboolean bluez_get_media_type(const char *remote_address)
                                                (gchar *)device_address);
 
                if (!g_strcmp0(remote_address, device_address) &&
-                       object->media_type == BT_AUDIO_PROFILE_TYPE_A2DP) {
-                       is_type = true;
+                       object->media_type == AUDIO_TYPE_A2DP) {
+                       is_type = TRUE;
                        break;
                }
        }
index 58e96a1..9da37f7 100644 (file)
@@ -323,37 +323,6 @@ done:
        g_free(reply_data);
 }
 
-void convert_address_to_hex(bluetooth_device_address_t *addr_hex,
-                                                       const char *addr_str)
-{
-       int i = 0;
-       unsigned int addr[BLUETOOTH_ADDRESS_LENGTH] = { 0, };
-
-       if (addr_str == NULL)
-               return;
-
-       i = sscanf(addr_str, "%X:%X:%X:%X:%X:%X", &addr[0], &addr[1],
-                               &addr[2], &addr[3], &addr[4], &addr[5]);
-
-       if (i != BLUETOOTH_ADDRESS_LENGTH)
-               DBG("Invalid format string - %s", addr_str);
-
-       for (i = 0; i < BLUETOOTH_ADDRESS_LENGTH; i++)
-               addr_hex->addr[i] = (unsigned char)addr[i];
-}
-
-void convert_addr_type_to_string(char *address,
-                                       unsigned char *addr)
-{
-       if (address == NULL && addr == NULL)
-               return;
-
-       snprintf(address, BLUETOOTH_ADDRESS_LENGTH,
-                       "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
-                       addr[0], addr[1], addr[2],
-                       addr[3], addr[4], addr[5]);
-}
-
 void device_path_to_address(const char *device_path, char *device_address)
 {
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
@@ -375,26 +344,6 @@ void device_path_to_address(const char *device_path, char *device_address)
        }
 }
 
-void convert_addr_string_to_type(unsigned char *addr,
-                                               const char *address)
-{
-       int i;
-       char *ptr = NULL;
-
-       if (address == NULL || addr == NULL)
-               return;
-
-       for (i = 0; i < BLUETOOTH_ADDRESS_LENGTH; i++) {
-               addr[i] = strtol(address, &ptr, 16);
-               if (ptr != NULL) {
-                       if (ptr[0] != ':')
-                               return;
-
-                       address = ptr + 1;
-               }
-       }
-}
-
 GDBusConnection *get_system_lib_dbus_connect(void)
 {
        GError *error = NULL;
index 24a6540..90f8e0e 100644 (file)
@@ -397,7 +397,7 @@ static gboolean handle_set_property(GDBusConnection *connection,
 
        if (relay_agent == NULL) {
                DBG("relay_agent == NULL");
-               return false;
+               return FALSE;
        }
 
        if (g_strcmp0(property_name, "LoopStatus") == 0) {
index 5d84429..c9c25f1 100644 (file)
@@ -491,8 +491,8 @@ static int hdp_activate(void *parameter)
 
        DBG("");
 
-       result = bluetooth_hdp_activate(1,
-               HDP_ROLE_SINK, HDP_QOS_ANY, &app_id);
+       result = bluez_hdp_activate(1,
+               HDP_ROLE_SINK, HDP_CHANNEL_ANY, &app_id);
 
        DBG("result = %d app_id = %s", result, app_id);
 
@@ -505,7 +505,7 @@ static int hdp_deactivate(void *parameter)
 
        DBG("app_id = %s", app_id);
 
-       result = bluetooth_hdp_deactivate((const char *)(app_id));
+       result = bluez_hdp_deactivate((const char *)(app_id));
 
        DBG("result = %d", result);