merge: 'lr/nmtui-slaves-after-master-rh1369008'
https://bugzilla.redhat.com/show_bug.cgi?id=1369008
This commit is contained in:
@@ -319,6 +319,33 @@ listbox_activated (NmtNewtWidget *listbox, gpointer list)
|
|||||||
edit_clicked (NMT_NEWT_BUTTON (priv->edit), list);
|
edit_clicked (NMT_NEWT_BUTTON (priv->edit), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
connection_saved (GObject *conn,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
nm_remote_connection_save_finish (NM_REMOTE_CONNECTION (conn), result, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nmt_edit_connection_list_recommit (NmtEditConnectionList *list)
|
||||||
|
{
|
||||||
|
NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE (list);
|
||||||
|
NMConnection *conn;
|
||||||
|
GSList *iter;
|
||||||
|
|
||||||
|
for (iter = priv->connections; iter; iter = iter->next) {
|
||||||
|
conn = iter->data;
|
||||||
|
|
||||||
|
if ( NM_IS_REMOTE_CONNECTION (conn)
|
||||||
|
&& (nm_remote_connection_get_unsaved (NM_REMOTE_CONNECTION (conn)) == FALSE)) {
|
||||||
|
nm_remote_connection_save_async (NM_REMOTE_CONNECTION (conn),
|
||||||
|
NULL, connection_saved, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nmt_edit_connection_list_finalize (GObject *object)
|
nmt_edit_connection_list_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
|
@@ -52,4 +52,6 @@ typedef gboolean (*NmtEditConnectionListFilter) (NmtEditConnectionList *list,
|
|||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
void nmt_edit_connection_list_recommit (NmtEditConnectionList *list);
|
||||||
|
|
||||||
#endif /* NMT_EDIT_CONNECTION_LIST_H */
|
#endif /* NMT_EDIT_CONNECTION_LIST_H */
|
||||||
|
@@ -112,6 +112,23 @@ nmt_editor_page_add_section (NmtEditorPage *page,
|
|||||||
priv->sections = g_slist_append (priv->sections, g_object_ref_sink (section));
|
priv->sections = g_slist_append (priv->sections, g_object_ref_sink (section));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nmt_editor_page_saved:
|
||||||
|
* @page: the #NmtEditorPage
|
||||||
|
*
|
||||||
|
* This method is called when the user saves the connection. It gives
|
||||||
|
* the page a chance to do save its data outside the connections (such as
|
||||||
|
* recommit the slave connections).
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
nmt_editor_page_saved (NmtEditorPage *page)
|
||||||
|
{
|
||||||
|
NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_GET_CLASS (page);
|
||||||
|
|
||||||
|
if (editor_page_class->saved)
|
||||||
|
editor_page_class->saved (page);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nmt_editor_page_set_property (GObject *object,
|
nmt_editor_page_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@@ -39,6 +39,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
GObjectClass parent;
|
GObjectClass parent;
|
||||||
|
|
||||||
|
void (*saved) (NmtEditorPage *page);
|
||||||
} NmtEditorPageClass;
|
} NmtEditorPageClass;
|
||||||
|
|
||||||
GType nmt_editor_page_get_type (void);
|
GType nmt_editor_page_get_type (void);
|
||||||
@@ -47,6 +48,8 @@ NMConnection *nmt_editor_page_get_connection (NmtEditorPage *page);
|
|||||||
|
|
||||||
GSList *nmt_editor_page_get_sections (NmtEditorPage *page);
|
GSList *nmt_editor_page_get_sections (NmtEditorPage *page);
|
||||||
|
|
||||||
|
void nmt_editor_page_saved (NmtEditorPage *page);
|
||||||
|
|
||||||
/*< protected >*/
|
/*< protected >*/
|
||||||
void nmt_editor_page_add_section (NmtEditorPage *page,
|
void nmt_editor_page_add_section (NmtEditorPage *page,
|
||||||
NmtEditorSection *section);
|
NmtEditorSection *section);
|
||||||
|
@@ -145,6 +145,15 @@ connection_added (GObject *client,
|
|||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
page_saved (gpointer data, gpointer user_data)
|
||||||
|
{
|
||||||
|
NmtEditorPage *page = data;
|
||||||
|
|
||||||
|
nmt_editor_page_saved (page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
save_connection_and_exit (NmtNewtButton *button,
|
save_connection_and_exit (NmtNewtButton *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -183,6 +192,9 @@ save_connection_and_exit (NmtNewtButton *button,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Let the page know that it was saved. */
|
||||||
|
g_slist_foreach (priv->pages, page_saved, NULL);
|
||||||
|
|
||||||
nmt_newt_form_quit (NMT_NEWT_FORM (editor));
|
nmt_newt_form_quit (NMT_NEWT_FORM (editor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -423,12 +423,22 @@ nmt_page_bond_constructed (GObject *object)
|
|||||||
G_OBJECT_CLASS (nmt_page_bond_parent_class)->constructed (object);
|
G_OBJECT_CLASS (nmt_page_bond_parent_class)->constructed (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nmt_page_bond_saved (NmtEditorPage *editor_page)
|
||||||
|
{
|
||||||
|
NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (editor_page);
|
||||||
|
|
||||||
|
nmt_edit_connection_list_recommit (NMT_EDIT_CONNECTION_LIST (priv->slaves));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nmt_page_bond_class_init (NmtPageBondClass *bond_class)
|
nmt_page_bond_class_init (NmtPageBondClass *bond_class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (bond_class);
|
GObjectClass *object_class = G_OBJECT_CLASS (bond_class);
|
||||||
|
NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_CLASS (bond_class);
|
||||||
|
|
||||||
g_type_class_add_private (bond_class, sizeof (NmtPageBondPrivate));
|
g_type_class_add_private (bond_class, sizeof (NmtPageBondPrivate));
|
||||||
|
|
||||||
object_class->constructed = nmt_page_bond_constructed;
|
object_class->constructed = nmt_page_bond_constructed;
|
||||||
|
editor_page_class->saved = nmt_page_bond_saved;
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,12 @@
|
|||||||
|
|
||||||
G_DEFINE_TYPE (NmtPageBridge, nmt_page_bridge, NMT_TYPE_EDITOR_PAGE_DEVICE)
|
G_DEFINE_TYPE (NmtPageBridge, nmt_page_bridge, NMT_TYPE_EDITOR_PAGE_DEVICE)
|
||||||
|
|
||||||
|
#define NMT_PAGE_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_PAGE_BRIDGE, NmtPageBridgePrivate))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
NmtSlaveList *slaves;
|
||||||
|
} NmtPageBridgePrivate;
|
||||||
|
|
||||||
NmtEditorPage *
|
NmtEditorPage *
|
||||||
nmt_page_bridge_new (NMConnection *conn,
|
nmt_page_bridge_new (NMConnection *conn,
|
||||||
NmtDeviceEntry *deventry)
|
NmtDeviceEntry *deventry)
|
||||||
@@ -58,6 +64,7 @@ static void
|
|||||||
nmt_page_bridge_constructed (GObject *object)
|
nmt_page_bridge_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
NmtPageBridge *bridge = NMT_PAGE_BRIDGE (object);
|
NmtPageBridge *bridge = NMT_PAGE_BRIDGE (object);
|
||||||
|
NmtPageBridgePrivate *priv = NMT_PAGE_BRIDGE_GET_PRIVATE (bridge);
|
||||||
NmtEditorSection *section;
|
NmtEditorSection *section;
|
||||||
NmtEditorGrid *grid;
|
NmtEditorGrid *grid;
|
||||||
NMSettingBridge *s_bridge;
|
NMSettingBridge *s_bridge;
|
||||||
@@ -80,6 +87,7 @@ nmt_page_bridge_constructed (GObject *object)
|
|||||||
|
|
||||||
widget = nmt_slave_list_new (conn, bridge_connection_type_filter, bridge);
|
widget = nmt_slave_list_new (conn, bridge_connection_type_filter, bridge);
|
||||||
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
||||||
|
priv->slaves = NMT_SLAVE_LIST (widget);
|
||||||
|
|
||||||
widget = nmt_newt_entry_numeric_new (10, 0, 1000000);
|
widget = nmt_newt_entry_numeric_new (10, 0, 1000000);
|
||||||
g_object_bind_property (s_bridge, NM_SETTING_BRIDGE_AGEING_TIME,
|
g_object_bind_property (s_bridge, NM_SETTING_BRIDGE_AGEING_TIME,
|
||||||
@@ -144,10 +152,20 @@ nmt_page_bridge_constructed (GObject *object)
|
|||||||
G_OBJECT_CLASS (nmt_page_bridge_parent_class)->constructed (object);
|
G_OBJECT_CLASS (nmt_page_bridge_parent_class)->constructed (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nmt_page_bridge_saved (NmtEditorPage *editor_page)
|
||||||
|
{
|
||||||
|
NmtPageBridgePrivate *priv = NMT_PAGE_BRIDGE_GET_PRIVATE (editor_page);
|
||||||
|
|
||||||
|
nmt_edit_connection_list_recommit (NMT_EDIT_CONNECTION_LIST (priv->slaves));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nmt_page_bridge_class_init (NmtPageBridgeClass *bridge_class)
|
nmt_page_bridge_class_init (NmtPageBridgeClass *bridge_class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (bridge_class);
|
GObjectClass *object_class = G_OBJECT_CLASS (bridge_class);
|
||||||
|
NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_CLASS (bridge_class);
|
||||||
|
|
||||||
object_class->constructed = nmt_page_bridge_constructed;
|
object_class->constructed = nmt_page_bridge_constructed;
|
||||||
|
editor_page_class->saved = nmt_page_bridge_saved;
|
||||||
}
|
}
|
||||||
|
@@ -179,12 +179,22 @@ nmt_page_team_constructed (GObject *object)
|
|||||||
G_OBJECT_CLASS (nmt_page_team_parent_class)->constructed (object);
|
G_OBJECT_CLASS (nmt_page_team_parent_class)->constructed (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nmt_page_team_saved (NmtEditorPage *editor_page)
|
||||||
|
{
|
||||||
|
NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE (editor_page);
|
||||||
|
|
||||||
|
nmt_edit_connection_list_recommit (NMT_EDIT_CONNECTION_LIST (priv->slaves));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nmt_page_team_class_init (NmtPageTeamClass *team_class)
|
nmt_page_team_class_init (NmtPageTeamClass *team_class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (team_class);
|
GObjectClass *object_class = G_OBJECT_CLASS (team_class);
|
||||||
|
NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_CLASS (team_class);
|
||||||
|
|
||||||
g_type_class_add_private (team_class, sizeof (NmtPageTeamPrivate));
|
g_type_class_add_private (team_class, sizeof (NmtPageTeamPrivate));
|
||||||
|
|
||||||
object_class->constructed = nmt_page_team_constructed;
|
object_class->constructed = nmt_page_team_constructed;
|
||||||
|
editor_page_class->saved = nmt_page_team_saved;
|
||||||
}
|
}
|
||||||
|
@@ -1711,6 +1711,17 @@ update_auth_cb (NMSettingsConnection *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!info->new_settings) {
|
||||||
|
/* We're just calling Save(). Just commit the existing connection. */
|
||||||
|
if (info->save_to_disk) {
|
||||||
|
nm_settings_connection_commit_changes (self,
|
||||||
|
NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION,
|
||||||
|
con_update_cb,
|
||||||
|
info);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!any_secrets_present (info->new_settings)) {
|
if (!any_secrets_present (info->new_settings)) {
|
||||||
/* If the new connection has no secrets, we do not want to remove all
|
/* If the new connection has no secrets, we do not want to remove all
|
||||||
* secrets, rather we keep all the existing ones. Do that by merging
|
* secrets, rather we keep all the existing ones. Do that by merging
|
||||||
@@ -1860,11 +1871,7 @@ static void
|
|||||||
impl_settings_connection_save (NMSettingsConnection *self,
|
impl_settings_connection_save (NMSettingsConnection *self,
|
||||||
GDBusMethodInvocation *context)
|
GDBusMethodInvocation *context)
|
||||||
{
|
{
|
||||||
/* Do nothing if the connection is already synced with disk */
|
|
||||||
if (nm_settings_connection_get_unsaved (self))
|
|
||||||
settings_connection_update_helper (self, context, NULL, TRUE);
|
settings_connection_update_helper (self, context, NULL, TRUE);
|
||||||
else
|
|
||||||
g_dbus_method_invocation_return_value (context, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -336,35 +336,12 @@ commit_changes (NMSettingsConnection *connection,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
NMConnection *reread;
|
gboolean success = FALSE;
|
||||||
gboolean same = FALSE, success = FALSE;
|
|
||||||
char *ifcfg_path = NULL;
|
char *ifcfg_path = NULL;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
|
||||||
/* To ensure we don't rewrite files that are only changed from other
|
|
||||||
* processes on-disk, read the existing connection back in and only rewrite
|
|
||||||
* it if it's really changed.
|
|
||||||
*/
|
|
||||||
filename = nm_settings_connection_get_filename (connection);
|
filename = nm_settings_connection_get_filename (connection);
|
||||||
if (filename) {
|
if (filename) {
|
||||||
gs_free char *unhandled = NULL;
|
|
||||||
|
|
||||||
reread = connection_from_file (filename, &unhandled, NULL, NULL);
|
|
||||||
if (reread) {
|
|
||||||
same = nm_connection_compare (NM_CONNECTION (connection),
|
|
||||||
reread,
|
|
||||||
NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
|
|
||||||
NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS);
|
|
||||||
g_object_unref (reread);
|
|
||||||
|
|
||||||
/* Don't bother writing anything out if in-memory and on-disk data are the same */
|
|
||||||
if (same) {
|
|
||||||
/* But chain up to parent to handle success - emits updated signal */
|
|
||||||
NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
success = writer_update_connection (NM_CONNECTION (connection),
|
success = writer_update_connection (NM_CONNECTION (connection),
|
||||||
IFCFG_DIR,
|
IFCFG_DIR,
|
||||||
filename,
|
filename,
|
||||||
@@ -478,6 +455,11 @@ nm_ifcfg_connection_new (NMConnection *source,
|
|||||||
if (out_ignore_error)
|
if (out_ignore_error)
|
||||||
*out_ignore_error = FALSE;
|
*out_ignore_error = FALSE;
|
||||||
|
|
||||||
|
if (full_path) {
|
||||||
|
/* The connection already is on the disk */
|
||||||
|
update_unsaved = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we're given a connection already, prefer that instead of re-reading */
|
/* If we're given a connection already, prefer that instead of re-reading */
|
||||||
if (source)
|
if (source)
|
||||||
tmp = g_object_ref (source);
|
tmp = g_object_ref (source);
|
||||||
@@ -488,9 +470,6 @@ nm_ifcfg_connection_new (NMConnection *source,
|
|||||||
out_ignore_error);
|
out_ignore_error);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* If we just read the connection from disk, it's clearly not Unsaved */
|
|
||||||
update_unsaved = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unmanaged:"))
|
if (unhandled_spec && g_str_has_prefix (unhandled_spec, "unmanaged:"))
|
||||||
|
Reference in New Issue
Block a user