mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 09:30:31 +01:00
libnm-util: add *_remove_*_by_value() functions for 'connection' setting
nm_setting_connection_remove_permission_by_value() nm_setting_connection_remove_secondary_by_value()
This commit is contained in:
parent
7c817d4176
commit
b59bd75956
3 changed files with 90 additions and 1 deletions
|
|
@ -267,7 +267,9 @@ global:
|
|||
nm_setting_connection_new;
|
||||
nm_setting_connection_permissions_user_allowed;
|
||||
nm_setting_connection_remove_permission;
|
||||
nm_setting_connection_remove_permission_by_value;
|
||||
nm_setting_connection_remove_secondary;
|
||||
nm_setting_connection_remove_secondary_by_value;
|
||||
nm_setting_dcb_error_get_type;
|
||||
nm_setting_dcb_error_quark;
|
||||
nm_setting_dcb_flags_get_type;
|
||||
|
|
|
|||
|
|
@ -447,6 +447,51 @@ nm_setting_connection_remove_permission (NMSettingConnection *setting,
|
|||
g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_remove_permission_by_value:
|
||||
* @setting: the #NMSettingConnection
|
||||
* @ptype: the permission type; at this time only "user" is supported
|
||||
* @pitem: the permission item formatted as required for @ptype
|
||||
* @detail: (allow-none): unused at this time; must be %NULL
|
||||
*
|
||||
* Removes the permission from the connection.
|
||||
* At this time, only the "user" permission type is supported, and @pitem must
|
||||
* be a username. See #NMSettingConnection:permissions: for more details.
|
||||
*
|
||||
* Returns: %TRUE if the permission was found and removed; %FALSE if it was not.
|
||||
*
|
||||
* Since: 0.9.10
|
||||
*/
|
||||
gboolean
|
||||
nm_setting_connection_remove_permission_by_value (NMSettingConnection *setting,
|
||||
const char *ptype,
|
||||
const char *pitem,
|
||||
const char *detail)
|
||||
{
|
||||
NMSettingConnectionPrivate *priv;
|
||||
Permission *p;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
|
||||
g_return_val_if_fail (ptype, FALSE);
|
||||
g_return_val_if_fail (strlen (ptype) > 0, FALSE);
|
||||
g_return_val_if_fail (detail == NULL, FALSE);
|
||||
|
||||
/* Only "user" for now... */
|
||||
g_return_val_if_fail (strcmp (ptype, "user") == 0, FALSE);
|
||||
|
||||
priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
|
||||
for (iter = priv->permissions; iter; iter = g_slist_next (iter)) {
|
||||
p = iter->data;
|
||||
if (strcmp (pitem, p->item) == 0) {
|
||||
permission_free ((Permission *) iter->data);
|
||||
priv->permissions = g_slist_delete_link (priv->permissions, iter);
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_get_autoconnect:
|
||||
|
|
@ -660,6 +705,39 @@ nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 id
|
|||
g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_remove_secondary_by_value:
|
||||
* @setting: the #NMSettingConnection
|
||||
* @sec_uuid: the secondary connection UUID to remove
|
||||
*
|
||||
* Removes the secondary coonnection UUID @sec_uuid.
|
||||
*
|
||||
* Returns: %TRUE if the secondary connection UUID was found and removed; %FALSE if it was not.
|
||||
*
|
||||
* Since: 0.9.10
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting,
|
||||
const char *sec_uuid)
|
||||
{
|
||||
NMSettingConnectionPrivate *priv;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
|
||||
g_return_val_if_fail (sec_uuid != NULL, FALSE);
|
||||
g_return_val_if_fail (sec_uuid[0] != '\0', FALSE);
|
||||
|
||||
priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
|
||||
for (iter = priv->secondaries; iter; iter = g_slist_next (iter)) {
|
||||
if (!strcmp (sec_uuid, (char *) iter->data)) {
|
||||
priv->secondaries = g_slist_delete_link (priv->secondaries, iter);
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_get_gateway_ping_timeout:
|
||||
* @setting: the #NMSettingConnection
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2007 - 2012 Red Hat, Inc.
|
||||
* (C) Copyright 2007 - 2014 Red Hat, Inc.
|
||||
* (C) Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -128,14 +128,23 @@ gboolean nm_setting_connection_add_permission (NMSettingConnection *set
|
|||
const char *detail);
|
||||
void nm_setting_connection_remove_permission (NMSettingConnection *setting,
|
||||
guint32 idx);
|
||||
NM_AVAILABLE_IN_0_9_10
|
||||
gboolean nm_setting_connection_remove_permission_by_value (NMSettingConnection *setting,
|
||||
const char *ptype,
|
||||
const char *pitem,
|
||||
const char *detail);
|
||||
|
||||
const char *nm_setting_connection_get_master (NMSettingConnection *setting);
|
||||
gboolean nm_setting_connection_is_slave_type (NMSettingConnection *setting,
|
||||
const char *type);
|
||||
const char *nm_setting_connection_get_slave_type (NMSettingConnection *setting);
|
||||
|
||||
guint32 nm_setting_connection_get_num_secondaries (NMSettingConnection *setting);
|
||||
const char *nm_setting_connection_get_secondary (NMSettingConnection *setting, guint32 idx);
|
||||
gboolean nm_setting_connection_add_secondary (NMSettingConnection *setting, const char *sec_uuid);
|
||||
void nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 idx);
|
||||
NM_AVAILABLE_IN_0_9_10
|
||||
gboolean nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting, const char *sec_uuid);
|
||||
|
||||
NM_AVAILABLE_IN_0_9_10
|
||||
guint32 nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue