g_variant_iter_free(property_iter);
}
-int __bt_hal_dbus_enquire_remote_device_services(char *address)
+int __bt_hal_dbus_get_all_remote_device_properties(char *address, GVariant **result)
{
char *device_path = NULL;
GError *error = NULL;
GDBusProxy *device_proxy;
GDBusConnection *conn;
- GVariant *result;
-
device_path = _bt_hal_get_device_object_path(address);
if (!device_path) {
ERR("Device not paired");
return BT_STATUS_FAIL;
}
- result = g_dbus_proxy_call_sync(device_proxy,
+ *result = g_dbus_proxy_call_sync(device_proxy,
"GetAll",
g_variant_new("(s)", BT_HAL_DEVICE_INTERFACE),
G_DBUS_CALL_FLAGS_NONE,
NULL,
&error);
- if (!result) {
+ if (!*result) {
ERR("Error occured in Proxy call");
if (error != NULL) {
ERR("Error occured in Proxy call (Error: %s)", error->message);
g_object_unref(device_proxy);
g_free(device_path);
- /* Fetch Device Services and send to HAL User */
- __bt_device_parse_services(result);
+ return BT_STATUS_SUCCESS;
+}
+
+int __bt_hal_dbus_enquire_remote_device_services(char *address)
+{
+ GVariant *result;
+ int ret;
+
+ ret = __bt_hal_dbus_get_all_remote_device_properties(address, &result);
+ if (ret == BT_STATUS_SUCCESS)
+ /* Fetch Device Services and send to HAL User */
+ __bt_device_parse_services(result);
DBG("-");
- return BT_STATUS_SUCCESS;
+ return ret;
}
static void __bt_hal_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
int _bt_hal_dbus_get_remote_device_properties(bt_bdaddr_t *remote_addr)
{
- char *device_path = NULL;
char address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
- GError *error = NULL;
- GDBusProxy *device_proxy;
- GDBusConnection *conn;
GVariant *result;
+ int ret;
if (!remote_addr) {
ERR("Invalid device address ptr received");
}
_bt_hal_convert_addr_type_to_string(address, remote_addr->address);
- device_path = _bt_hal_get_device_object_path(address);
- if (!device_path) {
- ERR("Device not paired");
- return BT_STATUS_FAIL;
- }
-
- conn = _bt_hal_get_system_gconn();
- if (!conn) {
- g_free(device_path);
- ERR("_bt_hal_get_system_gconn failed");
- return BT_STATUS_FAIL;
- }
-
- device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- BT_HAL_BLUEZ_NAME,
- device_path,
- BT_HAL_PROPERTIES_INTERFACE,
- NULL, NULL);
-
- if (!device_proxy) {
- ERR("Error creating device_proxy");
- g_free(device_path);
- return BT_STATUS_FAIL;
- }
-
- result = g_dbus_proxy_call_sync(device_proxy,
- "GetAll",
- g_variant_new("(s)", BT_HAL_DEVICE_INTERFACE),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
- if (!result) {
- ERR("Error occured in Proxy call");
- if (error != NULL) {
- ERR("Error occured in Proxy call (Error: %s)", error->message);
- g_clear_error(&error);
- }
- g_object_unref(device_proxy);
- g_free(device_path);
- return BT_STATUS_FAIL;
- }
+ ret = __bt_hal_dbus_get_all_remote_device_properties(address, &result);
- g_object_unref(device_proxy);
- g_free(device_path);
- /*
- * As we need to provide async callback to user from HAL, simply schedule a
- * callback method which will carry actual result
- */
- g_idle_add(__bt_device_bonded_device_info_cb, (gpointer)result);
+ if (ret == BT_STATUS_SUCCESS)
+ /*
+ * As we need to provide async callback to user from HAL, simply schedule a
+ * callback method which will carry actual result
+ */
+ g_idle_add(__bt_device_bonded_device_info_cb, (gpointer)result);
- return BT_STATUS_SUCCESS;
+ return ret;
}
static int __bt_hal_dbus_set_remote_device_alias(bt_bdaddr_t *remote_addr, char *alias)