static void set_discoverable(struct btd_adapter *adapter,
gboolean discoverable, GDBusPendingPropertySet id)
{
- DBusConnection *conn = btd_get_dbus_connection();
uint8_t mode;
int err;
if (mode == adapter->mode) {
adapter->global_mode = mode;
- return g_dbus_pending_property_success(conn, id);
+ return g_dbus_pending_property_success(id);
}
err = set_mode(adapter, mode);
if (err < 0)
- return g_dbus_pending_property_error(conn, id,
+ return g_dbus_pending_property_error(id,
ERROR_INTERFACE ".Failed",
strerror(-err));
static void set_powered(struct btd_adapter *adapter, gboolean powered,
GDBusPendingPropertySet id)
{
- DBusConnection *conn = btd_get_dbus_connection();
uint8_t mode;
int err;
if (mode == adapter->mode) {
adapter->global_mode = mode;
- return g_dbus_pending_property_success(conn, id);
+ return g_dbus_pending_property_success(id);
}
err = set_mode(adapter, mode);
if (err < 0)
- return g_dbus_pending_property_error(conn, id,
+ return g_dbus_pending_property_error(id,
ERROR_INTERFACE ".Failed",
strerror(-err));
static void set_pairable(struct btd_adapter *adapter, gboolean pairable,
bool reply, GDBusPendingPropertySet id)
{
- DBusConnection *conn = btd_get_dbus_connection();
int err;
if (adapter->scan_mode == SCAN_DISABLED)
- return g_dbus_pending_property_error(conn, id,
+ return g_dbus_pending_property_error(id,
ERROR_INTERFACE ".NotReady",
"Resource Not Ready");
err = set_mode(adapter, MODE_DISCOVERABLE);
if (err < 0) {
if (reply)
- g_dbus_pending_property_error(conn, id,
+ g_dbus_pending_property_error(id,
ERROR_INTERFACE ".Failed",
strerror(-err));
return;
done:
if (reply)
- g_dbus_pending_property_success(conn, id);
+ g_dbus_pending_property_success(id);
}
static gboolean pairable_timeout_handler(void *data)
DBusConnection *conn = btd_get_dbus_connection();
if (adapter->discov_timeout == timeout && timeout == 0)
- return g_dbus_pending_property_success(conn, id);
+ return g_dbus_pending_property_success(id);
if (adapter->scan_mode & SCAN_INQUIRY)
mgmt_set_discoverable(adapter->dev_id, TRUE, timeout);
g_dbus_emit_property_changed(conn, adapter->path, ADAPTER_INTERFACE,
"DiscoverableTimeout");
- g_dbus_pending_property_success(conn, id);
+ g_dbus_pending_property_success(id);
}
static void set_pairable_timeout(struct btd_adapter *adapter,
DBusConnection *conn = btd_get_dbus_connection();
if (adapter->pairable_timeout == timeout && timeout == 0)
- return g_dbus_pending_property_success(conn, id);
+ return g_dbus_pending_property_success(id);
if (adapter->pairable)
adapter_set_pairable_timeout(adapter, timeout);
g_dbus_emit_property_changed(conn, adapter->path, ADAPTER_INTERFACE,
"PairableTimeout");
- g_dbus_pending_property_success(conn, id);
+ g_dbus_pending_property_success(id);
}
void btd_adapter_class_changed(struct btd_adapter *adapter, uint8_t *new_class)
int ret;
if (adapter->allow_name_changes == FALSE)
- return g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".Failed",
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".Failed",
strerror(EPERM));
ret = adapter_set_name(adapter, name);
- if (ret >= 0) {
- g_dbus_pending_property_success(btd_get_dbus_connection(), id);
- return;
- }
+ if (ret >= 0)
+ return g_dbus_pending_property_success(id);
if (ret == -EINVAL)
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
+ g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
else
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".Failed",
- strerror(-ret));
+ g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed",
+ strerror(-ret));
}
struct btd_device *adapter_find_device(struct btd_adapter *adapter,
{
const char *name;
- if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING) {
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
- return;
- }
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING)
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &name);
dbus_bool_t powered;
if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN)
- return g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &powered);
dbus_bool_t discoverable;
if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN)
- return g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &discoverable);
dbus_bool_t pairable;
if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN)
- return g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &pairable);
uint32_t timeout;
if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT32)
- return g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &timeout);
set_discoverable_timeout(data, timeout, id);
uint32_t timeout;
if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_UINT32)
- return g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &timeout);
set_pairable_timeout(data, timeout, id);
if (pending->type == SESSION_TYPE_MODE_GLOBAL) {
if (err < 0)
- g_dbus_pending_property_error(conn, pending->prop_id,
+ g_dbus_pending_property_error(pending->prop_id,
ERROR_INTERFACE ".Failed",
strerror(-err));
else {
adapter->global_mode = adapter->mode;
- g_dbus_pending_property_success(conn,
- pending->prop_id);
+ g_dbus_pending_property_success(pending->prop_id);
}
} else if (pending->msg != NULL) {
DBusMessage *msg = pending->msg;
/* No change */
if ((device->alias == NULL && g_str_equal(alias, "")) ||
- g_strcmp0(device->alias, alias) == 0) {
- g_dbus_pending_property_success(btd_get_dbus_connection(), id);
- return;
- }
+ g_strcmp0(device->alias, alias) == 0)
+ return g_dbus_pending_property_success(id);
ba2str(adapter_get_address(adapter), srcaddr);
ba2str(&device->bdaddr, dstaddr);
/* Remove alias if empty string */
err = write_device_alias(srcaddr, dstaddr, device->bdaddr_type,
g_str_equal(alias, "") ? NULL : alias);
- if (err < 0) {
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".Failed", strerror(-err));
- return;
- }
+ if (err < 0)
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".Failed", strerror(-err));
g_free(device->alias);
device->alias = g_str_equal(alias, "") ? NULL : g_strdup(alias);
g_dbus_emit_property_changed(btd_get_dbus_connection(),
device->path, DEVICE_INTERFACE, "Alias");
- g_dbus_pending_property_success(btd_get_dbus_connection(), id);
+ g_dbus_pending_property_success(id);
}
static void dev_property_set_alias(const GDBusPropertyTable *property,
{
const char *alias;
- if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING) {
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
- return;
- }
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_STRING)
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &alias);
char srcaddr[18], dstaddr[18];
int err;
- if (device->trusted == value) {
- g_dbus_pending_property_success(btd_get_dbus_connection(), id);
- return;
- }
+ if (device->trusted == value)
+ return g_dbus_pending_property_success(id);
ba2str(adapter_get_address(adapter), srcaddr);
ba2str(&device->bdaddr, dstaddr);
err = write_trust(srcaddr, dstaddr, device->bdaddr_type, value);
- if (err < 0) {
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".Failed", strerror(-err));
- return;
- }
+ if (err < 0)
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".Failed", strerror(-err));
device->trusted = value;
g_dbus_emit_property_changed(btd_get_dbus_connection(),
device->path, DEVICE_INTERFACE, "Trusted");
- g_dbus_pending_property_success(btd_get_dbus_connection(), id);
+ g_dbus_pending_property_success(id);
}
static void dev_property_set_trusted(const GDBusPropertyTable *property,
{
dbus_bool_t b;
- if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN) {
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
- return;
- }
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN)
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &b);
switch (-err) {
case 0:
- g_dbus_pending_property_success(btd_get_dbus_connection(), id);
+ g_dbus_pending_property_success(id);
break;
case EINVAL:
- g_dbus_pending_property_error(btd_get_dbus_connection(), id,
- ERROR_INTERFACE ".Failed",
+ g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed",
"Kernel lacks blacklist support");
break;
default:
- g_dbus_pending_property_error(btd_get_dbus_connection(), id,
- ERROR_INTERFACE ".Failed",
- strerror(-err));
+ g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed",
+ strerror(-err));
break;
}
}
{
dbus_bool_t b;
- if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN) {
- g_dbus_pending_property_error(btd_get_dbus_connection(),
- id, ERROR_INTERFACE ".InvalidArguments",
- "Invalid arguments in method call");
- return;
- }
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN)
+ return g_dbus_pending_property_error(id,
+ ERROR_INTERFACE ".InvalidArguments",
+ "Invalid arguments in method call");
dbus_message_iter_get_basic(value, &b);