#define LIST_ADAPTERS "ListAdapters"
#define ADAPTER_ADDED "AdapterAdded"
#define ADAPTER_REMOVED "AdapterRemoved"
+#define DEVICE_REMOVED "DeviceRemoved"
#define PROPERTY_CHANGED "PropertyChanged"
#define GET_PROPERTIES "GetProperties"
return TRUE;
}
+static gboolean device_removed(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *network_path;
+ DBusMessageIter iter;
+
+ DBG("");
+
+ if (dbus_message_iter_init(message, &iter) == FALSE)
+ return TRUE;
+
+ dbus_message_iter_get_basic(&iter, &network_path);
+
+ g_hash_table_remove(bluetooth_networks, network_path);
+
+ return TRUE;
+}
+
static gboolean device_changed(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
connman_device_unref(device);
}
+static void unregister_network(gpointer data)
+{
+ struct connman_network *network = data;
+ struct connman_device *device;
+ const char *identifier;
+
+ device = connman_network_get_device(network);
+ if (device == NULL)
+ return;
+
+ identifier = connman_network_get_identifier(network);
+
+ connman_device_remove_network(device, identifier);
+}
+
static void bluetooth_connect(DBusConnection *connection, void *user_data)
{
DBusMessage *message;
g_free, unregister_device);
bluetooth_networks = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, NULL);
+ g_free, unregister_network);
message = dbus_message_new_method_call(BLUEZ_SERVICE, "/",
BLUEZ_MANAGER_INTERFACE, LIST_ADAPTERS);
static guint removed_watch;
static guint adapter_watch;
static guint device_watch;
+static guint device_removed_watch;
static guint network_watch;
static int bluetooth_init(void)
PROPERTY_CHANGED, adapter_changed,
NULL, NULL);
+ device_removed_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ BLUEZ_ADAPTER_INTERFACE,
+ DEVICE_REMOVED, device_removed,
+ NULL, NULL);
+
device_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
BLUEZ_DEVICE_INTERFACE,
PROPERTY_CHANGED, device_changed,
if (watch == 0 || added_watch == 0 || removed_watch == 0
|| adapter_watch == 0 || network_watch == 0
- || device_watch == 0) {
+ || device_watch == 0
+ || device_removed_watch == 0) {
err = -EIO;
goto remove;
}
g_dbus_remove_watch(connection, added_watch);
g_dbus_remove_watch(connection, removed_watch);
g_dbus_remove_watch(connection, adapter_watch);
+ g_dbus_remove_watch(connection, device_removed_watch);
g_dbus_remove_watch(connection, device_watch);
g_dbus_remove_watch(connection, network_watch);
g_dbus_remove_watch(connection, added_watch);
g_dbus_remove_watch(connection, removed_watch);
g_dbus_remove_watch(connection, adapter_watch);
+ g_dbus_remove_watch(connection, device_removed_watch);
g_dbus_remove_watch(connection, device_watch);
g_dbus_remove_watch(connection, network_watch);