mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 12:30:24 +01:00
core: add nm_settings_connection_get_setting() helper
For efficiently and conveniently lookup an NMSetting from the
NMConnection inside the NMSettingsConnection.
Note that this uses the NMMetaSettingType as lookup key. That is a novel
approach, compared to lookup by name (nm_connection_get_setting_by_name())
or GType (nm_connection_get_setting()).
Using the NMMetaSettingType enum is however faster, because it does not
require resolving the name/GType first. This is perfecly fine internal API,
we should use it.
(cherry picked from commit 429cf416fd)
This commit is contained in:
parent
50b6c2d622
commit
10e493bbe8
2 changed files with 18 additions and 0 deletions
|
|
@ -361,6 +361,20 @@ nm_settings_connection_get_connection(NMSettingsConnection *self)
|
|||
return NM_SETTINGS_CONNECTION_GET_PRIVATE(self)->connection;
|
||||
}
|
||||
|
||||
gpointer
|
||||
nm_settings_connection_get_setting(NMSettingsConnection *self, NMMetaSettingType meta_type)
|
||||
{
|
||||
NMConnection *connection;
|
||||
|
||||
nm_assert(NM_IS_SETTINGS_CONNECTION(self));
|
||||
|
||||
connection = NM_SETTINGS_CONNECTION_GET_PRIVATE(self)->connection;
|
||||
|
||||
nm_assert(NM_IS_SIMPLE_CONNECTION(connection));
|
||||
|
||||
return _nm_connection_get_setting_by_metatype_unsafe(connection, meta_type);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_settings_connection_set_connection(NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef __NETWORKMANAGER_SETTINGS_CONNECTION_H__
|
||||
#define __NETWORKMANAGER_SETTINGS_CONNECTION_H__
|
||||
|
||||
#include "libnm-core-intern/nm-meta-setting-base.h"
|
||||
|
||||
#include "nm-dbus-object.h"
|
||||
#include "nm-connection.h"
|
||||
|
||||
|
|
@ -218,6 +220,8 @@ GType nm_settings_connection_get_type(void);
|
|||
NMSettingsConnection *nm_settings_connection_new(void);
|
||||
|
||||
NMConnection *nm_settings_connection_get_connection(NMSettingsConnection *self);
|
||||
gpointer nm_settings_connection_get_setting(NMSettingsConnection *self,
|
||||
NMMetaSettingType meta_type);
|
||||
|
||||
void _nm_settings_connection_set_connection(NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue