/*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2011 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
+ * 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,
#include <sys/types.h>
#include <sys/socket.h>
-#include <dbus/dbus.h>
+#include <gio/gio.h>
+#include <glib.h>
#include <string.h>
+#include <gio/gunixfdlist.h>
#include "bluetooth-api.h"
#include "bt-common.h"
#include "bt-internal-types.h"
#define HDP_BUFFER_SIZE 1024
-#define BLUEZ_HDP_MANAGER_INTERFACE "org.bluez.HealthManager"
-#define BLUEZ_HDP_DEVICE_INTERFACE "org.bluez.HealthDevice"
-#define BLUEZ_HDP_CHANNEL_INTERFACE "org.bluez.HealthChannel"
+#define BLUEZ_HDP_MANAGER_INTERFACE "org.bluez.HealthManager1"
+#define BLUEZ_HDP_DEVICE_INTERFACE "org.bluez.HealthDevice1"
+#define BLUEZ_HDP_CHANNEL_INTERFACE "org.bluez.HealthChannel1"
typedef struct {
char *obj_channel_path;
int fd;
+ guint watch_id;
} hdp_obj_info_t;
typedef struct {
GSList *obj_info;
} hdp_app_list_t;
+/* Variable for privilege, only for write API,
+ before we should reduce time to bt-service dbus calling
+ -1 : Don't have a permission to access API
+ 0 : Initial value, not yet check
+ 1 : Have a permission to access API
+*/
+static int privilege_token;
+
/**********************************************************************
* Static Functions declaration *
bt_hdp_qos_type_t channel_type,
char **app_handle);
-static DBusHandlerResult __bt_hdp_internal_event_filter(DBusConnection *sys_conn,
- DBusMessage *msg,
- void *data);
+static void __bt_hdp_internal_event_filter(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data);
-static void __bt_hdp_internal_handle_connect(DBusMessage *msg);
+static void __bt_hdp_internal_handle_connect(GVariant *parameters);
-static void __bt_hdp_internal_handle_disconnect(DBusMessage *msg);
+static void __bt_hdp_internal_handle_disconnect(GVariant *parameters,
+ const gchar *object_path);
-static void __bt_hdp_internal_handle_property_changed(DBusMessage *msg);
+static void __bt_hdp_internal_handle_property_changed(GVariant *parameters);
static int __bt_hdp_internal_add_filter(void);
static int __bt_hdp_internal_acquire_fd(const char *path);
-static void __bt_hdp_internal_watch_fd(int file_desc, const char *path);
+static guint __bt_hdp_internal_watch_fd(int file_desc, const char *path);
static gboolean __bt_hdp_internal_data_received(GIOChannel *gio,
GIOCondition cond,
static hdp_obj_info_t *__bt_hdp_internal_gslist_obj_find_using_path(const char *obj_channel_path);
/*Global Variables*/
-static DBusConnection *g_hdp_dus_conn;
+static GDBusConnection *g_hdp_dus_conn;
static GSList *g_app_list = NULL;
/*For source role is mandatory */
if (role == HDP_ROLE_SOURCE && channel_type == HDP_QOS_ANY) {
- BT_DBG("For source, type is mandatory - Reliable/Streaming");
+ BT_ERR("For source, type is mandatory - Reliable/Streaming");
return BLUETOOTH_ERROR_INVALID_PARAM;
}
static void __bt_hdp_obj_info_free(hdp_obj_info_t *info)
{
if (info) {
+ g_source_remove(info->watch_id);
close(info->fd);
g_free(info->obj_channel_path);
g_free(info);
bt_hdp_qos_type_t channel_type,
char **app_handle)
{
- DBusMessage *msg;
- DBusMessage *reply;
+ GDBusProxy *proxy = NULL;
+ GVariant *reply = NULL;
+ GVariantBuilder *builder;
const char *svalue;
const char *key_type;
char *app_path;
hdp_app_list_t *list;
- DBusError err;
- DBusMessageIter iter;
- DBusMessageIter array_iter;
- DBusMessageIter entry;
- DBusMessageIter variant;
+ GError *err = NULL;
guint16 value;
- DBusConnection *conn;
+ GDBusConnection *conn;
int ret = BLUETOOTH_ERROR_NONE;
BT_DBG("+");
- conn = _bt_get_system_conn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- msg = dbus_message_new_method_call(BT_BLUEZ_NAME, "/org/bluez",
- BLUEZ_HDP_MANAGER_INTERFACE,
- "CreateApplication");
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ BT_BLUEZ_NAME,
+ "/org/bluez",
+ BLUEZ_HDP_MANAGER_INTERFACE,
+ NULL, &err);
- retv_if(msg == NULL, BLUETOOTH_ERROR_NO_RESOURCES);
+ if (!proxy) {
+ BT_ERR("Unable to create proxy: %s", err->message);
+ g_clear_error(&err);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
- dbus_message_iter_init_append(msg, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING
- DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
- &array_iter);
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
key_type = "DataType";
value = (guint16) data_type;
- dbus_message_iter_open_container(&array_iter, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key_type);
- dbus_message_iter_open_container(&entry,
- DBUS_TYPE_VARIANT, DBUS_TYPE_UINT16_AS_STRING, &variant);
- dbus_message_iter_append_basic(&variant, DBUS_TYPE_UINT16, &value);
- dbus_message_iter_close_container(&entry, &variant);
- dbus_message_iter_close_container(&array_iter, &entry);
+ g_variant_builder_add(builder, "{sv}",
+ key_type, g_variant_new("q",
+ value));
key_type = "Role";
-
/*0-Source,1-Sink*/
svalue = (role == HDP_ROLE_SINK) ? "Sink" : "Source";
- dbus_message_iter_open_container(&array_iter, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key_type);
- dbus_message_iter_open_container(&entry,
- DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &variant);
- dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &svalue);
- dbus_message_iter_close_container(&entry, &variant);
- dbus_message_iter_close_container(&array_iter, &entry);
+ g_variant_builder_add(builder, "{sv}",
+ key_type, g_variant_new("s",
+ svalue));
key_type = "Description";
svalue = "Health Device";
- dbus_message_iter_open_container(&array_iter, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key_type);
- dbus_message_iter_open_container(&entry,
- DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &variant);
- dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &svalue);
- dbus_message_iter_close_container(&entry, &variant);
- dbus_message_iter_close_container(&array_iter, &entry);
+ g_variant_builder_add(builder, "{sv}",
+ key_type, g_variant_new("s",
+ svalue));
if (role == HDP_ROLE_SOURCE) {
key_type = "ChannelType";
if (channel_type == HDP_QOS_RELIABLE)
- svalue = "Reliable";
+ svalue = "reliable";
else if (channel_type == HDP_QOS_STREAMING)
- svalue = "Streaming";
-
- dbus_message_iter_open_container(&array_iter,
- DBUS_TYPE_DICT_ENTRY, NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
- &key_type);
- dbus_message_iter_open_container(&entry,
- DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING,
- &variant);
- dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING,
- &svalue);
- dbus_message_iter_close_container(&entry, &variant);
- dbus_message_iter_close_container(&array_iter, &entry);
- }
+ svalue = "streaming";
- dbus_message_iter_close_container(&iter, &array_iter);
+ g_variant_builder_add(builder, "{sv}",
+ key_type, g_variant_new("s",
+ svalue));
+ }
- dbus_error_init(&err);
+ reply = g_dbus_proxy_call_sync(proxy, "CreateApplication",
+ g_variant_new("(a{sv})", builder),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, &err);
- reply = dbus_connection_send_with_reply_and_block(
- conn, msg,
- -1, &err);
- dbus_message_unref(msg);
+ g_variant_builder_unref(builder);
+ g_object_unref(proxy);
if (!reply) {
BT_ERR(" HDP:dbus Can't create application");
-
- if (dbus_error_is_set(&err)) {
- BT_ERR("%s", err.message);
- dbus_error_free(&err);
+ if (err) {
+ BT_ERR("%s", err->message);
+ if (g_strrstr(err->message, BT_ACCESS_DENIED_MSG))
+ ret = BLUETOOTH_ERROR_ACCESS_DENIED;
+ else
+ ret = BLUETOOTH_ERROR_INTERNAL;
+ g_clear_error(&err);
}
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- if (!dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH,
- &app_path, DBUS_TYPE_INVALID)) {
-
- BT_ERR(" HDP: Can't get reply arguments from Dbus");
-
- if (dbus_error_is_set(&err)) {
- BT_ERR("Error: %s", err.message);
- dbus_error_free(&err);
- }
-
- dbus_message_unref(reply);
- return BLUETOOTH_ERROR_INTERNAL;
+ return ret;
}
- dbus_message_unref(reply);
-
+ g_variant_get(reply, "(&o)", &app_path);
BT_DBG("Created health application: %s", (char *)app_path);
ret = __bt_hdp_internal_add_filter();
g_app_list = g_slist_append(g_app_list, list);
+ g_variant_unref(reply);
return BLUETOOTH_ERROR_NONE;
}
-static int __bt_hdp_internal_add_filter(void)
+static int __bt_hdp_add_filter_subscribe_signal(GDBusConnection *conn,
+ gboolean subscribe)
{
- DBusError dbus_error;
+ static guint subs_add_filter_id = 0;
+ if (conn == NULL)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ if (subscribe) {
+ if (subs_add_filter_id == 0) {
+ subs_add_filter_id = g_dbus_connection_signal_subscribe(
+ conn, NULL, BLUEZ_HDP_DEVICE_INTERFACE,
+ NULL, NULL, NULL, 0,
+ __bt_hdp_internal_event_filter, NULL, NULL);
+ }
+ } else {
+ if (subs_add_filter_id > 0) {
+ g_dbus_connection_signal_unsubscribe(conn,
+ subs_add_filter_id);
+ subs_add_filter_id = 0;
+ }
+ }
+ return BLUETOOTH_ERROR_NONE;
+}
+
+static int __bt_hdp_internal_add_filter(void)
+{
BT_DBG("+");
/*Single process only one signal registration is required */
if (g_hdp_dus_conn) {
BT_ERR("g_hdp_dus_conn already exist");
- goto done;
+ return BLUETOOTH_ERROR_NONE;
}
- /* Add the filter for HDP client functions */
- dbus_error_init(&dbus_error);
-
- g_hdp_dus_conn = _bt_get_system_conn();
+ g_hdp_dus_conn = _bt_gdbus_get_system_gconn();
retv_if(g_hdp_dus_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- dbus_connection_add_filter(g_hdp_dus_conn,
- __bt_hdp_internal_event_filter, NULL, NULL);
- dbus_bus_add_match(g_hdp_dus_conn,
- "type='signal',interface=" BLUEZ_HDP_DEVICE_INTERFACE,
- &dbus_error);
+ return __bt_hdp_add_filter_subscribe_signal(g_hdp_dus_conn, TRUE);
- if (dbus_error_is_set(&dbus_error)) {
- BT_ERR("Fail to add dbus filter signal\n");
- dbus_error_free(&dbus_error);
- g_hdp_dus_conn = NULL;
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
-done:
BT_DBG("-\n");
- return BLUETOOTH_ERROR_NONE;
-
}
-static DBusHandlerResult __bt_hdp_internal_event_filter(DBusConnection *sys_conn,
- DBusMessage *msg, void *data)
+static void __bt_hdp_internal_event_filter(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
{
- const char *path = dbus_message_get_path(msg);
-
- if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ BT_DBG("Path = %s\n", object_path);
+ if (object_path == NULL || g_strcmp0(object_path, "/") == 0)
+ return;
- BT_DBG("Path = %s\n", path);
- if (path == NULL || g_strcmp0(path, "/") == 0)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ if (signal_name == NULL)
+ return;
- if (dbus_message_is_signal(msg, BLUEZ_HDP_DEVICE_INTERFACE,
- "ChannelConnected"))
- __bt_hdp_internal_handle_connect(msg);
+ if (strcasecmp(signal_name, "ChannelConnected") == 0)
+ __bt_hdp_internal_handle_connect(parameters);
- else if (dbus_message_is_signal(msg, BLUEZ_HDP_DEVICE_INTERFACE,
- "ChannelDeleted"))
- __bt_hdp_internal_handle_disconnect(msg);
+ else if (strcasecmp(signal_name, "ChannelDeleted") == 0)
+ __bt_hdp_internal_handle_disconnect(parameters, object_path);
- else if (dbus_message_is_signal(msg, BLUEZ_HDP_DEVICE_INTERFACE,
- "PropertyChanged"))
- __bt_hdp_internal_handle_property_changed(msg);
+ else if (strcasecmp(signal_name, "PropertyChanged") == 0)
+ __bt_hdp_internal_handle_property_changed(parameters);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return;
}
-static void __bt_hdp_internal_handle_connect(DBusMessage *msg)
+static void __bt_hdp_internal_handle_connect(GVariant *parameters)
{
- const char *path = dbus_message_get_path(msg);
+ BT_DBG("+");
const char *obj_channel_path;
bt_user_info_t *user_info;
- bt_hdp_connected_t conn_ind;
int ret;
- BT_DBG("+********Signal - ChannelConnected******\n\n");
- BT_DBG("Path = %s", path);
+ BT_INFO("*********Signal - ChannelConnected******\n\n");
+ g_variant_get(parameters, "(&o)", &obj_channel_path);
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH,
- &obj_channel_path, DBUS_TYPE_INVALID)) {
- BT_ERR("Unexpected parameters in ChannelConnected signal");
- return;
- }
+ BT_INFO("Channel connected, Path = %s", obj_channel_path);
- BT_DBG("Channel connected, Path = %s", obj_channel_path);
+ user_info = _bt_get_user_data(BT_COMMON);
+ if (user_info == NULL || user_info->cb == NULL)
+ return;
ret = __bt_hdp_internal_acquire_fd(obj_channel_path);
if (ret != BLUETOOTH_ERROR_NONE) {
- user_info = _bt_get_user_data(BT_COMMON);
- if (user_info) {
- _bt_common_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
- BLUETOOTH_ERROR_CONNECTION_ERROR, &conn_ind,
- user_info->cb, user_info->user_data);
- }
+ _bt_common_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
+ BLUETOOTH_ERROR_CONNECTION_ERROR, NULL,
+ user_info->cb, user_info->user_data);
}
-
BT_DBG("-");
}
-static void __bt_hdp_internal_handle_disconnect(DBusMessage *msg)
+static void __bt_hdp_internal_handle_disconnect(GVariant *parameters,
+ const gchar *object_path)
{
- const char *path = dbus_message_get_path(msg);
const char *obj_channel_path;
char address[BT_ADDRESS_STRING_SIZE] = { 0, };
bluetooth_device_address_t device_addr = { {0} };
hdp_obj_info_t *info;
bt_user_info_t *user_info;
- BT_DBG("+********Signal - ChannelDeleted ******\n\n");
- BT_DBG("Path = %s", path);
+ BT_INFO("+********Signal - ChannelDeleted ******\n\n");
+ BT_DBG("Path = %s", object_path);
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH,
- &obj_channel_path, DBUS_TYPE_INVALID)) {
- BT_ERR("Unexpected parameters in ChannelDeleted signal");
- return;
- }
+ g_variant_get(parameters, "(&o)", &obj_channel_path);
- BT_DBG("Channel Deleted, Path = %s", obj_channel_path);
+ BT_INFO("Channel Deleted, Path = %s", obj_channel_path);
info = __bt_hdp_internal_gslist_obj_find_using_path(obj_channel_path);
if (!info) {
}
/*Since bluetoothd is not sending the ChannelDeleted signal */
- _bt_device_path_to_address(path, address);
+ _bt_convert_device_path_to_address(object_path, address);
_bt_convert_addr_string_to_type(device_addr.addr, address);
user_info = _bt_get_user_data(BT_COMMON);
- if (user_info) {
+ if (user_info->cb) {
_bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
BLUETOOTH_ERROR_NONE, &dis_ind,
user_info->cb, user_info->user_data);
}
-static void __bt_hdp_internal_handle_property_changed(DBusMessage *msg)
+static void __bt_hdp_internal_handle_property_changed(GVariant *parameters)
{
- const char *path = dbus_message_get_path(msg);
- DBusMessageIter item_iter;
- DBusMessageIter value_iter;
- const char *property;
- const char *obj_main_channel_path;
+ char *property = NULL;
+ GVariant *value = NULL;
+ gsize len;
+ char *obj_main_channel_path = NULL;
+ GVariantIter *property_iter;
BT_DBG("+*******Signal - PropertyChanged*******\n");
- BT_DBG("Path = %s", path);
- dbus_message_iter_init(msg, &item_iter);
+ g_variant_get (parameters, "(a{sv})", &property_iter);
- if (dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_STRING) {
- BT_DBG("This is bad format dbus");
- return;
+ while (g_variant_iter_loop(property_iter, "{sv}", &property, &value)) {
+ if (g_strcmp0("MainChannel", property) == 0) {
+ BT_INFO("Property MainChannel received");
+ obj_main_channel_path = g_variant_dup_string (value, &len);
+ BT_DBG("Main Channel Path = %s", obj_main_channel_path);
+ break;
+ }
}
+ g_variant_iter_free(property_iter);
- dbus_message_iter_get_basic(&item_iter, &property);
-
- ret_if(property == NULL);
-
- BT_DBG("Property (%s)\n", property);
-
- if (0 == g_strcmp0(property, "MainChannel")) {
- BT_DBG("Property MainChannel received");
-
- dbus_message_iter_next(&item_iter);
-
- dbus_message_iter_recurse(&item_iter, &value_iter);
-
- dbus_message_iter_get_basic(&value_iter,
- &obj_main_channel_path);
- BT_DBG("Path = %s", path);
-
- BT_DBG("Main Channel Path = %s", obj_main_channel_path);
- }
+ g_free(property);
+ g_variant_unref(value);
+ g_free(obj_main_channel_path);
BT_DBG("-*************\n");
}
{
char address[BT_ADDRESS_STRING_SIZE] = { 0, };
bluetooth_device_address_t device_addr = { {0} };
- DBusMessageIter reply_iter;
- DBusMessageIter reply_iter_entry;
const char *property;
+ GVariant *value = NULL;
char *type_qos = NULL;
- char *device = NULL;;
- char *app_handle = NULL;;
- hdp_app_list_t *list = NULL;;
- DBusMessage *msg;
- DBusMessage *reply;
- DBusConnection *conn;
+ char *device = NULL;
+ char *app_handle = NULL;
+ hdp_app_list_t *list = NULL;
+ GDBusProxy *proxy = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *conn;
bt_hdp_connected_t conn_ind;
- DBusError err;
+ GError *err = NULL;
int fd;
bt_user_info_t *user_info;
+ char *dev_path;
+ GUnixFDList *out_fd_list;
+ int index;
+ GVariantIter *property_iter;
+ gsize len;
BT_DBG("+");
- conn = _bt_get_system_conn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- msg = dbus_message_new_method_call(BT_BLUEZ_NAME, path,
- BLUEZ_HDP_CHANNEL_INTERFACE,
- "Acquire");
-
- retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ BT_BLUEZ_NAME,
+ path,
+ BLUEZ_HDP_CHANNEL_INTERFACE,
+ NULL, &err);
- dbus_error_init(&err);
+ if (!proxy) {
+ BT_ERR("Unable to create proxy: %s", err->message);
+ g_clear_error(&err);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
- reply = dbus_connection_send_with_reply_and_block(conn, msg,
- -1, &err);
+ reply = g_dbus_proxy_call_with_unix_fd_list_sync (proxy,
+ "Acquire",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &out_fd_list,
+ NULL,
+ &err);
- dbus_message_unref(msg);
+ g_object_unref(proxy);
if (!reply) {
BT_ERR(" HDP:****** dbus Can't create application ****");
- if (dbus_error_is_set(&err)) {
- BT_ERR("%s", err.message);
- dbus_error_free(&err);
+ if (err) {
+ BT_ERR("%s", err->message);;
+ g_clear_error(&err);
}
return BLUETOOTH_ERROR_INTERNAL;
}
- if (!dbus_message_get_args(reply, &err, DBUS_TYPE_UNIX_FD, &fd,
- DBUS_TYPE_INVALID)) {
- BT_ERR(" HDP:dbus Can't get reply arguments");
+ g_variant_get (reply, "(h)", &index);
+ fd = g_unix_fd_list_get(out_fd_list, index, NULL);
- if (dbus_error_is_set(&err)) {
- BT_ERR("%s", err.message);
- dbus_error_free(&err);
- }
- goto error;
- }
-
- dbus_message_unref(reply);
+ g_variant_unref(reply);
BT_DBG("File Descriptor = %d, Dev_path = %s \n", fd, path);
- msg = dbus_message_new_method_call(BT_BLUEZ_NAME, path,
- BLUEZ_HDP_CHANNEL_INTERFACE, "GetProperties");
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ BT_BLUEZ_NAME,
+ path,
+ BT_PROPERTIES_INTERFACE,
+ NULL, &err);
- retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
+ if (!proxy) {
+ BT_ERR("Unable to create proxy: %s", err->message);
+ g_clear_error(&err);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
- dbus_error_init(&err);
+ dev_path = g_strdup(BLUEZ_HDP_CHANNEL_INTERFACE);
- reply = dbus_connection_send_with_reply_and_block(conn, msg,
- -1, &err);
+ reply = g_dbus_proxy_call_sync(proxy, "GetAll",
+ g_variant_new("(s)", dev_path),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &err);
- dbus_message_unref(msg);
+ g_free(dev_path);
+ g_object_unref(proxy);
if (!reply) {
BT_ERR(" HDP:dbus Can't get the reply");
- if (dbus_error_is_set(&err)) {
- BT_ERR("%s", err.message);
- dbus_error_free(&err);
+ if (err) {
+ BT_ERR("%s", err->message);;
+ g_clear_error(&err);
}
return BLUETOOTH_ERROR_INTERNAL;
}
- dbus_message_iter_init(reply, &reply_iter);
-
- if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) {
- BT_ERR("Can't get reply arguments - DBUS_TYPE_ARRAY\n");
- goto error;
- }
- dbus_message_iter_recurse(&reply_iter, &reply_iter_entry);
+ g_variant_get (reply, "(a{sv})", &property_iter);
- /*Parse the dict */
- while (dbus_message_iter_get_arg_type(&reply_iter_entry) ==
- DBUS_TYPE_DICT_ENTRY) {
- DBusMessageIter dict_entry, dict_entry_val;
- dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
- dbus_message_iter_get_basic(&dict_entry, &property);
+ while (g_variant_iter_loop(property_iter, "{sv}", &property, &value)) {
BT_DBG("String received = %s\n", property);
if (g_strcmp0("Type", property) == 0) {
- dbus_message_iter_next(&dict_entry);
- dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
- if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
- DBUS_TYPE_STRING)
- continue;
-
- dbus_message_iter_get_basic(&dict_entry_val, &type_qos);
-
+ type_qos = g_variant_dup_string (value, &len);
} else if (g_strcmp0("Device", property) == 0) {
- dbus_message_iter_next(&dict_entry);
- dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
- if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
- DBUS_TYPE_OBJECT_PATH)
- continue;
-
- dbus_message_iter_get_basic(&dict_entry_val, &device);
-
+ device = g_variant_dup_string (value, &len);
} else if (g_strcmp0("Application", property) == 0) {
- dbus_message_iter_next(&dict_entry);
- dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
- if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
- DBUS_TYPE_OBJECT_PATH)
- continue;
-
- dbus_message_iter_get_basic(&dict_entry_val,
- &app_handle);
+ app_handle = g_variant_dup_string (value, &len);
}
- dbus_message_iter_next(&reply_iter_entry);
}
+ g_variant_iter_free(property_iter);
+ g_variant_unref(reply);
BT_DBG("QOS = %s, Device = %s, Apphandler = %s",
type_qos, device, app_handle);
/*Only process register with app handle receive the Connected event */
if (NULL == list) {
- BT_DBG("**** Could not locate the list for %s*****\n", app_handle);
+ BT_ERR("**** Could not locate the list for %s*****\n", app_handle);
goto error;
}
hdp_obj_info_t *info = g_new0(hdp_obj_info_t, 1);
info->fd = fd;
info->obj_channel_path = g_strdup(path);
+ info->watch_id = __bt_hdp_internal_watch_fd(fd, info->obj_channel_path);
list->obj_info = g_slist_append(list->obj_info, info);
- __bt_hdp_internal_watch_fd(fd, info->obj_channel_path);
-
- _bt_device_path_to_address(path, address);
+ _bt_convert_device_path_to_address(path, address);
_bt_convert_addr_string_to_type(device_addr.addr, address);
user_info = _bt_get_user_data(BT_COMMON);
- if (user_info) {
+ if (user_info->cb) {
_bt_common_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
BLUETOOTH_ERROR_NONE, &conn_ind,
user_info->cb, user_info->user_data);
}
- dbus_message_unref(reply);
-
BT_DBG("Updated fd in the list*\n");
BT_DBG("-\n");
+ g_free(type_qos);
+ g_free(device);
+ g_free(app_handle);
return BLUETOOTH_ERROR_NONE;
- error:
- dbus_message_unref(reply);
+error:
+ g_free(type_qos);
+ g_free(device);
+ g_free(app_handle);
return BLUETOOTH_ERROR_INTERNAL;
}
-static void __bt_hdp_internal_watch_fd(int file_desc, const char *path)
+static guint __bt_hdp_internal_watch_fd(int file_desc, const char *path)
{
GIOChannel *gio;
+ guint id;
BT_DBG("+");
g_io_channel_set_close_on_unref(gio, TRUE);
- g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ id = g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
__bt_hdp_internal_data_received, (void *)path);
BT_DBG("-");
+ return id;
}
hdp_obj_info_t *info;
bt_user_info_t *user_info;
- BT_DBG("******** Socket Error ******\n");
+ BT_INFO("******** Socket Error ******\n");
info = __bt_hdp_internal_gslist_obj_find_using_path(path);
ret_if(info == NULL);
/*Since bluetoothd is not sending the ChannelDeleted signal */
- _bt_device_path_to_address(path, address);
+ _bt_convert_device_path_to_address(path, address);
_bt_convert_addr_string_to_type(device_addr.addr, address);
user_info = _bt_get_user_data(BT_COMMON);
- if (user_info) {
+ if (user_info->cb) {
_bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
BLUETOOTH_ERROR_NONE, &dis_ind,
user_info->cb, user_info->user_data);
if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
BT_DBG("GIOCondition %d.............path = %s\n", cond, path);
+ g_io_channel_shutdown(gio, TRUE, NULL);
+ g_io_channel_unref(gio);
__bt_hdp_internal_handle_disconnect_cb(sk, path);
return FALSE;
}
if (act_read > 0) {
BT_DBG("Received data of %d\n", act_read);
} else {
- BT_DBG("Read failed.....\n");
+ BT_ERR("Read failed.....\n");
return FALSE;
}
user_info = _bt_get_user_data(BT_COMMON);
- if (user_info) {
+ if (user_info->cb) {
_bt_common_event_cb(BLUETOOTH_EVENT_HDP_DATA_RECEIVED,
BLUETOOTH_ERROR_NONE, &data_ind,
user_info->cb, user_info->user_data);
list = __bt_hdp_internal_gslist_find_app_handler((void *)app_handle);
if (NULL == list) {
- BT_DBG("**** list not found for %s ******\n", app_handle);
+ BT_ERR("**** list not found for %s ******\n", app_handle);
return FALSE;
}
static int __bt_hdp_internal_destroy_application(const char *app_handle)
{
- DBusMessage *msg;
- DBusMessage *reply;
- DBusError err;
- DBusConnection *conn;
+ GDBusProxy *proxy = NULL;
+ GVariant *reply = NULL;
+ GError *err = NULL;
+ GDBusConnection *conn;
+ int result = BLUETOOTH_ERROR_NONE;
- conn = _bt_get_system_conn();
+ conn = _bt_gdbus_get_system_gconn();
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
- msg = dbus_message_new_method_call(BT_BLUEZ_NAME, "/org/bluez",
- BLUEZ_HDP_MANAGER_INTERFACE, "DestroyApplication");
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ BT_BLUEZ_NAME,
+ "/org/bluez",
+ BLUEZ_HDP_MANAGER_INTERFACE,
+ NULL, &err);
- retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &app_handle,
- DBUS_TYPE_INVALID);
+ if (!proxy) {
+ BT_ERR("Unable to create proxy: %s", err->message);
+ g_clear_error(&err);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
- dbus_error_init(&err);
+ reply = g_dbus_proxy_call_sync(proxy, "DestroyApplication",
+ g_variant_new("o", app_handle),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &err);
- reply = dbus_connection_send_with_reply_and_block(conn, msg,
- -1, &err);
- dbus_message_unref(msg);
+ g_object_unref(proxy);
if (!reply) {
BT_ERR(" HDP:dbus Can't Destroy application");
- if (dbus_error_is_set(&err)) {
- BT_ERR("%s", err.message);
- dbus_error_free(&err);
+ if (err) {
+ BT_ERR("%s", err->message);
+ if (g_strrstr(err->message, BT_ACCESS_DENIED_MSG))
+ result = BLUETOOTH_ERROR_ACCESS_DENIED;
+ else
+ result = BLUETOOTH_ERROR_INTERNAL;
+ g_clear_error(&err);
}
-
- return BLUETOOTH_ERROR_INTERNAL;
+ return result ;
}
- dbus_message_unref(reply);
+ g_variant_unref(reply);
BT_DBG("Destroyed health application: %s", (char *)app_handle);
ret_if(g_hdp_dus_conn == NULL);
- dbus_connection_remove_filter(g_hdp_dus_conn,
- __bt_hdp_internal_event_filter, NULL);
+ __bt_hdp_add_filter_subscribe_signal(g_hdp_dus_conn, FALSE);
g_hdp_dus_conn = NULL; /*should not unref here, bcz no ++reff */
{
int wbytes = 0;
int written = 0;
+ int result;
BT_DBG("+");
BT_CHECK_ENABLED(return);
if ((channel_id == 0) || (NULL == buffer) || (size == 0)) {
- BT_DBG("Invalid arguments..\n");
+ BT_ERR("Invalid arguments..\n");
return BLUETOOTH_ERROR_INVALID_PARAM;
- } else {
- while (wbytes < size) {
- written = write(channel_id, buffer + wbytes, size - wbytes);
- if (written <= 0) {
- BT_DBG("write failed..\n");
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
- }
- wbytes += written;
+ }
+
+ switch (privilege_token) {
+ case 0:
+ result = _bt_check_privilege(BT_BLUEZ_SERVICE, BT_HDP_SEND_DATA);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ privilege_token = 1; /* Have a permission */
+ } else if (result == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ privilege_token = -1; /* Don't have a permission */
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ } else {
+ /* Just break - It is not related with permission error */
+ }
+ break;
+ case 1:
+ /* Already have a privilege */
+ break;
+ case -1:
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ default:
+ /* Invalid privilge token value */
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ while (wbytes < size) {
+ written = write(channel_id, buffer + wbytes, size - wbytes);
+ if (written <= 0) {
+ BT_ERR("write failed..\n");
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
}
+ wbytes += written;
}
return BLUETOOTH_ERROR_NONE;
}
-
-static void __bt_hdp_connect_request_cb(DBusGProxy *hdp_proxy, DBusGProxyCall *call,
- gpointer user_data)
+static void __bt_hdp_connect_request_cb(GDBusProxy *hdp_proxy,
+ GAsyncResult *res, gpointer user_data)
{
- GError *g_error = NULL;
+ GError *err = NULL;
char *obj_connect_path = NULL;
bt_hdp_connected_t *conn_ind = user_data;
bt_user_info_t *user_info;
+ GVariant *reply = NULL;
- dbus_g_proxy_end_call(hdp_proxy, call, &g_error,
- DBUS_TYPE_G_OBJECT_PATH, &obj_connect_path, G_TYPE_INVALID);
+ reply = g_dbus_proxy_call_finish(hdp_proxy, res, &err);
g_object_unref(hdp_proxy);
- if (g_error != NULL) {
- BT_ERR("HDP connection Dbus Call Error: %s\n", g_error->message);
- g_error_free(g_error);
+ if (!reply) {
+ if (err) {
+ BT_ERR("HDP connection Dbus Call Error: %s\n", err->message);
+ g_clear_error(&err);
+ }
user_info = _bt_get_user_data(BT_COMMON);
- if (user_info) {
+ if (user_info->cb) {
_bt_common_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
BLUETOOTH_ERROR_CONNECTION_ERROR, conn_ind,
user_info->cb, user_info->user_data);
}
} else {
+ g_variant_get(reply, "(&o)", &obj_connect_path);
BT_DBG("Obj Path returned = %s\n", obj_connect_path);
- g_free(obj_connect_path);
}
g_free((void *)conn_ind->app_handle);
g_free(conn_ind);
const bluetooth_device_address_t *device_address)
{
GError *err = NULL;
- DBusGConnection *conn = NULL;
- DBusGProxy *hdp_proxy = NULL;
+ GDBusConnection *conn = NULL;
+ GDBusProxy *hdp_proxy = NULL;
bt_hdp_connected_t *param;
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
BT_CHECK_PARAMETER(app_handle, return);
BT_CHECK_PARAMETER(device_address, return);
+ if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_HDP_CONNECT)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
if (channel_type == HDP_QOS_RELIABLE) {
role = "Reliable";
} else if (channel_type == HDP_QOS_STREAMING) {
return BLUETOOTH_ERROR_ACCESS_DENIED;
}
- conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (err != NULL) {
- BT_DBG("ERROR: Can't get on system bus [%s]", err->message);
- g_error_free(err);
+ if (err) {
+ BT_ERR("ERROR: Can't get on system bus [%s]", err->message);
+ g_clear_error(&err);
return BLUETOOTH_ERROR_INTERNAL;
}
/* If the adapter path is wrong, we can think the BT is not enabled. */
- if (_bt_get_adapter_path(conn, default_adapter_path) < 0) {
+ if (_bt_get_adapter_path(_bt_gdbus_get_system_gconn(),
+ default_adapter_path) < 0) {
BT_ERR("Could not get adapter path\n");
- dbus_g_connection_unref(conn);
+ g_object_unref(conn);
return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
}
dev_path = g_strdup_printf("%s/dev_%s", default_adapter_path, address);
if (dev_path == NULL) {
- dbus_g_connection_unref(conn);
+ g_object_unref(conn);
return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
}
BT_DBG("path: %s", dev_path);
- hdp_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME, dev_path,
- BLUEZ_HDP_DEVICE_INTERFACE);
- dbus_g_connection_unref(conn);
+ hdp_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_BLUEZ_NAME,
+ dev_path, BLUEZ_HDP_DEVICE_INTERFACE,
+ NULL, NULL);
+ g_object_unref(conn);
if (hdp_proxy == NULL) {
- BT_DBG("Failed to get the HDP server proxy\n");
+ BT_ERR("Failed to get the HDP server proxy\n");
g_free(dev_path);
return BLUETOOTH_ERROR_NOT_PAIRED;
}
memcpy(¶m->device_address, device_address, BLUETOOTH_ADDRESS_LENGTH);
param->type = channel_type;
- if (!dbus_g_proxy_begin_call(hdp_proxy, "CreateChannel",
- (DBusGProxyCallNotify) __bt_hdp_connect_request_cb,
- param, /* user_data */
- NULL, /* destroy */
- DBUS_TYPE_G_OBJECT_PATH, app_handle,
- G_TYPE_STRING, role,
- G_TYPE_INVALID)) {
- BT_ERR("HDP connection Dbus Call Error");
- g_free(dev_path);
- g_free((void *)param->app_handle);
- g_free(param);
- g_object_unref(hdp_proxy);
- return BLUETOOTH_ERROR_INTERNAL;
- }
+ g_dbus_proxy_call(hdp_proxy, "CreateChannel",
+ g_variant_new("(os)", app_handle, role),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+ (GAsyncReadyCallback)__bt_hdp_connect_request_cb,
+ param);
g_free(dev_path);
+
return BLUETOOTH_ERROR_NONE;
}
-static void __bt_hdp_disconnect_request_cb(DBusGProxy *hdp_proxy, DBusGProxyCall *call,
- gpointer user_data)
+static void __bt_hdp_disconnect_request_cb(GDBusProxy *hdp_proxy,
+ GAsyncResult *res, gpointer user_data)
{
- GError *g_error = NULL;
+ GError *err = NULL;
bt_hdp_disconnected_t *disconn_ind = user_data;
bt_user_info_t *user_info;
+ GVariant *reply = NULL;
- dbus_g_proxy_end_call(hdp_proxy, call, &g_error, G_TYPE_INVALID);
-
+ reply = g_dbus_proxy_call_finish(hdp_proxy, res, &err);
g_object_unref(hdp_proxy);
- if (g_error != NULL) {
- BT_ERR("HDP disconnection Dbus Call Error: %s\n", g_error->message);
- g_error_free(g_error);
-
- user_info = _bt_get_user_data(BT_COMMON);
+ user_info = _bt_get_user_data(BT_COMMON);
+ if (user_info == NULL || user_info->cb == NULL) {
+ g_free(disconn_ind);
+ if (err) {
+ g_clear_error(&err);
+ return;
+ }
+ g_variant_unref(reply);
+ return;
+ }
- if (user_info) {
- _bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
- BLUETOOTH_ERROR_CONNECTION_ERROR, disconn_ind,
- user_info->cb, user_info->user_data);
+ if (!reply) {
+ if (err) {
+ BT_ERR("HDP disconnection Dbus Call Error: %s\n",
+ err->message);
+ g_clear_error(&err);
}
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
+ BLUETOOTH_ERROR_CONNECTION_ERROR, disconn_ind,
+ user_info->cb, user_info->user_data);
} else {
- BT_DBG("HDP disconnection Dbus Call is done\n");
+ _bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
+ BLUETOOTH_ERROR_NONE, disconn_ind,
+ user_info->cb, user_info->user_data);
+ BT_INFO("HDP disconnection Dbus Call is done\n");
+ g_variant_unref(reply);
}
g_free(disconn_ind);
const bluetooth_device_address_t *device_address)
{
GError *err = NULL;
- DBusGConnection *conn = NULL;
- DBusGProxy *hdp_proxy = NULL;
+ GDBusConnection *conn = NULL;
+ GDBusProxy *hdp_proxy = NULL;
char address[BT_ADDRESS_STRING_SIZE] = { 0 };
char default_adapter_path[BT_ADAPTER_OBJECT_PATH_MAX + 1] = { 0 };
char *dev_path = NULL;
BT_CHECK_ENABLED(return);
BT_CHECK_PARAMETER(device_address, return);
- hdp_obj_info_t *info = __bt_hdp_internal_gslist_obj_find_using_fd(channel_id);
+ if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_HDP_DISCONNECT)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
+ hdp_obj_info_t *info =
+ __bt_hdp_internal_gslist_obj_find_using_fd(channel_id);
if (NULL == info) {
- BT_ERR("*** Could not locate the list for %d*****\n", channel_id);
+ BT_ERR("*** Could not locate the list for %d*****\n",
+ channel_id);
return BLUETOOTH_ERROR_INVALID_PARAM;
}
- conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
- if (err != NULL) {
+ if (err) {
BT_ERR("ERROR: Can't get on system bus [%s]", err->message);
- g_error_free(err);
+ g_clear_error(&err);
return BLUETOOTH_ERROR_INTERNAL;
}
/* If the adapter path is wrong, we can think the BT is not enabled. */
- if (_bt_get_adapter_path(conn, default_adapter_path) < 0) {
+ if (_bt_get_adapter_path(_bt_gdbus_get_system_gconn(),
+ default_adapter_path) < 0) {
BT_ERR("Could not get adapter path\n");
- dbus_g_connection_unref(conn);
+ g_object_unref(conn);
return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
}
dev_path = g_strdup_printf("%s/dev_%s", default_adapter_path, address);
if (dev_path == NULL) {
- dbus_g_connection_unref(conn);
+ g_object_unref(conn);
return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
}
BT_DBG("path %s\n", dev_path);
- hdp_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME, dev_path,
- BLUEZ_HDP_DEVICE_INTERFACE);
+ hdp_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_BLUEZ_NAME,
+ dev_path, BLUEZ_HDP_DEVICE_INTERFACE,
+ NULL, NULL);
- dbus_g_connection_unref(conn);
+ g_object_unref(conn);
if (hdp_proxy == NULL) {
BT_ERR("Failed to get the HDP proxy\n");
param->channel_id = channel_id;
memcpy(¶m->device_address, device_address, BLUETOOTH_ADDRESS_LENGTH);
- if (!dbus_g_proxy_begin_call(hdp_proxy, "DestroyChannel",
- (DBusGProxyCallNotify) __bt_hdp_disconnect_request_cb,
- param, /* user_data */
- NULL, /* destroy */
- DBUS_TYPE_G_OBJECT_PATH, info->obj_channel_path,
- G_TYPE_INVALID)) {
- BT_ERR("HDP connection Dbus Call Error");
- g_free(dev_path);
- g_free(param);
- g_object_unref(hdp_proxy);
- return BLUETOOTH_ERROR_INTERNAL;
- }
+ g_dbus_proxy_call(hdp_proxy, "DestroyChannel",
+ g_variant_new("o", info->obj_channel_path),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+ (GAsyncReadyCallback)__bt_hdp_disconnect_request_cb,
+ param);
g_free(dev_path);
+ g_free(param);
+ g_object_unref(hdp_proxy);
return BLUETOOTH_ERROR_NONE;
+
}