summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-20 13:23:59 +0200
committerThomas Haller <thaller@redhat.com>2014-07-30 01:26:13 +0200
commit95fd061dbbebba3629fc1bb092c57d301f69ccfe (patch)
treef0b1da80e594177d9c1bda46d8a1fd4f25416865
parent29e620f5d203ce6db986949ec9b0c2144db18ece (diff)
downloadNetworkManager-95fd061dbbebba3629fc1bb092c57d301f69ccfe.tar.gz
bluez: simplify cleanup of generated PAN connection
For PAN devices we create an unsaved connection if no matching connection exists. After the device gets removed, we want to clean up that connection, unless it was modified/saved in the meantime. Before this was accomplished by creating a clone of the original connection. When deciding whether the temporary connection was modified, we would compare the current state with the original. This can now be simplified, because we have the nm-generated flag that gets cleared whenever the user modifies or saves the connection. This code is also more robust, because the previous implementation was a hack, but could not reliably detect whether the connection was modified by the user. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/devices/bluetooth/nm-bluez-device.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c
index 23fee45e1a..4159e050e5 100644
--- a/src/devices/bluetooth/nm-bluez-device.c
+++ b/src/devices/bluetooth/nm-bluez-device.c
@@ -67,7 +67,6 @@ typedef struct {
GSList *connections;
NMConnection *pan_connection;
- NMConnection *pan_connection_original;
gboolean pan_connection_no_autocreate;
} NMBluezDevicePrivate;
@@ -240,9 +239,10 @@ pan_connection_check_create (NMBluezDevice *self)
g_assert (connection_compatible (self, added));
g_assert (nm_connection_compare (added, connection, NM_SETTING_COMPARE_FLAG_EXACT));
+ nm_connection_set_flags (added, NM_CONNECTION_FLAGS_NM_GENERATED, TRUE);
+
priv->connections = g_slist_prepend (priv->connections, g_object_ref (added));
priv->pan_connection = added;
- priv->pan_connection_original = connection;
nm_log_dbg (LOGD_BT, "bluez[%s] added new Bluetooth connection for NAP device: '%s' (%s)", priv->path, id, uuid);
} else {
nm_log_warn (LOGD_BT, "bluez[%s] couldn't add new Bluetooth connection for NAP device: '%s' (%s): %d / %s",
@@ -250,8 +250,8 @@ pan_connection_check_create (NMBluezDevice *self)
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
- g_object_unref (connection);
}
+ g_object_unref (connection);
g_free (id);
g_free (uuid);
@@ -362,10 +362,8 @@ cp_connection_removed (NMConnectionProvider *provider,
if (g_slist_find (priv->connections, connection)) {
priv->connections = g_slist_remove (priv->connections, connection);
- if (priv->pan_connection == connection) {
+ if (priv->pan_connection == connection)
priv->pan_connection = NULL;
- g_clear_object (&priv->pan_connection_original);
- }
g_object_unref (connection);
check_emit_usable (self);
}
@@ -1037,12 +1035,10 @@ dispose (GObject *object)
if (priv->pan_connection) {
/* Check whether we want to remove the created connection. If so, we take a reference
* and delete it at the end of dispose(). */
- if ((nm_connection_get_flags (priv->pan_connection) & NM_CONNECTION_FLAGS_UNSAVED)
- && nm_connection_compare (priv->pan_connection, priv->pan_connection_original, NM_SETTING_COMPARE_FLAG_EXACT))
+ if (nm_connection_get_flags (priv->pan_connection) & NM_CONNECTION_FLAGS_NM_GENERATED)
to_delete = g_object_ref (priv->pan_connection);
priv->pan_connection = NULL;
- g_clear_object (&priv->pan_connection_original);
}
g_signal_handlers_disconnect_by_func (priv->provider, cp_connection_added, self);