static void __bt_device_trusted_callback(gboolean trusted, event_dev_trust_t* info);
static int __bt_get_device_pin_code(const char *address, char *pin_code);
+static gboolean __bt_ignore_auto_pairing_request(const char *address);
gboolean _bt_is_device_creating(void)
{
To be considered later*/
int result = BLUETOOTH_ERROR_INTERNAL;
BT_INFO("BT_OPERATION_STATUS_AUTH_FAILED");
+
+ BT_INFO("add device in pairing black list");
+ _bt_set_autopair_status_in_bonding_info(FALSE);
+ __bt_ignore_auto_pairing_request(trigger_bond_info->addr);
+
if (trigger_bond_info) {
BT_ERR("Create Bond procedure could not suceed, check if cancelled by User");
if (trigger_bond_info->is_cancelled_by_user) {
return BLUETOOTH_ERROR_NONE;
}
+static gboolean __bt_ignore_auto_pairing_request(const char *address)
+{
+ gchar *buffer;
+ char **lines;
+ int i;
+ char lap_address[BT_LOWER_ADDRESS_LENGTH + 1] = {0,};
+ char *temp_buffer;
+ FILE *fp;
+ long size;
+ size_t result;
+
+ BT_DBG("+\n");
+
+ if (address == NULL)
+ return FALSE;
+
+ /* Get the LAP(Lower Address part) */
+ /* User BT_LOWER_ADDRESS_LENGTH+1 for lap_address to accomodate
+ a "," */
+ snprintf(lap_address, sizeof(lap_address), ",%s", address);
+
+ fp = fopen(BT_AGENT_AUTO_PAIR_BLACKLIST_FILE, "r");
+
+ if (fp == NULL) {
+ BT_ERR("fopen failed \n");
+ return FALSE;
+ }
+
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+ rewind(fp);
+
+ if (size < 0) {
+ BT_ERR("Get file size failed \n");
+ fclose(fp);
+ return FALSE;
+ }
+
+ buffer = g_malloc0(sizeof(char) * size);
+ result = fread((char *)buffer, 1, size, fp);
+ fclose(fp);
+ if (result != size) {
+ BT_ERR("Read Error\n");
+ g_free(buffer);
+ return FALSE;
+ }
+
+ BT_DBG("Buffer = %s\n", buffer);
+
+ lines = g_strsplit_set(buffer, BT_AGENT_NEW_LINE, 0);
+ g_free(buffer);
+
+ if (lines == NULL)
+ return FALSE;
+
+ /* Write the data and insert new device data */
+ for (i = 0; lines[i] != NULL; i++) {
+ if (g_str_has_prefix(lines[i], "AddressBlacklist")) {
+ temp_buffer = g_strconcat(lines[i], lap_address, NULL);
+ g_free(lines[i]);
+ lines[i] = temp_buffer;
+ }
+ }
+ buffer = g_strjoinv(BT_AGENT_NEW_LINE, lines);
+ g_strfreev(lines);
+ /* Fix : NULL_RETURNS */
+ retv_if(buffer == NULL, FALSE);
+
+ fp = fopen(BT_AGENT_AUTO_PAIR_BLACKLIST_FILE, "w");
+
+ if (fp == NULL) {
+ BT_ERR("fopen failed \n");
+ g_free(buffer);
+ return FALSE;
+ }
+
+ BT_DBG("Buffer = %s\n", buffer);
+ fwrite(buffer, 1, strlen(buffer), fp);
+ fclose(fp);
+
+ g_free(buffer);
+
+ BT_DBG("-\n");
+
+ return FALSE;
+}
#endif