X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-service%2Fbt-service-agent.c;h=6e39de77887a3d84ab22c5dd89a2d25d247e09f5;hb=3141a2e5c63151fe6d765bdb6e41d2c9b3ad89b9;hp=88db75a1afce5b4f4c391d297ba1f4ee72e8bfc2;hpb=2526bd7df935a0330d8ad5b5649f9935035ef652;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-service/bt-service-agent.c b/bt-service/bt-service-agent.c index 88db75a..6e39de7 100644 --- a/bt-service/bt-service-agent.c +++ b/bt-service/bt-service-agent.c @@ -73,7 +73,7 @@ extern guint nap_connected_device_count; -static char *passkey_watcher = NULL; +static char *passkey_watcher; #define G_VARIANT_UNREF(variant) \ g_variant_unref(variant); \ @@ -482,6 +482,37 @@ static gboolean __a2dp_authorize_request_check(void) return _bt_is_headset_type_connected(BT_AUDIO_A2DP, NULL); } +static gboolean __bt_agent_is_hid_device_connectable(void) +{ + GDBusProxy *proxy = NULL; + GVariant *reply = NULL; + GError *err = NULL; + gboolean connectable = FALSE; + + proxy = _bt_gdbus_get_hid_agent_proxy(); + retv_if(proxy == NULL, FALSE); + + reply = g_dbus_proxy_call_sync(proxy, "IsHidConnectable", NULL, + G_DBUS_CALL_FLAGS_NONE, 2000, NULL, &err); + if (reply == NULL) { + BT_ERR("Error returned in method call"); + if (err != NULL) { + BT_ERR("Error message = %s", err->message); + g_error_free(err); + } + connectable = FALSE; + } else { + g_variant_get(reply, "(b)", &connectable); + g_variant_unref(reply); + } + g_object_unref(proxy); + + BT_INFO("HID Device is %s", + connectable ? "Connectable" : "Non-connectable"); + + return connectable; +} + static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device, const char *uuid) { @@ -512,12 +543,22 @@ static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device, } /* Check completed */ + if (!strcasecmp(uuid, HID_UUID)) { + gboolean is_connectable = __bt_agent_is_hid_device_connectable(); + BT_DBG("Automatically %s authorization for HID", + is_connectable ? "accept" : "reject"); + if (is_connectable == TRUE) + gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT, NULL); + else + gap_agent_reply_authorize(agent, GAP_AGENT_REJECT, NULL); + goto done; + } + if (!strcasecmp(uuid, HFP_AUDIO_GATEWAY_UUID) || !strcasecmp(uuid, HSP_AUDIO_GATEWAY_UUID) || !strcasecmp(uuid, HFP_HS_UUID) || !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) ||