diff --git a/src/device.c b/src/device.c
index d4c1e23..5cb5460 100644
--- a/src/device.c
+++ b/src/device.c
device->connect = NULL;
}
- if (msg)
+ if (device->connected && msg)
device->disconnects = g_slist_append(device->disconnects,
dbus_message_ref(msg));
g_free(data);
}
+ if (!device->connected) {
+ g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID);
+ return;
+ }
+
device->disconn_timer = g_timeout_add_seconds(DISCONNECT_TIMER,
do_disconnect, device);
}
-static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
+static DBusMessage *dev_disconnect(DBusConnection *conn, DBusMessage *msg,
void *user_data)
{
struct btd_device *device = user_data;
- if (!device->connected)
- return btd_error_not_connected(msg);
-
/*
* Disable connections through passive scanning until
* Device1.Connect is called
}
static const GDBusMethodTable device_methods[] = {
- { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, disconnect) },
+ { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, dev_disconnect) },
{ GDBUS_ASYNC_METHOD("Connect", NULL, NULL, dev_connect) },
{ GDBUS_ASYNC_METHOD("ConnectProfile", GDBUS_ARGS({ "UUID", "s" }),
NULL, connect_profile) },
struct btd_device *device = btd_service_get_device(service);
int err = btd_service_get_error(service);
+ if (new_state == BTD_SERVICE_STATE_CONNECTING ||
+ new_state == BTD_SERVICE_STATE_DISCONNECTING)
+ return;
+
if (old_state == BTD_SERVICE_STATE_CONNECTING)
device_profile_connected(device, profile, err);
else if (old_state == BTD_SERVICE_STATE_DISCONNECTING)
diff --git a/src/service.c b/src/service.c
index aef9502..83e1c1a 100644
--- a/src/service.c
+++ b/src/service.c
if (err == 0)
return 0;
+ if (err == -ENOTCONN) {
+ btd_service_disconnecting_complete(service, 0);
+ return 0;
+ }
+
ba2str(device_get_address(service->device), addr);
error("%s profile disconnect failed for %s: %s", profile->name, addr,
strerror(-err));