return TRUE;
}
-static void
-hash_to_connection (NMConnection *connection, GHashTable *new)
+/**
+ * _nm_connection_replace_settings:
+ * @connection: a #NMConnection
+ * @new_settings: (element-type utf8 GLib.HashTable): a #GHashTable of settings
+ **/
+void
+_nm_connection_replace_settings (NMConnection *connection,
+ GHashTable *new_settings)
{
+ NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
GHashTableIter iter;
const char *setting_name;
GHashTable *setting_hash;
gboolean changed;
- NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
+
+ g_return_if_fail (NM_IS_CONNECTION (connection));
+ g_return_if_fail (new_settings != NULL);
+
+ priv = NM_CONNECTION_GET_PRIVATE (connection);
if ((changed = g_hash_table_size (priv->settings) > 0))
g_hash_table_foreach_remove (priv->settings, _setting_release, connection);
- g_hash_table_iter_init (&iter, new);
+ g_hash_table_iter_init (&iter, new_settings);
while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting_hash)) {
GType type = nm_connection_lookup_setting_type (setting_name);
{
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
g_return_val_if_fail (new_settings != NULL, FALSE);
- if (error)
- g_return_val_if_fail (*error == NULL, FALSE);
+ g_return_val_if_fail (!error || !*error, FALSE);
if (!validate_permissions_type (new_settings, error))
return FALSE;
- hash_to_connection (connection, new_settings);
+ _nm_connection_replace_settings (connection, new_settings);
return nm_connection_verify (connection, error);
}
return (NMConnection *) g_object_new (NM_TYPE_CONNECTION, NULL);
}
+/**
+ * _nm_connection_new_from_hash:
+ * @hash: (element-type utf8 GLib.HashTable): the #GHashTable describing
+ * the connection
+ *
+ * Creates a new #NMConnection from a hash table describing the connection. See
+ * nm_connection_to_hash() for a description of the expected hash table.
+ *
+ * Returns: the new #NMConnection object, populated with settings created
+ * from the values in the hash table.
+ **/
+NMConnection *
+_nm_connection_new_from_hash (GHashTable *hash)
+{
+ NMConnection *connection;
+
+ g_return_val_if_fail (hash != NULL, NULL);
+
+ connection = nm_connection_new ();
+ _nm_connection_replace_settings (connection, hash);
+ return connection;
+}
+
/**
* nm_connection_new_from_hash:
* @hash: (element-type utf8 GLib.HashTable): the #GHashTable describing
if (!validate_permissions_type (hash, error))
return NULL;
- connection = nm_connection_new ();
- hash_to_connection (connection, hash);
+ connection = _nm_connection_new_from_hash (hash);
if (!nm_connection_verify (connection, error))
g_clear_object (&connection);
return connection;
#include "nm-default.h"
+#include "nm-connection.h"
+
#define NM_SETTING_SECRET_FLAGS_ALL \
(NM_SETTING_SECRET_FLAG_NONE | \
NM_SETTING_SECRET_FLAG_AGENT_OWNED | \
gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
+NMConnection *_nm_connection_new_from_hash (GHashTable *hash);
+void _nm_connection_replace_settings (NMConnection *connection,
+ GHashTable *new_settings);
+
typedef enum NMSettingUpdateSecretResult {
NM_SETTING_UPDATE_SECRET_ERROR = FALSE,
NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED = TRUE,