[network-manager-applet/jk/master-as-ifname-rh1083186] editor: use ifname instead of UUID in slaves' master property (rh #1083186)
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/jk/master-as-ifname-rh1083186] editor: use ifname instead of UUID in slaves' master property (rh #1083186)
- Date: Fri, 13 Mar 2015 10:49:10 +0000 (UTC)
commit f1cf77f117d9ab4492fd3b33da26a56c97042ae5
Author: Jiří Klimeš <jklimes redhat com>
Date: Mon Mar 9 17:45:56 2015 +0100
editor: use ifname instead of UUID in slaves' master property (rh #1083186)
NetworkManager accepts both UUID and interface name in slave's master property
(identifying master). UUID is easier to use and may be more appropriate for
'connection based' configurations. On the other hand, some users may expect
master property to be rather interface name. And this is also the only
supported option for some configurations, such as initscripts in Red Hat based
distros.
https://bugzilla.redhat.com/show_bug.cgi?id=1083186
src/connection-editor/ce-page.c | 12 +++++++++
src/connection-editor/ce-page.h | 2 +
src/connection-editor/nm-connection-editor.c | 5 +++
src/connection-editor/page-master.c | 35 ++++++++++++++++++++++++++
4 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 51adee6..6a880e8 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -134,6 +134,18 @@ ce_page_validate (CEPage *self, NMConnection *connection, GError **error)
return TRUE;
}
+gboolean
+ce_page_last_update (CEPage *self, NMConnection *connection, GError **error)
+{
+ g_return_val_if_fail (CE_IS_PAGE (self), FALSE);
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
+
+ if (CE_PAGE_GET_CLASS (self)->last_update)
+ return CE_PAGE_GET_CLASS (self)->last_update (self, connection, error);
+
+ return TRUE;
+}
+
char **
ce_page_get_mac_list (CEPage *self, GType device_type, const char *mac_property)
{
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index 66e317d..05595ab 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -79,6 +79,7 @@ typedef struct {
/* Virtual functions */
gboolean (*validate) (CEPage *self, NMConnection *connection, GError **error);
+ gboolean (*last_update) (CEPage *self, NMConnection *connection, GError **error);
/* Signals */
void (*changed) (CEPage *self);
@@ -100,6 +101,7 @@ GtkWidget * ce_page_get_page (CEPage *self);
const char * ce_page_get_title (CEPage *self);
gboolean ce_page_validate (CEPage *self, NMConnection *connection, GError **error);
+gboolean ce_page_last_update (CEPage *self, NMConnection *connection, GError **error);
char **ce_page_get_mac_list (CEPage *self, GType device_type, const char *mac_property);
void ce_page_setup_mac_combo (CEPage *self, GtkComboBox *combo,
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index be3a06d..30742c8 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -957,6 +957,7 @@ static void
ok_button_clicked_cb (GtkWidget *widget, gpointer user_data)
{
NMConnectionEditor *self = NM_CONNECTION_EDITOR (user_data);
+ GSList *iter;
/* If the dialog is busy waiting for authorization or something,
* don't destroy it until authorization returns.
@@ -967,6 +968,10 @@ ok_button_clicked_cb (GtkWidget *widget, gpointer user_data)
/* Validate one last time to ensure all pages update the connection */
connection_editor_validate (self);
+ /* Perform page specific actions before the connection is saved */
+ for (iter = self->pages; iter; iter = g_slist_next (iter))
+ ce_page_last_update (CE_PAGE (iter->data), self->connection, NULL);
+
ok_button_clicked_save_connection (self);
}
diff --git a/src/connection-editor/page-master.c b/src/connection-editor/page-master.c
index c229c59..1d1590c 100644
--- a/src/connection-editor/page-master.c
+++ b/src/connection-editor/page-master.c
@@ -592,6 +592,40 @@ validate (CEPage *page, NMConnection *connection, GError **error)
return TRUE;
}
+static gboolean
+last_update (CEPage *page, NMConnection *connection, GError **error)
+{
+ CEPageMaster *self = CE_PAGE_MASTER (page);
+ CEPageMasterPrivate *priv = CE_PAGE_MASTER_GET_PRIVATE (self);
+ const char *interface_name, *tmp;
+ NMSettingConnection *s_con;
+ GtkTreeIter iter;
+
+ /*
+ * Set master property of all slaves to be the interface name.
+ * Even if UUID has the advantage of being stable and thus easier to use,
+ * users may prefer using interface name instead.
+ */
+ interface_name = gtk_entry_get_text (priv->interface_name);
+ if (gtk_tree_model_get_iter_first (priv->connections_model, &iter)) {
+ do {
+ NMRemoteConnection *rcon = NULL;
+
+ gtk_tree_model_get (priv->connections_model, &iter,
+ COL_CONNECTION, &rcon,
+ -1);
+ tmp = nm_connection_get_interface_name (NM_CONNECTION (rcon));
+ if (g_strcmp0 (interface_name, tmp) != 0) {
+ s_con = nm_connection_get_setting_connection (NM_CONNECTION (rcon));
+ g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, interface_name, NULL);
+ nm_remote_connection_commit_changes_async (rcon, TRUE, NULL, NULL, NULL);
+ }
+ g_object_unref (rcon);
+ } while (gtk_tree_model_iter_next (priv->connections_model, &iter));
+ }
+ return TRUE;
+}
+
static void
ce_page_master_init (CEPageMaster *self)
{
@@ -610,6 +644,7 @@ ce_page_master_class_init (CEPageMasterClass *master_class)
object_class->dispose = dispose;
parent_class->validate = validate;
+ parent_class->last_update = last_update;
/* Signals */
signals[CREATE_CONNECTION] =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]