mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 01:50:25 +01:00
core: add add_connection method to NMConnectionProvider
This exposes the functionality of nm_settings_add_connection to the users of NMConnectionProvider. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
3b12d9ae6e
commit
98daf270ba
3 changed files with 43 additions and 0 deletions
|
|
@ -49,6 +49,18 @@ nm_connection_provider_has_connections_loaded (NMConnectionProvider *self)
|
|||
return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->has_connections_loaded (self);
|
||||
}
|
||||
|
||||
NMConnection *
|
||||
nm_connection_provider_add_connection (NMConnectionProvider *self,
|
||||
NMConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (self), NULL);
|
||||
|
||||
g_assert (NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->add_connection);
|
||||
return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->add_connection (self, connection, save_to_disk, error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -60,6 +60,11 @@ struct _NMConnectionProvider {
|
|||
|
||||
gboolean (*has_connections_loaded) (NMConnectionProvider *self);
|
||||
|
||||
NMConnection * (*add_connection) (NMConnectionProvider *self,
|
||||
NMConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GError **error);
|
||||
|
||||
/* Signals */
|
||||
void (*connection_added) (NMConnectionProvider *self, NMConnection *connection);
|
||||
|
||||
|
|
@ -117,4 +122,19 @@ const GSList *nm_connection_provider_get_connections (NMConnectionProvider *self
|
|||
*/
|
||||
gboolean nm_connection_provider_has_connections_loaded (NMConnectionProvider *self);
|
||||
|
||||
|
||||
/**
|
||||
* nm_connection_provider_add_connection:
|
||||
* @self: the #NMConnectionProvider
|
||||
* @connection: the connection to be added
|
||||
* @save_to_disk: whether to store the connection on disk
|
||||
* @error: returns any error if adding fails
|
||||
*
|
||||
* returns: a newly added #NMConnection.
|
||||
*/
|
||||
NMConnection *nm_connection_provider_add_connection (NMConnectionProvider *self,
|
||||
NMConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GError **error);
|
||||
|
||||
#endif /* NM_CONNECTION_PROVIDER_H */
|
||||
|
|
|
|||
|
|
@ -930,6 +930,16 @@ nm_settings_add_connection (NMSettings *self,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
_nm_connection_provider_add_connection (NMConnectionProvider *provider,
|
||||
NMConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GError **error)
|
||||
{
|
||||
g_assert (NM_IS_CONNECTION_PROVIDER (provider) && NM_IS_SETTINGS (provider));
|
||||
return NM_CONNECTION (nm_settings_add_connection (NM_SETTINGS (provider), connection, save_to_disk, error));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
secrets_filter_cb (NMSetting *setting,
|
||||
const char *secret,
|
||||
|
|
@ -1676,6 +1686,7 @@ connection_provider_init (NMConnectionProvider *cp_class)
|
|||
cp_class->get_best_connections = get_best_connections;
|
||||
cp_class->get_connections = get_connections;
|
||||
cp_class->has_connections_loaded = has_connections_loaded;
|
||||
cp_class->add_connection = _nm_connection_provider_add_connection;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue