core: use nm_dbus_object_get_path() instead of nm_connection_get_path()

Essentially, nm_connection_get_path() mirros nm_dbus_object_get_path().
However, when cloning a simple-connection, the path also gets cloned.

I think this field doesn't belong to NMConnection in the first place,
because NMConnection is not a D-Bus object. NMSettingsConnection (in
core) and NMRemoteConnection (in libnm) is.

Don't use the misleading alias, but use nm_dbus_object_get_path()
directly.
This commit is contained in:
Thomas Haller 2018-03-29 11:40:27 +02:00
parent efe5cf79c0
commit 9efa7c7220
7 changed files with 21 additions and 23 deletions

View file

@ -15257,7 +15257,7 @@ get_property (GObject *object, guint prop_id,
array = g_ptr_array_sized_new (g_hash_table_size (priv->available_connections));
g_hash_table_iter_init (&iter, priv->available_connections);
while (g_hash_table_iter_next (&iter, (gpointer) &connection, NULL))
g_ptr_array_add (array, g_strdup (nm_connection_get_path (connection)));
g_ptr_array_add (array, g_strdup (nm_dbus_object_get_path (NM_DBUS_OBJECT (connection))));
g_ptr_array_add (array, NULL);
g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE));
break;

View file

@ -1186,7 +1186,7 @@ get_property (GObject *object, guint prop_id,
* is set, to get an assertion failure if somebody tries to access the
* getters at the wrong time. */
case PROP_CONNECTION:
g_value_set_string (value, nm_connection_get_path (NM_CONNECTION (priv->settings_connection)));
g_value_set_string (value, nm_dbus_object_get_path (NM_DBUS_OBJECT (priv->settings_connection)));
break;
case PROP_ID:
g_value_set_string (value, nm_connection_get_id (NM_CONNECTION (priv->settings_connection)));

View file

@ -579,7 +579,7 @@ _dispatcher_call (NMDispatcherAction action,
const char *connection_path;
const char *filename;
connection_path = nm_connection_get_path (NM_CONNECTION (settings_connection));
connection_path = nm_dbus_object_get_path (NM_DBUS_OBJECT (settings_connection));
if (connection_path) {
g_variant_builder_add (&connection_props, "{sv}",
NMD_CONNECTION_PROPS_PATH,

View file

@ -2392,7 +2392,7 @@ recheck_assume_connection (NMManager *self,
if (!active) {
_LOGW (LOGD_DEVICE, "assume: assumed connection %s failed to activate: %s",
nm_connection_get_path (NM_CONNECTION (connection)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection)),
error->message);
g_error_free (error);
@ -4517,7 +4517,7 @@ activation_add_done (NMSettings *settings,
g_dbus_method_invocation_return_value (
context,
g_variant_new ("(oo)",
nm_connection_get_path (NM_CONNECTION (new_connection)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (new_connection)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (active))));
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD_ACTIVATE,
nm_active_connection_get_settings_connection (active),

View file

@ -581,7 +581,7 @@ _update_prepare (NMSettingsConnection *self,
if (!nm_connection_normalize (new_connection, NULL, NULL, error))
return FALSE;
if ( nm_connection_get_path (NM_CONNECTION (self))
if ( nm_dbus_object_get_path (NM_DBUS_OBJECT (self))
&& g_strcmp0 (nm_settings_connection_get_uuid (self), nm_connection_get_uuid (new_connection)) != 0) {
/* Updating the UUID is not allowed once the path is exported. */
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
@ -798,7 +798,7 @@ nm_settings_connection_delete (NMSettingsConnection *self,
for_agents = nm_simple_connection_new_clone (NM_CONNECTION (self));
nm_connection_clear_secrets (for_agents);
nm_agent_manager_delete_secrets (priv->agent_mgr,
nm_connection_get_path (NM_CONNECTION (self)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)),
for_agents);
g_object_unref (for_agents);
@ -1295,7 +1295,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
priv->last_secret_agent_version_id = nm_agent_manager_get_agent_version_id (priv->agent_mgr);
call_id_a = nm_agent_manager_get_secrets (priv->agent_mgr,
nm_connection_get_path (NM_CONNECTION (self)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)),
NM_CONNECTION (self),
subject,
existing_secrets,
@ -1789,7 +1789,7 @@ update_auth_cb (NMSettingsConnection *self,
secrets_filter_cb,
GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED));
nm_agent_manager_save_secrets (info->agent_mgr,
nm_connection_get_path (NM_CONNECTION (self)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)),
for_agent,
info->subject);
}
@ -2210,7 +2210,7 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
/* Tell agents to remove secrets for this connection */
nm_agent_manager_delete_secrets (priv->agent_mgr,
nm_connection_get_path (NM_CONNECTION (self)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)),
NM_CONNECTION (self));
nm_settings_connection_update (self,

View file

@ -365,7 +365,7 @@ impl_settings_get_connection_by_uuid (NMDBusObject *obj,
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)",
nm_connection_get_path (NM_CONNECTION (connection))));
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection))));
return;
error:
@ -856,7 +856,7 @@ _emit_connection_removed (NMSettings *self,
&interface_info_settings,
&signal_info_connection_removed,
"(o)",
nm_connection_get_path (NM_CONNECTION (connection)));
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection)));
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connection);
}
@ -866,7 +866,7 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data)
{
NMSettings *self = NM_SETTINGS (user_data);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
const char *cpath = nm_connection_get_path (NM_CONNECTION (connection));
const char *cpath = nm_dbus_object_get_path (NM_DBUS_OBJECT (connection));
NMDevice *device;
_nm_unused gs_unref_object NMSettingsConnection *connection_keep_alive = NULL;
@ -963,7 +963,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
NMSettingsConnection *existing;
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection));
g_return_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL);
g_return_if_fail (!nm_dbus_object_is_exported (NM_DBUS_OBJECT (connection)));
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, NULL, &data)) {
@ -1023,13 +1023,11 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
self);
}
/* Export the connection over D-Bus */
g_warn_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL);
path = nm_dbus_object_export (NM_DBUS_OBJECT (connection));
nm_connection_set_path (NM_CONNECTION (connection), path);
g_hash_table_insert (priv->connections,
(gpointer) nm_connection_get_path (NM_CONNECTION (connection)),
(gpointer) nm_dbus_object_get_path (NM_DBUS_OBJECT (connection)),
g_object_ref (connection));
_clear_connections_cached_list (&priv->connections_cached_list);
@ -1043,7 +1041,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
&interface_info_settings,
&signal_info_new_connection,
"(o)",
nm_connection_get_path (NM_CONNECTION (connection)));
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection)));
g_signal_emit (self, signals[CONNECTION_ADDED], 0, connection);
_notify (self, PROP_CONNECTIONS);
@ -1169,7 +1167,7 @@ send_agent_owned_secrets (NMSettings *self,
secrets_filter_cb,
GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED));
nm_agent_manager_save_secrets (priv->agent_mgr,
nm_connection_get_path (NM_CONNECTION (connection)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection)),
for_agent,
subject);
g_object_unref (for_agent);
@ -1382,9 +1380,9 @@ settings_add_connection_add_cb (NMSettings *self,
g_dbus_method_invocation_return_gerror (context, error);
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD, NULL, FALSE, NULL, subject, error->message);
} else {
g_dbus_method_invocation_return_value (
context,
g_variant_new ("(o)", nm_connection_get_path (NM_CONNECTION (connection))));
g_dbus_method_invocation_return_value (context,
g_variant_new ("(o)",
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection))));
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD, connection, TRUE, NULL,
subject, NULL);
}

View file

@ -750,7 +750,7 @@ impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin,
return;
}
path = nm_connection_get_path (NM_CONNECTION (connection));
path = nm_dbus_object_get_path (NM_DBUS_OBJECT (connection));
if (!path) {
g_dbus_method_invocation_return_error (context,
NM_SETTINGS_ERROR,