X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-service%2Fbt-service-agent.c;h=c65d60272abf872eea648dd3406bd579dd794165;hb=ef37826b533977ba5733483d588ce83ddd2618c7;hp=7eef8dcb06bbfe360c8fbc081f8b547e8f3372e6;hpb=39a4d8134daca84979cc67d4c9b5d552c54d2bca;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-service/bt-service-agent.c b/bt-service/bt-service-agent.c old mode 100755 new mode 100644 index 7eef8dc..c65d602 --- a/bt-service/bt-service-agent.c +++ b/bt-service/bt-service-agent.c @@ -46,6 +46,10 @@ #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 @@ -389,6 +393,15 @@ static gboolean __pincode_request(GapAgentPrivate *agent, GDBusProxy *device) 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) { @@ -397,7 +410,7 @@ static gboolean __pincode_request(GapAgentPrivate *agent, GDBusProxy *device) 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); @@ -488,6 +501,15 @@ static gboolean __passkey_request(GapAgentPrivate *agent, GDBusProxy *device) 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) { @@ -496,9 +518,9 @@ static gboolean __passkey_request(GapAgentPrivate *agent, GDBusProxy *device) 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) { @@ -559,9 +581,9 @@ static gboolean __display_request(GapAgentPrivate *agent, GDBusProxy *device, 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) { @@ -619,6 +641,15 @@ static gboolean __confirm_request(GapAgentPrivate *agent, GDBusProxy *device, 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); @@ -630,9 +661,9 @@ static gboolean __confirm_request(GapAgentPrivate *agent, GDBusProxy *device, 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) { @@ -640,7 +671,7 @@ static gboolean __confirm_request(GapAgentPrivate *agent, GDBusProxy *device, 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) @@ -739,7 +770,9 @@ static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device, tethering_h tethering = NULL; #endif int result = BLUETOOTH_ERROR_NONE; +#ifndef AUTO_ACCEPT int request_type = BT_AGENT_EVENT_AUTHORIZE_REQUEST; +#endif BT_DBG("+"); @@ -832,9 +865,9 @@ fail: 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) { @@ -890,23 +923,23 @@ fail: 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)); + _gap_agent_get_path(agent)); #endif }