mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 16:00:34 +01:00
core: use nm_dbus_manager_lookup_object_with_type()
I think this makes it clearer that we should always look for a certain type, because NMDBusManager tracks all D-Bus objects.
This commit is contained in:
parent
de61722efe
commit
6f948fcd2e
5 changed files with 27 additions and 17 deletions
|
|
@ -1037,9 +1037,10 @@ nm_wifi_ap_lookup_for_device(NMDevice *device, const char *exported_path)
|
|||
|
||||
g_return_val_if_fail(NM_IS_DEVICE(device), NULL);
|
||||
|
||||
ap = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
|
||||
exported_path);
|
||||
if (!ap || !NM_IS_WIFI_AP(ap) || ap->wifi_device != device)
|
||||
ap = nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
|
||||
NM_TYPE_WIFI_AP,
|
||||
exported_path);
|
||||
if (!ap || ap->wifi_device != device)
|
||||
return NULL;
|
||||
|
||||
return ap;
|
||||
|
|
|
|||
|
|
@ -139,10 +139,11 @@ nm_wifi_p2p_peer_lookup_for_device(NMDevice *device, const char *exported_path)
|
|||
|
||||
g_return_val_if_fail(NM_IS_DEVICE(device), NULL);
|
||||
|
||||
peer = (NMWifiP2PPeer *) nm_dbus_manager_lookup_object(
|
||||
nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
|
||||
exported_path);
|
||||
if (!peer || !NM_IS_WIFI_P2P_PEER(peer) || peer->wifi_device != device)
|
||||
peer =
|
||||
nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(device)),
|
||||
NM_TYPE_WIFI_P2P_PEER,
|
||||
exported_path);
|
||||
if (!peer || peer->wifi_device != device)
|
||||
return NULL;
|
||||
|
||||
return peer;
|
||||
|
|
|
|||
|
|
@ -259,10 +259,11 @@ nm_checkpoint_manager_lookup_by_path(NMCheckpointManager *self, const char *path
|
|||
|
||||
g_return_val_if_fail(self, NULL);
|
||||
|
||||
checkpoint =
|
||||
nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(GET_MANAGER(self))),
|
||||
path);
|
||||
if (!checkpoint || !NM_IS_CHECKPOINT(checkpoint)) {
|
||||
checkpoint = nm_dbus_manager_lookup_object_with_type(
|
||||
nm_dbus_object_get_manager(NM_DBUS_OBJECT(GET_MANAGER(self))),
|
||||
NM_TYPE_CHECKPOINT,
|
||||
path);
|
||||
if (!checkpoint) {
|
||||
g_set_error(error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_INVALID_ARGUMENTS,
|
||||
|
|
|
|||
|
|
@ -1159,8 +1159,10 @@ active_connection_get_by_path(NMManager *self, const char *path)
|
|||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
NMActiveConnection *ac;
|
||||
|
||||
ac = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)), path);
|
||||
if (!ac || !NM_IS_ACTIVE_CONNECTION(ac) || c_list_is_empty(&ac->active_connections_lst))
|
||||
ac = nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)),
|
||||
NM_TYPE_ACTIVE_CONNECTION,
|
||||
path);
|
||||
if (!ac || c_list_is_empty(&ac->active_connections_lst))
|
||||
return NULL;
|
||||
|
||||
nm_assert(c_list_contains(&priv->active_connections_lst_head, &ac->active_connections_lst));
|
||||
|
|
@ -1292,8 +1294,11 @@ nm_manager_get_device_by_path(NMManager *self, const char *path)
|
|||
|
||||
g_return_val_if_fail(path, NULL);
|
||||
|
||||
device = nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)), path);
|
||||
if (!device || !NM_IS_DEVICE(device) || c_list_is_empty(&device->devices_lst))
|
||||
device =
|
||||
nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)),
|
||||
NM_TYPE_DEVICE,
|
||||
path);
|
||||
if (!device || c_list_is_empty(&device->devices_lst))
|
||||
return NULL;
|
||||
|
||||
nm_assert(c_list_contains(&priv->devices_lst_head, &device->devices_lst));
|
||||
|
|
|
|||
|
|
@ -3201,8 +3201,10 @@ nm_settings_get_connection_by_path(NMSettings *self, const char *path)
|
|||
priv = NM_SETTINGS_GET_PRIVATE(self);
|
||||
|
||||
connection =
|
||||
nm_dbus_manager_lookup_object(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)), path);
|
||||
if (!connection || !NM_IS_SETTINGS_CONNECTION(connection))
|
||||
nm_dbus_manager_lookup_object_with_type(nm_dbus_object_get_manager(NM_DBUS_OBJECT(self)),
|
||||
NM_TYPE_SETTINGS_CONNECTION,
|
||||
path);
|
||||
if (!connection)
|
||||
return NULL;
|
||||
|
||||
nm_assert(c_list_contains(&priv->connections_lst_head, &connection->_connections_lst));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue