#include <string.h>
#include <malloc.h>
#include <stacktrim.h>
-
-#if defined(LIBNOTIFY_SUPPORT)
-#include "bt-popup.h"
-#elif defined(LIBNOTIFICATION_SUPPORT)
-#include "bt-service-agent-notification.h"
-#else
#include <syspopup_caller.h>
-#endif
-
#include <vconf.h>
#include <bundle_internal.h>
-#ifdef TIZEN_NETWORK_TETHERING_ENABLE
+#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
#include <tethering.h>
#endif
#include "bt-service-device.h"
#include "bt-service-audio.h"
+#ifdef TIZEN_DPM_ENABLE
+#include "bt-service-dpm.h"
+#endif
+
#define BT_APP_AUTHENTICATION_TIMEOUT 35
#define BT_APP_AUTHORIZATION_TIMEOUT 15
#define GN_UUID "00001117-0000-1000-8000-00805f9b34fb"
#define BNEP_UUID "0000000f-0000-1000-8000-00805f9b34fb"
#define HID_UUID "00001124-0000-1000-8000-00805f9b34fb"
+#define HID_DEVICE_UUID "00001124-0000-1000-8000-00805f9b43bf"
#define SAP_UUID_OLD "a49eb41e-cb06-495c-9f4f-bb80a90cdf00"
#define SAP_UUID_NEW "a49eb41e-cb06-495c-9f4f-aa80a90cdf4a"
+#define IOTIVITY_UUID "12341234-1C25-481F-9DFB-59193D238280"
#define BT_AGENT_OBJECT "/org/bluez/agent/frwk_agent"
#define BT_AGENT_SIGNAL_RFCOMM_AUTHORIZE "RfcommAuthorize"
#define BT_AGENT_SIGNAL_OBEX_AUTHORIZE "ObexAuthorize"
-#define BT_PIN_MAX_LENGTH 16
#define BT_PASSKEY_MAX_LENGTH 4
#define BT_AGENT_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
#define BT_AGENT_SYSPOPUP_MAX_ATTEMPT 3
#define BT_PAN_MAX_CONNECTION 4
+
extern guint nap_connected_device_count;
+static char *passkey_watcher = NULL;
+
#define G_VARIANT_UNREF(variant) \
g_variant_unref(variant); \
variant = NULL
-static gboolean syspopup_mode = TRUE;
-
static int __bt_agent_is_auto_response(uint32_t dev_class, const gchar *address,
const gchar *name);
static gboolean __bt_agent_is_hid_keyboard(uint32_t dev_class);
/* Release Stack Memory*/
stack_trim();
}
-
static gboolean __bt_agent_system_popup_timer_cb(gpointer user_data)
{
int ret;
retv_if(user_data == NULL, FALSE);
++retry_count;
-#if defined(LIBNOTIFY_SUPPORT)
- ret = notify_launch(b);
-#elif defined(LIBNOTIFICATION_SUPPORT)
- ret = notification_launch(b);
-#else
- ret = syspopup_launch("bt-syspopup", b);
-#endif
+
+ ret = syspopup_launch("bt-syspopup", b);
if (ret < 0) {
BT_ERR("Sorry! Can't launch popup, ret=%d, Re-try[%d] time..",
ret, retry_count);
return (ret < 0) ? TRUE : FALSE;
}
-#ifdef TIZEN_WEARABLE
-static void __bt_popup_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)
-{
- BT_DBG("Sender Name[%s] Object Path[%s] Interface[%s] Signal[%s]",
- sender_name, object_path, interface_name, signal_name);
-
- if (g_strcmp0(interface_name, "User.Bluetooth.syspopup") == 0 &&
- g_strcmp0(signal_name, "ResetResponse") == 0) {
- int response;
-
- g_variant_get(parameters, "(i)", &response);
- BT_DBG("response = %d", response);
- }
-}
-
-int __bt_service_subscribe_popup(GDBusConnection *conn,
- gboolean subscribe)
-{
- static guint subs_interface_added_id = 0;
-
- if (conn == NULL)
- return BLUETOOTH_ERROR_INVALID_PARAM;
-
- if (subscribe) {
- if (subs_interface_added_id == 0) {
- subs_interface_added_id = g_dbus_connection_signal_subscribe(conn,
- NULL, "User.Bluetooth.syspopup", "ResetResponse", NULL, NULL, 0,
- __bt_popup_event_filter, NULL, NULL);
- }
- } else {
- if (subs_interface_added_id > 0) {
- g_dbus_connection_signal_unsubscribe(conn,
- subs_interface_added_id);
- subs_interface_added_id = 0;
- }
- }
- return BLUETOOTH_ERROR_NONE;
-}
-
-static void __bt_register_popup_event_signal(void)
-{
- GDBusConnection *conn;
-
- BT_DBG("+\n");
-
- conn = _bt_get_system_gconn();
- if (conn == NULL)
- return;
-
- __bt_service_subscribe_popup(conn, TRUE);
-
- BT_DBG("-\n");
- return;
-}
-
-static gboolean __is_reset_required(const gchar *address)
-{
- GArray *device_list;
- uint32_t no_of_device;
- uint32_t i;
- bluetooth_device_info_t info;
- gboolean is_required = FALSE;
-
- device_list = g_array_new(FALSE, FALSE, sizeof(gchar));
- if (device_list == NULL) {
- BT_ERR("g_array_new is failed");
- return FALSE;
- }
-
- if (_bt_get_bonded_devices(&device_list) != BLUETOOTH_ERROR_NONE) {
- BT_ERR("_bt_get_bonded_devices is failed");
- g_array_free(device_list, TRUE);
- return FALSE;
- }
-
- no_of_device = device_list->len / sizeof(bluetooth_device_info_t);
- for (i = 0; i < no_of_device; i++) {
- char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
-
- info = g_array_index(device_list, bluetooth_device_info_t, i);
-
- _bt_convert_addr_type_to_string(addr, info.device_address.addr);
- if (g_strcmp0(address, addr) == 0) {
- BT_DBG("This device is already in paired list");
- is_required = FALSE;
- break;
- }
-
- if (info.device_class.major_class != BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO) {
- is_required = TRUE;
- break;
- }
- }
- g_array_free(device_list, TRUE);
-
- return is_required;
-}
-#endif
-
int _bt_launch_system_popup(bt_agent_event_type_t event_type,
const char *device_name,
+ const unsigned char *auth_info,
char *passkey,
const char *filename,
const char *agent_path)
}
bundle_add(b, "device-name", device_name);
+ bundle_add(b, "auth-info", (const char *)auth_info);
bundle_add(b, "passkey", passkey);
bundle_add(b, "file", filename);
bundle_add(b, "agent-path", agent_path);
sizeof(event_str));
break;
- case BT_AGENT_EVENT_PASSKEY_AUTO_ACCEPTED:
- g_strlcpy(event_str, "passkey-auto-accepted",
- sizeof(event_str));
- break;
-
case BT_AGENT_EVENT_PASSKEY_REQUEST:
g_strlcpy(event_str, "passkey-request", sizeof(event_str));
break;
g_strlcpy(event_str, "message-request", sizeof(event_str));
break;
-#ifdef TIZEN_WEARABLE
- case BT_AGENT_EVENT_SYSTEM_RESET_REQUEST:
- __bt_register_popup_event_signal();
- g_strlcpy(event_str, "system-reset-request", sizeof(event_str));
- break;
-#endif
-
case BT_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE:
g_strlcpy(event_str, "remote-legacy-pair-failed", sizeof(event_str));
break;
bundle_add(b, "event-type", event_str);
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
ret = syspopup_launch("bt-syspopup", b);
-#endif
if (0 > ret) {
BT_ERR("Popup launch failed...retry %d", ret);
static gboolean __pincode_request(GapAgentPrivate *agent, GDBusProxy *device)
{
uint32_t device_class;
- const gchar *address;
- const gchar *name;
+ gchar *address = NULL;
+ unsigned char auth_info[5] = {0, };
+ gchar *name = NULL;
GVariant *reply = NULL;
GVariant *reply_temp = NULL;
GVariant *tmp_value;
- GVariant *param;
- int result = BLUETOOTH_ERROR_NONE;
+ char pin_code[BLUETOOTH_PIN_CODE_MAX_LENGTH + 1];
BT_DBG("+");
+#ifdef TIZEN_DPM_ENABLE
+ if (_bt_dpm_get_bluetooth_pairing_state() == DPM_RESTRICTED) {
+ BT_ERR("Not allow to pair the device");
+ gap_agent_reply_confirmation(agent, GAP_AGENT_REJECT, NULL);
+ __bt_agent_release_memory();
+ return TRUE;
+ }
+#endif
+
reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
if (reply_temp == NULL) {
goto done;
}
- g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+ g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/
tmp_value = g_variant_lookup_value(reply, "Class", G_VARIANT_TYPE_UINT32);
g_variant_get(tmp_value, "u", &device_class);
tmp_value = g_variant_lookup_value(reply, "Name", G_VARIANT_TYPE_STRING);
g_variant_get(tmp_value, "s", &name);
G_VARIANT_UNREF(tmp_value);
- if (!name)
- name = address;
+ if (!name) {
+ BT_DBG("Replacing the name with address");
+ name = g_strdup(address);
+ } else {
+ BT_INFO("Name = %s, Address = %s, Class = 0x%x", name, address, device_class);
+ if (name[0] == '\0') {
+ g_free(name);
+ BT_DBG("Name[0]=NULL, Replacing the name with address");
+ name = g_strdup(address);
+ }
+ }
+ __bt_get_auth_info(reply, (char *)auth_info);
if (_bt_is_device_creating() == TRUE &&
_bt_is_bonding_device_address(address) == TRUE &&
__bt_agent_is_auto_response(device_class, address, name)) {
gap_agent_reply_pin_code(agent, GAP_AGENT_ACCEPT,
str_passkey, NULL);
-#ifdef AUTO_ACCEPT
- gap_agent_reply_pin_code(agent, GAP_AGENT_ACCEPT, "0000",
- NULL);
-#else
- if (syspopup_mode) {
- BT_DBG("LAUNCH SYSPOPUP");
- _bt_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST,
- name, str_passkey, NULL,
- _gap_agent_get_path(agent));
- } else {
- BT_DBG("Send BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY");
- param = g_variant_new("(isss)", result, address, name, str_passkey);
- _bt_send_event(BT_ADAPTER_EVENT,
- BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY, param);
- }
-#endif
+ _bt_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST,
+ name, auth_info, str_passkey, NULL,
+ _gap_agent_get_path(agent));
+ } else if (_bt_get_device_pin_code(address, pin_code)
+ == BLUETOOTH_ERROR_NONE) {
+ BT_DBG("Use stored PIN code(%s)", pin_code);
+ gap_agent_reply_pin_code(agent, GAP_AGENT_ACCEPT, pin_code,
+ NULL);
+ goto done;
} else {
BT_DBG("Show Pin entry");
-
- if (syspopup_mode) {
- BT_DBG("LAUNCH SYSPOPUP");
- _bt_launch_system_popup(BT_AGENT_EVENT_PIN_REQUEST, name, NULL,
- NULL, _gap_agent_get_path(agent));
- } else {
- BT_DBG("Send BLUETOOTH_EVENT_PIN_REQUEST");
- param = g_variant_new("(iss)", result, address, name);
- _bt_send_event(BT_ADAPTER_EVENT,
- BLUETOOTH_EVENT_PIN_REQUEST, param);
- }
+ _bt_launch_system_popup(BT_AGENT_EVENT_PIN_REQUEST, name, auth_info,
+ NULL, NULL, _gap_agent_get_path(agent));
}
done:
g_variant_unref(reply);
g_variant_unref(reply_temp);
+ g_free(address);
+ g_free(name);
__bt_agent_release_memory();
BT_DBG("-");
static gboolean __passkey_request(GapAgentPrivate *agent, GDBusProxy *device)
{
- const gchar *address;
- const gchar *name;
+ gchar *address = NULL;
+ gchar *name = NULL;
+ unsigned char auth_info[5] = {0, };
GVariant *reply = NULL;
GVariant *reply_temp = NULL;
GVariant *tmp_value;
BT_DBG("+");
+#ifdef TIZEN_DPM_ENABLE
+ if (_bt_dpm_get_bluetooth_pairing_state() == DPM_RESTRICTED) {
+ BT_ERR("Not allow to pair the device");
+ gap_agent_reply_confirmation(agent, GAP_AGENT_REJECT, NULL);
+ __bt_agent_release_memory();
+ return TRUE;
+ }
+#endif
+
reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
if (reply_temp == NULL) {
goto done;
}
- g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+ g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/
- tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+ tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING);
g_variant_get(tmp_value, "s", &address);
G_VARIANT_UNREF(tmp_value);
if (!address) {
g_variant_get(tmp_value, "s", &name);
G_VARIANT_UNREF(tmp_value);
if (!name)
- name = address;
-
-#ifdef AUTO_ACCEPT
- gap_agent_reply_pin_code(agent, GAP_AGENT_ACCEPT, "0000",
- NULL);
-#else
- if (syspopup_mode) {
- BT_DBG("LAUNCH SYSPOPUP");
- _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_REQUEST, name, NULL, NULL,
- _gap_agent_get_path(agent));
- } else {
- int result = BLUETOOTH_ERROR_NONE;
- GVariant *param;
+ name = g_strdup(address);
- BT_DBG("Send BLUETOOTH_EVENT_PASSKEY_REQUEST");
- param = g_variant_new("(iss)", result, address, name);
- _bt_send_event(BT_ADAPTER_EVENT,
- BLUETOOTH_EVENT_PASSKEY_REQUEST, param);
- }
-#endif
+ __bt_get_auth_info(reply, (char *)auth_info);
+
+ _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_REQUEST, name, auth_info,
+ NULL, NULL, _gap_agent_get_path(agent));
done:
g_variant_unref(reply);
g_variant_unref(reply_temp);
+ g_free(address);
+ g_free(name);
__bt_agent_release_memory();
BT_DBG("-");
static gboolean __display_request(GapAgentPrivate *agent, GDBusProxy *device,
guint passkey)
{
- const gchar *address;
- const gchar *name;
+ gchar *address = NULL;
+ gchar *name = NULL;
+ unsigned char auth_info[5] = {0, };
char *str_passkey;
GVariant *reply = NULL;
GVariant *reply_temp = NULL;
goto done;
}
- g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+ g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/
- tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+ tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING);
g_variant_get(tmp_value, "s", &address);
G_VARIANT_UNREF(tmp_value);
if (!address) {
g_variant_get(tmp_value, "s", &name);
G_VARIANT_UNREF(tmp_value);
if (!name)
- name = address;
+ name = g_strdup(address);
- str_passkey = g_strdup_printf("%d", passkey);
+ __bt_get_auth_info(reply, (char *)auth_info);
-#ifdef AUTO_ACCEPT
- gap_agent_reply_pin_code(agent, GAP_AGENT_ACCEPT, str_passkey,
- NULL);
-#else
- if (syspopup_mode) {
- BT_DBG("LAUNCH SYSPOPUP");
- _bt_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, name,
- str_passkey, NULL,
- _gap_agent_get_path(agent));
- } else {
- int result = BLUETOOTH_ERROR_NONE;
- GVariant *param;
+ str_passkey = g_strdup_printf("%06d", passkey);
+
+ if (passkey_watcher) {
+ GVariant *param = NULL;
+
+ BT_INFO("Send passkey to %s", passkey_watcher);
- BT_DBG("Send BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY");
- param = g_variant_new("(isss)", result, address, name, str_passkey);
- _bt_send_event(BT_ADAPTER_EVENT,
- BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY, param);
+ param = g_variant_new("(ss)", address, str_passkey);
+
+ _bt_send_event_to_dest(passkey_watcher, BT_ADAPTER_EVENT,
+ BLUETOOTH_EVENT_PASSKEY_NOTIFICATION, param);
+ } else {
+ _bt_launch_system_popup(BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST, name,
+ auth_info, str_passkey, NULL,
+ _gap_agent_get_path(agent));
}
-#endif
g_free(str_passkey);
done:
g_variant_unref(reply);
g_variant_unref(reply_temp);
+ g_free(address);
+ g_free(name);
__bt_agent_release_memory();
BT_DBG("-");
static gboolean __confirm_request(GapAgentPrivate *agent, GDBusProxy *device,
guint passkey)
{
- const gchar *address;
- const gchar *name;
+ gchar *address = NULL;
+ gchar *name = NULL;
+ unsigned char auth_info[5] = {0, };
char str_passkey[7];
GVariant *reply_temp = NULL;
GVariant *reply = NULL;
GVariant *tmp_value;
BT_DBG("+ passkey[%.6d]", passkey);
+#ifdef TIZEN_DPM_ENABLE
+ if (_bt_dpm_get_bluetooth_pairing_state() == DPM_RESTRICTED) {
+ BT_ERR("Not allow to pair the device");
+ gap_agent_reply_confirmation(agent, GAP_AGENT_REJECT, NULL);
+ __bt_agent_release_memory();
+ return TRUE;
+ }
+#endif
+
snprintf(str_passkey, sizeof(str_passkey), "%.6d", passkey);
reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
goto done;
}
- g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+ g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/
- tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+ tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING);
g_variant_get(tmp_value, "s", &address);
G_VARIANT_UNREF(tmp_value);
if (!address) {
goto done;
}
- tmp_value = g_variant_lookup_value (reply, "Name", G_VARIANT_TYPE_STRING);
+ tmp_value = g_variant_lookup_value(reply, "Name", G_VARIANT_TYPE_STRING);
g_variant_get(tmp_value, "s", &name);
G_VARIANT_UNREF(tmp_value);
if (!name)
- name = address;
+ name = g_strdup(address);
+ __bt_get_auth_info(reply, (char *)auth_info);
-#ifdef TIZEN_WEARABLE
- uint32_t device_class = 0x00;
- uint32_t major_class;
-
- tmp_value = g_variant_lookup_value(reply, "Class", G_VARIANT_TYPE_UINT32);
- g_variant_get(tmp_value, "u", &device_class);
- G_VARIANT_UNREF(tmp_value);
-
- major_class = (device_class & 0x1f00) >> 8;
-
- if (major_class == BLUETOOTH_DEVICE_MAJOR_CLASS_AUDIO) {
- BT_DBG("Audio device. Launch passkey pop-up");
- _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST, name,
- str_passkey, NULL, _gap_agent_get_path(agent));
- goto done;
- }
-
- if (__is_reset_required(address)) {
- BT_INFO("Launch system reset pop-up");
- _bt_launch_system_popup(BT_AGENT_EVENT_SYSTEM_RESET_REQUEST, name,
- NULL, NULL, _gap_agent_get_path(agent));
- } else {
- BT_INFO("Launch passkey pop-up");
- _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_AUTO_ACCEPTED, name,
- str_passkey, NULL, _gap_agent_get_path(agent));
-
- gap_agent_reply_confirmation(agent, GAP_AGENT_ACCEPT, NULL);
- }
-#else
-#ifdef AUTO_ACCEPT
- BT_DBG("Confirm reply");
- gap_agent_reply_confirmation(agent, GAP_AGENT_ACCEPT, NULL);
-#else
- if (syspopup_mode) {
- BT_DBG("LAUNCH SYSPOPUP");
- _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST, name,
- str_passkey, NULL,
- _gap_agent_get_path(agent));
- } else {
- int result = BLUETOOTH_ERROR_NONE;
- GVariant *param;
-
- BT_DBG("Send BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST");
- param = g_variant_new("(isss)", result, address, name, str_passkey);
- _bt_send_event(BT_ADAPTER_EVENT,
- BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST, param);
- }
-#endif
-#endif
+ BT_DBG("LAUNCH SYSPOPUP");
+ _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST, name,
+ auth_info, str_passkey, NULL,
+ _gap_agent_get_path(agent));
done:
g_variant_unref(reply);
g_variant_unref(reply_temp);
+ g_free(address);
+ g_free(name);
__bt_agent_release_memory();
BT_DBG("-");
{
BT_DBG("On Going Pairing is cancelled by remote\n");
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
syspopup_destroy_all();
-#endif
__bt_agent_release_memory();
static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device,
const char *uuid)
{
- const gchar *address;
- const gchar *name;
+ gchar *address = NULL;
+ gchar *name = NULL;
+ unsigned char auth_info[5] = {0, };
gboolean trust;
- gboolean paired;
GVariant *reply = NULL;
GVariant *reply_temp = NULL;
GVariant *tmp_value;
-#ifdef TIZEN_NETWORK_TETHERING_ENABLE
+#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
bool enabled;
tethering_h tethering = NULL;
#endif
int result = BLUETOOTH_ERROR_NONE;
-#ifndef AUTO_ACCEPT
int request_type = BT_AGENT_EVENT_AUTHORIZE_REQUEST;
-#endif
BT_DBG("+");
-#ifdef AUTO_ACCEPT
- gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT,
- NULL);
- goto done;
-#endif
-
/* Check if already Media connection exsist */
if (!strcasecmp(uuid, A2DP_UUID)) {
gboolean ret = FALSE;
!strcasecmp(uuid, HSP_HS_UUID) ||
!strcasecmp(uuid, A2DP_UUID) ||
!strcasecmp(uuid, HID_UUID) ||
+ !strcasecmp(uuid, HID_DEVICE_UUID) ||
!strcasecmp(uuid, SAP_UUID_OLD) ||
!strcasecmp(uuid, SAP_UUID_NEW) ||
+ !strcasecmp(uuid, IOTIVITY_UUID) ||
!strcasecmp(uuid, AVRCP_TARGET_UUID)) {
BT_DBG("Auto accept authorization for audio device (HFP, A2DP, AVRCP) [%s]", uuid);
gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT,
!strcasecmp(uuid, BNEP_UUID)) {
BT_DBG("Network connection request: %s", uuid);
-#ifdef TIZEN_NETWORK_TETHERING_ENABLE
+#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
if (nap_connected_device_count >=
BT_PAN_MAX_CONNECTION) {
BT_ERR("Max connection exceeded");
ret = tethering_destroy(tethering);
- if (ret != TETHERING_ERROR_NONE) {
+ if (ret != TETHERING_ERROR_NONE)
BT_ERR("Fail to create tethering: %d", ret);
- }
if (enabled != true) {
BT_ERR("BT tethering is not enabled");
gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT,
NULL);
goto done;
-#ifdef TIZEN_NETWORK_TETHERING_ENABLE
+#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
fail:
gap_agent_reply_authorize(agent, GAP_AGENT_REJECT,
NULL);
goto done;
}
- g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+ g_variant_get(reply_temp, "(@a{sv})", &reply); /* Format of reply a{sv}*/
- tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+ tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING);
g_variant_get(tmp_value, "s", &address);
G_VARIANT_UNREF(tmp_value);
if (!address) {
g_variant_get(tmp_value, "s", &name);
G_VARIANT_UNREF(tmp_value);
if (!name)
- name = address;
+ name = g_strdup(address);
tmp_value = g_variant_lookup_value(reply, "Trusted", G_VARIANT_TYPE_BOOLEAN);
g_variant_get(tmp_value, "b", &trust);
G_VARIANT_UNREF(tmp_value);
- tmp_value = g_variant_lookup_value(reply, "Paired", G_VARIANT_TYPE_BOOLEAN);
- g_variant_get(tmp_value, "b", &paired);
- G_VARIANT_UNREF(tmp_value);
- if ((paired == FALSE) && (trust == FALSE)) {
- BT_ERR("No paired & No trusted device");
- gap_agent_reply_authorize(agent,
- GAP_AGENT_REJECT, NULL);
- goto done;
- }
+ __bt_get_auth_info(reply, (char *)auth_info);
BT_INFO("Authorization request for device [%s] Service:[%s]\n", address, uuid);
goto done;
}
+ if (!strcasecmp(uuid, OPP_UUID))
+ request_type = BT_AGENT_EVENT_EXCHANGE_REQUEST;
+ else if (!strcasecmp(uuid, PBAP_UUID))
+ request_type = BT_AGENT_EVENT_PBAP_REQUEST;
+ else if (!strcasecmp(uuid, MAP_UUID))
+ request_type = BT_AGENT_EVENT_MAP_REQUEST;
+
if (trust) {
BT_INFO("Trusted device, so authorize\n");
gap_agent_reply_authorize(agent,
- GAP_AGENT_ACCEPT, NULL);
+ GAP_AGENT_ACCEPT, NULL);
} else {
-#ifdef AUTO_ACCEPT
- gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT, NULL);
-#else
- if (!strcasecmp(uuid, OPP_UUID))
- request_type = BT_AGENT_EVENT_EXCHANGE_REQUEST;
- else if (!strcasecmp(uuid, PBAP_UUID))
- request_type = BT_AGENT_EVENT_PBAP_REQUEST;
- else if (!strcasecmp(uuid, MAP_UUID))
- request_type = BT_AGENT_EVENT_MAP_REQUEST;
-
- _bt_launch_system_popup(request_type, name, NULL, NULL,
- _gap_agent_get_path(agent));
-#endif
+ _bt_launch_system_popup(request_type, name, auth_info, NULL, NULL,
+ _gap_agent_get_path(agent));
}
done:
- g_variant_unref(reply);
- g_variant_unref(reply_temp);
+ if (reply)
+ g_variant_unref(reply);
+
+ if (reply_temp)
+ g_variant_unref(reply_temp);
+
+ g_free(name);
+ g_free(address);
__bt_agent_release_memory();
BT_DBG("-");
gap_agent_reply_authorize(agent, GAP_AGENT_CANCEL, NULL);
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
syspopup_destroy_all();
-#endif
__bt_agent_release_memory();
rewind(fp);
buffer = g_malloc0(sizeof(char) * size);
- /* Fix : NULL_RETURNS */
- if (buffer == NULL) {
- BT_ERR("Fail to allocate memory");
- fclose(fp);
- return FALSE;
- }
result = fread((char *)buffer, 1, size, fp);
fclose(fp);
if (result != size) {
return 0;
}
+
+int _bt_set_passkey_notification(const char *sender, gboolean enable)
+{
+ BT_INFO("Set passkey notification(sender:%s, %s)",
+ sender, enable ? "Enable" : "Disable");
+
+ g_free(passkey_watcher);
+ if (enable == TRUE)
+ passkey_watcher = g_strdup(sender);
+ else
+ passkey_watcher = NULL;
+
+ return BLUETOOTH_ERROR_NONE;
+}