-int _bt_set_restrict_profile(bluetooth_device_address_t *bd_addr,
- bluetooth_restricted_profile_t profile, gboolean restricted)
-{
- int ret = BLUETOOTH_ERROR_NONE;
- GDBusConnection *conn;
- GDBusProxy *proxy;
- GError *error = NULL;
- char *device_path = NULL;
- char *uuid = NULL;
- char address[BT_ADDRESS_STRING_SIZE] = { 0 };
- GVariant *reply;
-
- BT_CHECK_PARAMETER(bd_addr, return);
- BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
- bd_addr->addr[0], bd_addr->addr[1],
- bd_addr->addr[2], bd_addr->addr[3],
- bd_addr->addr[4], bd_addr->addr[5],
- profile, restricted);
-
- conn = _bt_gdbus_get_system_gconn();
- retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- _bt_convert_addr_type_to_string(address, bd_addr->addr);
-
- device_path = _bt_get_device_object_path(address);
- retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
- NULL, BT_BLUEZ_NAME, device_path,
- BT_DEVICE_INTERFACE, NULL, NULL);
-
- g_free(device_path);
- retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- uuid = _bt_get_restricted_profile_uuid(profile);
- if (uuid == NULL) {
- g_object_unref(proxy);
- return BLUETOOTH_ERROR_NOT_SUPPORT;
- }
-
- reply = g_dbus_proxy_call_sync(proxy, "SetRestrictedProfile",
- g_variant_new("(sb)", uuid, restricted),
- G_DBUS_CALL_FLAGS_NONE, -1,
- NULL, &error);
- g_object_unref(proxy);
-
- if (reply == NULL) {
- BT_ERR("Failed to Set Profile Restricted");
- ret = BLUETOOTH_ERROR_INTERNAL;
- if (error) {
- BT_ERR("Error %s[%s]", error->message, address);
- g_error_free(error);
- }
- goto finish;
- }
- g_variant_unref(reply);
-
-finish:
- g_free(uuid);
- return ret;
-}
-
-int _bt_get_restrict_profile(bluetooth_device_address_t *bd_addr,
- bluetooth_restricted_profile_t profile, guint *restricted)
-{
- int ret = BLUETOOTH_ERROR_NONE;
- GDBusConnection *conn;
- GDBusProxy *proxy;
- GError *error = NULL;
- char *device_path = NULL;
- guint restricted_profile_flag;
- char address[BT_ADDRESS_STRING_SIZE] = { 0 };
- GVariant *reply;
-
- BT_CHECK_PARAMETER(bd_addr, return);
- BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
- bd_addr->addr[0], bd_addr->addr[1],
- bd_addr->addr[2], bd_addr->addr[3],
- bd_addr->addr[4], bd_addr->addr[5],
- profile, *restricted);
-
- conn = _bt_gdbus_get_system_gconn();
- retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- _bt_convert_addr_type_to_string(address, bd_addr->addr);
-
- device_path = _bt_get_device_object_path(address);
- retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
- NULL, BT_BLUEZ_NAME, device_path,
- BT_PROPERTIES_INTERFACE, NULL, NULL);
-
- g_free(device_path);
- retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
- reply = g_dbus_proxy_call_sync(proxy, "Get",
- g_variant_new("(ss)", BT_DEVICE_INTERFACE, "RestrictedProfiles"),
- G_DBUS_CALL_FLAGS_NONE, -1,
- NULL, &error);
- g_object_unref(proxy);
-
- if (reply == NULL) {
- BT_ERR("Failed to Get Profile Restricted");
- ret = BLUETOOTH_ERROR_INTERNAL;
- if (error) {
- BT_ERR("Error %s[%s]", error->message, address);
- g_error_free(error);
- }
- *restricted = 0;
- } else {
- GVariant *temp;
- g_variant_get(reply, "(v)", &temp);
- restricted_profile_flag = g_variant_get_uint32(temp);
- BT_DBG("Restricted_FLAG %d", restricted_profile_flag);
-
- ret = _bt_get_restricted_profile_from_flag(profile,
- restricted_profile_flag, restricted);
- g_variant_unref(temp);
- g_variant_unref(reply);
- }
-
- BT_DBG("TRUST %d", *restricted);
- return ret;
-}
-