return FALSE;
server = g_malloc0(sizeof(bt_agent_osp_server_t));
-
- /* Fix : NULL_RETURNS */
- retv_if(server == NULL, FALSE);
-
server->type = type;
if (type == BT_RFCOMM_SERVER) {
server->uuid = g_strdup(uuid);
BT_DBG("+");
GapAgentPrivate *priv = agent;
-
- /* Fix : NULL_RETURNS */
retv_if(priv == NULL, FALSE);
if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
BT_DBG("+");
GapAgentPrivate *priv = agent;
-
- /* Fix : NULL_RETURNS */
retv_if(priv == NULL, FALSE);
if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
BT_DBG("+");
GapAgentPrivate *priv = agent;
-
- /* Fix : NULL_RETURNS */
retv_if(priv == NULL, FALSE);
if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
BT_DBG("+");
GapAgentPrivate *priv = agent;
-
- /* Fix : NULL_RETURNS */
retv_if(priv == NULL, FALSE);
if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
if (accept == GAP_AGENT_ACCEPT) {
g_dbus_method_invocation_return_value(priv->reply_context, NULL);
} else if (accept == GAP_AGENT_ACCEPT_ALWAYS) {
- bluetooth_device_address_t addr = {{0,}};
+ bluetooth_device_address_t addr = { { 0, } };
int result;
_bt_convert_addr_string_to_type(addr.addr,
priv->authorize_addr);
- result = _bt_set_authorization(&addr, TRUE);
+ /* Do not set device as Trusted*/
+ /* result = _bt_set_authorization(&addr, TRUE); */
+ result = _bt_set_trust_profile(&addr,
+ _bt_get_trusted_profile_enum(priv->uuid),
+ TRUE);
if (result == BLUETOOTH_ERROR_NONE) {
- BT_INFO("[%s] Device added to trusted", priv->authorize_addr);
+ BT_INFO("[%s] Profile added as trusted for Device[%s]",
+ priv->uuid, priv->authorize_addr);
}
g_dbus_method_invocation_return_value(priv->reply_context, NULL);
GAP_AGENT_ERROR, GAP_AGENT_ERROR_CANCEL,
"CanceledbyUser");
break;
+ case GAP_AGENT_REJECT: {
+ bluetooth_device_address_t addr = { { 0, } };
+ int result;
+
+ _bt_convert_addr_string_to_type(addr.addr,
+ priv->authorize_addr);
+
+ /* Set Profile as blocked */
+ result = _bt_set_trust_profile(&addr,
+ _bt_get_trusted_profile_enum(priv->uuid),
+ FALSE);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ BT_INFO("[%s] Profile added as blocked for Device[%s]",
+ priv->uuid, priv->authorize_addr);
+ }
+
+ g_dbus_method_invocation_return_error(priv->reply_context,
+ GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+ "Authorization request rejected");
+ break;
+ }
case GAP_AGENT_TIMEOUT:
- case GAP_AGENT_REJECT:
default:
g_dbus_method_invocation_return_error(priv->reply_context,
GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
ret = FALSE;
}
- priv->exec_type = GAP_AGENT_EXEC_NO_OPERATION;
- priv->reply_context = NULL;
- memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+ if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION) {
+ priv->exec_type = GAP_AGENT_EXEC_NO_OPERATION;
+ priv->reply_context = NULL;
+ memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+ g_free(priv->uuid);
+ priv->uuid = NULL;
+ }
BT_DBG("-");
reply = g_dbus_proxy_call_sync(agent_manager, "RegisterAgent",
#ifdef TIZEN_BT_IO_CAPA_NO_INPUT_OUTPUT
g_variant_new("(os)", priv->path, "NoInputNoOutput"),
+#elif defined(TIZEN_BT_IO_CAPA_DISPLAY_ONLY)
+ g_variant_new("(os)", priv->path, "DisplayOnly"),
#else
- g_variant_new("(os)", priv->path, "DisplayYesNo"),
+ g_variant_new("(os)", priv->path, "KeyboardDisplay"),
#endif
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
}
reply = g_dbus_proxy_call_sync(agent_manager, "UnregisterAgent",
- g_variant_new("o", priv->path),
+ g_variant_new("(o)", priv->path),
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
g_object_unref(agent_manager);
static const gchar gap_agent_bluez_introspection_xml[] =
"<node name='/'>"
" <interface name='org.bluez.Agent1'>"
-" <method name='GetDiscoverableTimeout'>"
-" <arg type='u' name='timeout' direction='out'/>"
-" </method>"
-" <method name='Cancel'>"
-" </method>"
-" <method name='RequestPasskey'>"
-" <arg type='o' name='device' direction='in'/>"
-" <arg type='u' name='passkey' direction='out'/>"
-" </method>"
-" <method name='Release'>"
-" </method>"
" <method name='RequestConfirmation'>"
-" <arg type='o' name='device' direction='in'/>"
+" <arg type='o' name='target' direction='in'/>"
" <arg type='u' name='passkey' direction='in'/>"
" </method>"
+" <method name='RequestPinCode'>"
+" <arg type='o' name='target' direction='in'/>"
+" <arg type='s' name='pincode' direction='out'/>"
+" </method>"
" <method name='RequestAuthorization'>"
-" <arg type='o' name='device' direction='in'/>"
+" <arg type='o' name='target' direction='in'/>"
" </method>"
-" <method name='ReplyPasskey'>"
-" <arg type='u' name='accept' direction='in'/>"
-" <arg type='s' name='passkey' direction='in'/>"
+" <method name='RequestPasskey'>"
+" <arg type='o' name='target' direction='in'/>"
+" <arg type='u' name='passkey' direction='out'/>"
+" </method>"
+" <method name='AuthorizeService'>"
+" <arg type='o' name='target' direction='in'/>"
+" <arg type='s' name='uuid' direction='in'/>"
+" </method>"
+" <method name='DisplayPasskey'>"
+" <arg type='o' name='target' direction='in'/>"
+" <arg type='u' name='passkey' direction='in'/>"
+" <arg type='q' name='entered' direction='in'/>"
" </method>"
-" <method name='DisplayPasskey'>"
-" <arg type='o' name='device' direction='in'/>"
-" <arg type='u' name='passkey' direction='in'/>"
-" <arg type='q' name='entered' direction='in'/>"
+" <method name='ReplyConfirmation'>"
+" <arg type='u' name='accept' direction='in'/>"
" </method>"
-" <method name='ReplyConfirmation'>"
+" <method name='ReplyPinCode'>"
" <arg type='u' name='accept' direction='in'/>"
+" <arg type='s' name='pincode' direction='in'/>"
" </method>"
-" <method name='ReplyPinCode'>"
+" <method name='ReplyAuthorize'>"
" <arg type='u' name='accept' direction='in'/>"
-" <arg type='s' name='pincode' direction='in'/>"
" </method>"
-" <method name='ReplyAuthorize'>"
+" <method name='ReplyPasskey'>"
" <arg type='u' name='accept' direction='in'/>"
+" <arg type='s' name='passkey' direction='in'/>"
" </method>"
-" <method name='RequestPinCode'>"
-" <arg type='o' name='device' direction='in'/>"
-" <arg type='s' name='pincode' direction='out'/>"
+" <method name='GetDiscoverableTimeout'>"
+" <arg type='u' name='timeout' direction='out'/>"
" </method>"
" <method name='ConfirmModeChange'>"
" <arg type='s' name='mode' direction='in'/>"
" </method>"
-" <method name='AuthorizeService'>"
-" <arg type='o' name='device' direction='in'/>"
-" <arg type='s' name='uuid' direction='in'/>"
+" <method name='Cancel'>"
+" </method>"
+" <method name='Release'>"
" </method>"
" </interface>"
"</node>";
if (!agent->cb.passkey_func)
return;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL)
return;
addr += 4;
g_strlcpy(agent->pairing_addr, addr, sizeof(agent->pairing_addr));
- while ((pos = strchr(agent->pairing_addr, '_')) != NULL) {
+ while ((pos = strchr(agent->pairing_addr, '_')) != NULL)
*pos = ':';
- }
}
agent->cb.pincode_func(agent, device);
if (!priv->cb.passkey_func)
return;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL)
return;
addr += 4;
g_strlcpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr));
- while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
+ while ((pos = strchr(priv->pairing_addr, '_')) != NULL)
*pos = ':';
- }
}
priv->cb.passkey_func(priv, device);
g_variant_get(parameters, "(&ouq)", &path, &passkey, &entered);
BT_INFO("Request passkey display :sender %s priv->busname %s"
- " Device Path :%s, Passkey: %d, Entered: %d",
+ " Device Path :%s, Passkey: %06d, Entered: %d",
sender, priv->busname, path, passkey, entered);
/* Do not show popup for Key event while typing*/
if (!priv->cb.display_func)
return;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL)
return;
return;
g_variant_get(parameters, "(&ou)", &path, &passkey);
- BT_INFO("Request passkey confirmation, Device Path :%s, Passkey: %d",
- path, passkey);
+ BT_INFO_C("### Request passkey confirmation");
+ INFO_SECURE("Device Path :%s, Passkey: %d", path, passkey);
BT_DBG("Sender: [%s] priv->busname: [%s]", sender, priv->busname);
/* Need to check
if (!priv->cb.confirm_func)
return;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL)
return;
addr += 4;
g_strlcpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr));
- while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
+ while ((pos = strchr(priv->pairing_addr, '_')) != NULL)
*pos = ':';
- }
}
priv->cb.confirm_func(priv, device, passkey);
if (!priv->cb.authorize_func)
return;
- conn = _bt_get_system_gconn();
+ conn = _bt_gdbus_get_system_gconn();
if (conn == NULL)
return;
priv->exec_type = GAP_AGENT_EXEC_AUTHORZATION;
priv->reply_context = invocation;
+ priv->uuid = g_strdup(uuid);
addr = strstr(path, "dev_");
if (addr != NULL) {
g_strlcpy(priv->authorize_addr, addr,
sizeof(priv->authorize_addr));
- while ((pos = strchr(priv->authorize_addr, '_')) != NULL) {
+ while ((pos = strchr(priv->authorize_addr, '_')) != NULL)
*pos = ':';
- }
}
priv->cb.authorize_func(priv, device, uuid);
GDBusNodeInfo *node_info;
GError *error = NULL;
-
priv->path = g_strdup(path);
BT_DBG("path is [%s]", path);
- connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (!connection) {
- if (error) {
- ERR("Unable to connect to gdbus: %s", error->message);
- g_clear_error(&error);
+ if (connection == NULL) {
+ connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (!connection) {
+ if (error) {
+ ERR("Unable to connect to gdbus: %s", error->message);
+ g_clear_error(&error);
+ }
+ g_dbus_node_info_unref(node_info);
+ return;
}
- g_dbus_node_info_unref(node_info);
- return;
}
if (gap_agent_id == -1) {
priv->busname = NULL;
} else {
priv->busname = g_strdup(g_dbus_proxy_get_name(proxy));
- g_object_unref(proxy);
BT_DBG("Busname: %s", priv->busname);
+ g_object_unref(proxy);
}
}
void _gap_agent_reset_dbus(GapAgentPrivate *agent)
{
GapAgentPrivate *priv = agent;
-
- /* Fix : NULL_RETURNS */
if (priv == NULL)
- return ;
+ return;
__gap_agent_unregister(agent);
if (gap_agent_id > 0) {
g_dbus_connection_unregister_object(connection,
gap_agent_id);
- gap_agent_id = 0;
+ gap_agent_id = -1;
+ }
+
+ if (connection) {
+ g_object_unref(connection);
+ connection = NULL;
}
if (priv->osp_servers) {
priv->osp_servers = NULL;
}
- g_object_ref(priv->adapter);
- priv->adapter = NULL;
-
g_free(priv->path);
priv->path = NULL;
{
GapAgentPrivate *priv = agent;
- /* Fix : NULL_RETURNS */
- retv_if(priv == NULL, FALSE);
+ if (priv == NULL)
+ return FALSE;
if (__gap_agent_find_server(priv->osp_servers,
type, uuid) != NULL) {
osp_serv = __gap_agent_find_server(priv->osp_servers,
type, uuid);
- if (!osp_serv) {
+ if (!osp_serv)
return NULL;
- }
return osp_serv;
}
gchar* _gap_agent_get_path(GapAgentPrivate *agent)
{
GapAgentPrivate *priv = agent;
-
- /* Fix : NULL_RETURNS */
if (priv == NULL)
return NULL;
{
GapAgentPrivate *priv = agent;
- /* Fix : NULL_RETURNS */
- retv_if(priv == NULL, FALSE);
-
return priv->canceled;
}
void _gap_agent_set_canceled(GapAgentPrivate *agent, gboolean value)
{
GapAgentPrivate *priv = agent;
-
- /* Fix : NULL_RETURNS */
if (priv == NULL)
return;