mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 14:38:09 +02:00
libnm-util: add connection helpers for ID and UUID
Shortcuts. Getting the ID and UUID is used in a ton of places and this helps cut down on code.
This commit is contained in:
parent
09d608b99c
commit
c5235f87db
3 changed files with 52 additions and 0 deletions
|
|
@ -9,9 +9,11 @@ global:
|
|||
nm_connection_error_get_type;
|
||||
nm_connection_error_quark;
|
||||
nm_connection_for_each_setting_value;
|
||||
nm_connection_get_id;
|
||||
nm_connection_get_path;
|
||||
nm_connection_get_setting;
|
||||
nm_connection_get_setting_by_name;
|
||||
nm_connection_get_uuid;
|
||||
nm_connection_get_type;
|
||||
nm_connection_lookup_setting_type;
|
||||
nm_connection_lookup_setting_type_by_quark;
|
||||
|
|
|
|||
|
|
@ -1040,6 +1040,51 @@ nm_connection_duplicate (NMConnection *connection)
|
|||
return dup;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_uuid:
|
||||
* @connection: the #NMConnection
|
||||
*
|
||||
* A shortcut to return the UUID from the connections #NMSettingConnection.
|
||||
*
|
||||
* Returns: the UUID from the connection's 'connection' setting
|
||||
**/
|
||||
const char *
|
||||
nm_connection_get_uuid (NMConnection *connection)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
|
||||
g_return_val_if_fail (s_con != NULL, NULL);
|
||||
|
||||
return nm_setting_connection_get_uuid (s_con);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_uuid:
|
||||
* @connection: the #NMConnection
|
||||
*
|
||||
* A shortcut to return the UUID from the connections #NMSettingConnection.
|
||||
*
|
||||
* Returns: the UUID from the connection's 'connection' setting
|
||||
**/
|
||||
const char *nm_connection_get_id (NMConnection *connection)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
|
||||
g_return_val_if_fail (s_con != NULL, NULL);
|
||||
|
||||
return nm_setting_connection_get_id (s_con);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
static void
|
||||
nm_connection_init (NMConnection *connection)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -141,6 +141,11 @@ GType nm_connection_lookup_setting_type (const char *name);
|
|||
|
||||
GType nm_connection_lookup_setting_type_by_quark (GQuark error_quark);
|
||||
|
||||
/* Helpers */
|
||||
const char * nm_connection_get_uuid (NMConnection *connection);
|
||||
|
||||
const char * nm_connection_get_id (NMConnection *connection);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_CONNECTION_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue