Commit 773d3f0a authored by Dan Winship's avatar Dan Winship

libnm-core: rename NMConnection to/from_hash methods

Rename nm_connection_to_hash() to nm_connection_to_dbus(), and
nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In
addition to clarifying that this is specifically the D-Bus
serialization format, these names will also work better in the
GDBus-based future where the serialization format is GVariant, not
GHashTable.

Also, move NMSettingHashFlags to nm-connection.h, and rename it
NMConnectionSerializationFlags.
parent c9653a9e
......@@ -167,7 +167,7 @@ parse_main (GKeyFile *kf,
g_free (id);
nm_connection_add_setting (connection, NM_SETTING (s_con));
*out_con_hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
*out_con_hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
g_object_unref (connection);
*out_con_props = value_hash_create ();
......
......@@ -5438,7 +5438,7 @@ gen_cmd_print0 (const char *text, int state)
const char *setting_name;
int i = 0;
settings = nm_connection_to_hash (nmc_tab_completion.connection, NM_SETTING_HASH_FLAG_NO_SECRETS);
settings = nm_connection_to_dbus (nmc_tab_completion.connection, NM_CONNECTION_SERIALIZE_NO_SECRETS);
words = g_new (char *, g_hash_table_size (settings) + 2);
g_hash_table_iter_init (&iter, settings);
while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, NULL))
......
......@@ -188,7 +188,7 @@ build_edit_connection (NMConnection *orig_connection)
if (!NM_IS_REMOTE_CONNECTION (orig_connection))
return edit_connection;
settings = nm_connection_to_hash (orig_connection, NM_SETTING_HASH_FLAG_NO_SECRETS);
settings = nm_connection_to_dbus (orig_connection, NM_CONNECTION_SERIALIZE_NO_SECRETS);
g_hash_table_iter_init (&iter, settings);
while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, NULL)) {
nmt_sync_op_init (&op);
......
......@@ -70,7 +70,7 @@ add_connection (DBusGProxy *proxy, const char *con_name)
NULL);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
/* Call AddConnection with the hash as argument */
if (!dbus_g_proxy_call (proxy, "AddConnection", &error,
......
......@@ -66,7 +66,7 @@ print_connection (DBusGConnection *bus, const char *path)
/* Using the raw configuration, create an NMConnection object for it. This
* step also verifies that the data we got from NetworkManager are valid. */
connection = nm_simple_connection_new_from_hash (hash, &error);
connection = nm_simple_connection_new_from_dbus (hash, &error);
if (!connection) {
g_warning ("Received invalid connection data: %s", error->message);
g_error_free (error);
......
......@@ -308,7 +308,7 @@ hash_to_connection (NMConnection *connection, GHashTable *new, GError **error)
GType type = nm_setting_lookup_type (setting_name);
if (type) {
NMSetting *setting = _nm_setting_new_from_hash (type, setting_hash);
NMSetting *setting = _nm_setting_new_from_dbus (type, setting_hash);
if (setting) {
_nm_connection_add_setting (connection, setting);
......@@ -983,8 +983,8 @@ nm_connection_normalize (NMConnection *connection,
* Update the specified setting's secrets, given a hash table of secrets
* intended for that setting (deserialized from D-Bus for example). Will also
* extract the given setting's secrets hash if given a hash of hashes, as would
* be returned from nm_connection_to_hash(). If @setting_name is %NULL, expects
* a fully serialized #NMConnection as returned by nm_connection_to_hash() and
* be returned from nm_connection_to_dbus(). If @setting_name is %NULL, expects
* a fully serialized #NMConnection as returned by nm_connection_to_dbus() and
* will update all secrets from all settings contained in @secrets.
*
* Returns: %TRUE if the secrets were successfully updated, %FALSE if the update
......@@ -1228,15 +1228,15 @@ nm_connection_clear_secrets_with_flags (NMConnection *connection,
}
/**
* nm_connection_to_hash:
* nm_connection_to_dbus:
* @connection: the #NMConnection
* @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL
* @flags: serialization flags, e.g. %NM_CONNECTION_SERIALIZE_ALL
*
* Converts the #NMConnection into a #GHashTable describing the connection,
* suitable for marshalling over D-Bus or serializing. The hash table mapping
* is string:#GHashTable with each element in the returned hash representing
* a #NMSetting object. The keys are setting object names, and the values
* are #GHashTables mapping string:GValue, each of which represents the
* suitable for marshalling over D-Bus or otherwise serializing. The hash table
* mapping is string:#GHashTable with each element in the returned hash
* representing a #NMSetting object. The keys are setting object names, and the
* values are #GHashTables mapping string:GValue, each of which represents the
* properties of the #NMSetting object.
*
* Returns: (transfer full) (element-type utf8 GLib.HashTable): a new
......@@ -1245,7 +1245,7 @@ nm_connection_clear_secrets_with_flags (NMConnection *connection,
* with g_hash_table_unref() when it is no longer needed.
**/
GHashTable *
nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
nm_connection_to_dbus (NMConnection *connection, NMConnectionSerializationFlags flags)
{
NMConnectionPrivate *priv;
GHashTableIter iter;
......@@ -1264,7 +1264,7 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
while (g_hash_table_iter_next (&iter, &key, &data)) {
NMSetting *setting = NM_SETTING (data);
setting_hash = _nm_setting_to_hash (setting, flags);
setting_hash = _nm_setting_to_dbus (setting, flags);
if (setting_hash)
g_hash_table_insert (ret, g_strdup (nm_setting_get_name (setting)), setting_hash);
}
......
......@@ -140,6 +140,24 @@ NMSetting *nm_connection_get_setting (NMConnection *connection,
NMSetting *nm_connection_get_setting_by_name (NMConnection *connection,
const char *name);
/**
* NMConnectionSerializationFlags:
* @NM_CONNECTION_SERIALIZE_ALL: serialize all properties (including secrets)
* @NM_CONNECTION_SERIALIZE_NO_SECRETS: do not include secrets
* @NM_CONNECTION_SERIALIZE_ONLY_SECRETS: only serialize secrets
*
* These flags determine which properties are serialized when calling when
* calling nm_connection_to_dbus().
**/
typedef enum { /*< flags >*/
NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
} NMConnectionSerializationFlags;
GHashTable *nm_connection_to_dbus (NMConnection *connection,
NMConnectionSerializationFlags flags);
gboolean nm_connection_replace_settings (NMConnection *connection,
GHashTable *new_settings,
GError **error);
......@@ -192,9 +210,6 @@ void nm_connection_for_each_setting_value (NMConnection *connection,
NMSettingValueIterFn func,
gpointer user_data);
GHashTable *nm_connection_to_hash (NMConnection *connection,
NMSettingHashFlags flags);
void nm_connection_dump (NMConnection *connection);
/* Helpers */
......
......@@ -22,6 +22,7 @@
#define __NM_SETTING_PRIVATE_H__
#include "nm-setting.h"
#include "nm-connection.h"
#include "nm-glib-compat.h"
#include "nm-core-internal.h"
......@@ -114,10 +115,10 @@ NMSetting *_nm_setting_find_in_list_base_type (GSList *all_settings);
gboolean _nm_setting_slave_type_is_valid (const char *slave_type, const char **out_port_type);
const char * _nm_setting_slave_type_detect_from_settings (GSList *all_settings, NMSetting **out_s_port);
GHashTable *_nm_setting_to_hash (NMSetting *setting,
NMSettingHashFlags flags);
GHashTable *_nm_setting_to_dbus (NMSetting *setting,
NMConnectionSerializationFlags flags);
NMSetting *_nm_setting_new_from_hash (GType setting_type,
NMSetting *_nm_setting_new_from_dbus (GType setting_type,
GHashTable *hash);
#endif /* NM_SETTING_PRIVATE_H */
......@@ -380,9 +380,9 @@ destroy_gvalue (gpointer data)
}
/**
* _nm_setting_to_hash:
* _nm_setting_to_dbus:
* @setting: the #NMSetting
* @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL
* @flags: hash flags, e.g. %NM_CONNECTION_SERIALIZE_ALL
*
* Converts the #NMSetting into a #GHashTable mapping each setting property
* name to a GValue describing that property, suitable for marshalling over
......@@ -392,7 +392,7 @@ destroy_gvalue (gpointer data)
* describing the setting's properties
**/
GHashTable *
_nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
_nm_setting_to_dbus (NMSetting *setting, NMConnectionSerializationFlags flags)
{
GHashTable *hash;
GParamSpec **property_specs;
......@@ -414,11 +414,11 @@ _nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
if (strcmp (g_param_spec_get_name (prop_spec), NM_SETTING_NAME) == 0)
continue;
if ( (flags & NM_SETTING_HASH_FLAG_NO_SECRETS)
if ( (flags & NM_CONNECTION_SERIALIZE_NO_SECRETS)
&& (prop_spec->flags & NM_SETTING_PARAM_SECRET))
continue;
if ( (flags & NM_SETTING_HASH_FLAG_ONLY_SECRETS)
if ( (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS)
&& !(prop_spec->flags & NM_SETTING_PARAM_SECRET))
continue;
......@@ -444,7 +444,7 @@ _nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
}
/**
* _nm_setting_new_from_hash:
* _nm_setting_new_from_dbus:
* @setting_type: the #NMSetting type which the hash contains properties for
* @hash: (element-type utf8 GObject.Value): the #GHashTable containing a
* string to GValue mapping of properties that apply to the setting
......@@ -460,7 +460,7 @@ _nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
* hash table, or %NULL on failure
**/
NMSetting *
_nm_setting_new_from_hash (GType setting_type, GHashTable *hash)
_nm_setting_new_from_dbus (GType setting_type, GHashTable *hash)
{
GHashTableIter iter;
NMSetting *setting;
......
......@@ -232,22 +232,6 @@ GType nm_setting_get_type (void);
GType nm_setting_lookup_type (const char *name);
GType nm_setting_lookup_type_by_quark (GQuark error_quark);
/**
* NMSettingHashFlags:
* @NM_SETTING_HASH_FLAG_ALL: hash all properties (including secrets)
* @NM_SETTING_HASH_FLAG_NO_SECRETS: do not include secrets
* @NM_SETTING_HASH_FLAG_ONLY_SECRETS: only hash secrets
*
* These flags determine which properties are added to the resulting hash
* when calling nm_setting_to_hash().
*
**/
typedef enum {
NM_SETTING_HASH_FLAG_ALL = 0x00000000,
NM_SETTING_HASH_FLAG_NO_SECRETS = 0x00000001,
NM_SETTING_HASH_FLAG_ONLY_SECRETS = 0x00000002,
} NMSettingHashFlags;
NMSetting *nm_setting_duplicate (NMSetting *setting);
const char *nm_setting_get_name (NMSetting *setting);
......
......@@ -48,13 +48,13 @@ nm_simple_connection_new (void)
}
/**
* nm_simple_connection_new_from_hash:
* nm_simple_connection_new_from_dbus:
* @hash: (element-type utf8 GLib.HashTable): the #GHashTable describing
* the connection
* @error: on unsuccessful return, an error
*
* Creates a new #NMSimpleConnection from a hash table describing the
* connection. See nm_connection_to_hash() for a description of the expected
* connection. See nm_connection_to_dbus() for a description of the expected
* hash table.
*
* Returns: (transfer full): the new #NMSimpleConnection object, populated with
......@@ -62,7 +62,7 @@ nm_simple_connection_new (void)
* connection failed to validate
**/
NMConnection *
nm_simple_connection_new_from_hash (GHashTable *hash, GError **error)
nm_simple_connection_new_from_dbus (GHashTable *hash, GError **error)
{
NMConnection *connection;
......
......@@ -51,7 +51,7 @@ GType nm_simple_connection_get_type (void);
NMConnection *nm_simple_connection_new (void);
NMConnection *nm_simple_connection_new_from_hash (GHashTable *hash,
NMConnection *nm_simple_connection_new_from_dbus (GHashTable *hash,
GError **error);
NMConnection *nm_simple_connection_new_clone (NMConnection *connection);
......
......@@ -673,115 +673,115 @@ make_test_wsec_setting (const char *detail)
}
static void
test_setting_to_hash_all (void)
test_setting_to_dbus_all (void)
{
NMSettingWirelessSecurity *s_wsec;
GHashTable *hash;
s_wsec = make_test_wsec_setting ("setting-to-hash-all");
s_wsec = make_test_wsec_setting ("setting-to-dbus-all");
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
hash = _nm_setting_to_dbus (NM_SETTING (s_wsec), NM_CONNECTION_SERIALIZE_ALL);
/* Make sure all keys are there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT),
"setting-to-hash-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
"setting-to-dbus-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME),
"setting-to-hash-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
"setting-to-dbus-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_PSK),
"setting-to-hash-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_PSK);
"setting-to-dbus-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_PSK);
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0),
"setting-to-hash-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
"setting-to-dbus-all", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
g_hash_table_destroy (hash);
g_object_unref (s_wsec);
}
static void
test_setting_to_hash_no_secrets (void)
test_setting_to_dbus_no_secrets (void)
{
NMSettingWirelessSecurity *s_wsec;
GHashTable *hash;
s_wsec = make_test_wsec_setting ("setting-to-hash-no-secrets");
s_wsec = make_test_wsec_setting ("setting-to-dbus-no-secrets");
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_NO_SECRETS);
hash = _nm_setting_to_dbus (NM_SETTING (s_wsec), NM_CONNECTION_SERIALIZE_NO_SECRETS);
/* Make sure non-secret keys are there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT),
"setting-to-hash-no-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
"setting-to-dbus-no-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME),
"setting-to-hash-no-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
"setting-to-dbus-no-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
/* Make sure secrets are not there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_PSK) == NULL,
"setting-to-hash-no-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_PSK);
"setting-to-dbus-no-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_PSK);
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0) == NULL,
"setting-to-hash-no-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
"setting-to-dbus-no-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
g_hash_table_destroy (hash);
g_object_unref (s_wsec);
}
static void
test_setting_to_hash_only_secrets (void)
test_setting_to_dbus_only_secrets (void)
{
NMSettingWirelessSecurity *s_wsec;
GHashTable *hash;
s_wsec = make_test_wsec_setting ("setting-to-hash-only-secrets");
s_wsec = make_test_wsec_setting ("setting-to-dbus-only-secrets");
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ONLY_SECRETS);
hash = _nm_setting_to_dbus (NM_SETTING (s_wsec), NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
/* Make sure non-secret keys are there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT) == NULL,
"setting-to-hash-only-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
"setting-to-dbus-only-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_KEY_MGMT);
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME) == NULL,
"setting-to-hash-only-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
"setting-to-dbus-only-secrets", "unexpectedly present " NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
/* Make sure secrets are not there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_PSK),
"setting-to-hash-only-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_PSK);
"setting-to-dbus-only-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_PSK);
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0),
"setting-to-hash-only-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
"setting-to-dbus-only-secrets", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
g_hash_table_destroy (hash);
g_object_unref (s_wsec);
}
static void
test_connection_to_hash_setting_name (void)
test_connection_to_dbus_setting_name (void)
{
NMConnection *connection;
NMSettingWirelessSecurity *s_wsec;
GHashTable *hash;
connection = nm_simple_connection_new ();
s_wsec = make_test_wsec_setting ("connection-to-hash-setting-name");
s_wsec = make_test_wsec_setting ("connection-to-dbus-setting-name");
nm_connection_add_setting (connection, NM_SETTING (s_wsec));
hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
/* Make sure the keys of the first level hash are setting names, not
* the GType name of the setting objects.
*/
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) != NULL,
"connection-to-hash-setting-name", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
"connection-to-dbus-setting-name", "unexpectedly missing " NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
g_hash_table_destroy (hash);
g_object_unref (connection);
}
static void
test_setting_new_from_hash (void)
test_setting_new_from_dbus (void)
{
NMSettingWirelessSecurity *s_wsec;
GHashTable *hash;
s_wsec = make_test_wsec_setting ("setting-to-hash-all");
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
s_wsec = make_test_wsec_setting ("setting-to-dbus-all");
hash = _nm_setting_to_dbus (NM_SETTING (s_wsec), NM_CONNECTION_SERIALIZE_ALL);
g_object_unref (s_wsec);
s_wsec = (NMSettingWirelessSecurity *) _nm_setting_new_from_hash (NM_TYPE_SETTING_WIRELESS_SECURITY, hash);
s_wsec = (NMSettingWirelessSecurity *) _nm_setting_new_from_dbus (NM_TYPE_SETTING_WIRELESS_SECURITY, hash);
g_hash_table_destroy (hash);
g_assert (s_wsec);
......@@ -992,7 +992,7 @@ test_connection_replace_settings_from_connection ()
}
static void
test_connection_new_from_hash ()
test_connection_new_from_dbus ()
{
NMConnection *connection;
GHashTable *new_settings;
......@@ -1006,7 +1006,7 @@ test_connection_new_from_hash ()
g_assert (new_settings);
/* Replace settings and test */
connection = nm_simple_connection_new_from_hash (new_settings, &error);
connection = nm_simple_connection_new_from_dbus (new_settings, &error);
g_assert_no_error (error);
g_assert (connection);
......@@ -3096,9 +3096,9 @@ int main (int argc, char **argv)
g_test_add_func ("/core/general/test_setting_gsm_apn_bad_chars", test_setting_gsm_apn_bad_chars);
g_test_add_func ("/core/general/test_setting_gsm_apn_underscore", test_setting_gsm_apn_underscore);
g_test_add_func ("/core/general/test_setting_gsm_without_number", test_setting_gsm_without_number);
g_test_add_func ("/core/general/test_setting_to_hash_all", test_setting_to_hash_all);
g_test_add_func ("/core/general/test_setting_to_hash_no_secrets", test_setting_to_hash_no_secrets);
g_test_add_func ("/core/general/test_setting_to_hash_only_secrets", test_setting_to_hash_only_secrets);
g_test_add_func ("/core/general/test_setting_to_dbus_all", test_setting_to_dbus_all);
g_test_add_func ("/core/general/test_setting_to_dbus_no_secrets", test_setting_to_dbus_no_secrets);
g_test_add_func ("/core/general/test_setting_to_dbus_only_secrets", test_setting_to_dbus_only_secrets);
g_test_add_func ("/core/general/test_setting_compare_id", test_setting_compare_id);
#define ADD_FUNC(func, secret_flags, comp_flags, remove_secret) \
g_test_add_data_func_full ("/core/general/" G_STRINGIFY (func), \
......@@ -3114,11 +3114,11 @@ int main (int argc, char **argv)
ADD_FUNC (test_setting_compare_vpn_secrets, NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_COMPARE_FLAG_EXACT, FALSE);
g_test_add_func ("/core/general/test_setting_old_uuid", test_setting_old_uuid);
g_test_add_func ("/core/general/test_connection_to_hash_setting_name", test_connection_to_hash_setting_name);
g_test_add_func ("/core/general/test_setting_new_from_hash", test_setting_new_from_hash);
g_test_add_func ("/core/general/test_connection_to_dbus_setting_name", test_connection_to_dbus_setting_name);
g_test_add_func ("/core/general/test_setting_new_from_dbus", test_setting_new_from_dbus);
g_test_add_func ("/core/general/test_connection_replace_settings", test_connection_replace_settings);
g_test_add_func ("/core/general/test_connection_replace_settings_from_connection", test_connection_replace_settings_from_connection);
g_test_add_func ("/core/general/test_connection_new_from_hash", test_connection_new_from_hash);
g_test_add_func ("/core/general/test_connection_new_from_dbus", test_connection_new_from_dbus);
g_test_add_func ("/core/general/test_connection_normalize_connection_interface_name", test_connection_normalize_connection_interface_name);
g_test_add_func ("/core/general/test_connection_normalize_virtual_iface_name", test_connection_normalize_virtual_iface_name);
g_test_add_func ("/core/general/test_connection_normalize_type", test_connection_normalize_type);
......
......@@ -595,7 +595,7 @@ test_update_secrets_whole_connection (void)
connection = wifi_connection_new ();
/* Build up the secrets hash */
secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
secrets = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
wsec_hash = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
g_assert (wsec_hash);
g_hash_table_insert (wsec_hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey));
......@@ -645,7 +645,7 @@ test_update_secrets_whole_connection_bad_setting (void)
connection = wifi_connection_new ();
/* Build up the secrets hash */
secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
secrets = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
wsec_hash = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
g_assert (wsec_hash);
g_hash_table_insert (wsec_hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey));
......@@ -678,7 +678,7 @@ test_update_secrets_whole_connection_empty_base_setting (void)
*/
connection = wifi_connection_new ();
secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ONLY_SECRETS);
secrets = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
g_assert_cmpint (g_hash_table_size (secrets), ==, 1);
g_assert (g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SETTING_NAME));
......
......@@ -123,8 +123,9 @@ global:
nm_connection_remove_setting;
nm_connection_replace_settings;
nm_connection_replace_settings_from_connection;
nm_connection_serialization_flags_get_type;
nm_connection_set_path;
nm_connection_to_hash;
nm_connection_to_dbus;
nm_connection_update_secrets;
nm_connection_verify;
nm_connectivity_state_get_type;
......@@ -591,7 +592,6 @@ global:
nm_setting_gsm_get_type;
nm_setting_gsm_get_username;
nm_setting_gsm_new;
nm_setting_hash_flags_get_type;
nm_setting_infiniband_error_get_type;
nm_setting_infiniband_error_quark;
nm_setting_infiniband_get_mac_address;
......@@ -864,7 +864,7 @@ global:
nm_simple_connection_get_type;
nm_simple_connection_new;
nm_simple_connection_new_clone;
nm_simple_connection_new_from_hash;
nm_simple_connection_new_from_dbus;
nm_ssid_get_type;
nm_state_get_type;
nm_string_array_get_type;
......
......@@ -718,7 +718,7 @@ nm_client_add_and_activate_connection (NMClient *client,
info->client = client;
if (partial)
hash = nm_connection_to_hash (partial, NM_SETTING_HASH_FLAG_ALL);
hash = nm_connection_to_dbus (partial, NM_CONNECTION_SERIALIZE_ALL);
if (!hash)
hash = g_hash_table_new (g_str_hash, g_str_equal);
......
......@@ -221,7 +221,7 @@ nm_remote_connection_commit_changes (NMRemoteConnection *self,
if (!call)
return;
settings = nm_connection_to_hash (NM_CONNECTION (self), NM_SETTING_HASH_FLAG_ALL);
settings = nm_connection_to_dbus (NM_CONNECTION (self), NM_CONNECTION_SERIALIZE_ALL);
call->call = dbus_g_proxy_begin_call (priv->proxy, "Update",
remote_call_dbus_cb, call, NULL,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, settings,
......@@ -259,7 +259,7 @@ nm_remote_connection_commit_changes_unsaved (NMRemoteConnection *connection,
if (!call)
return;
settings = nm_connection_to_hash (NM_CONNECTION (connection), NM_SETTING_HASH_FLAG_ALL);
settings = nm_connection_to_dbus (NM_CONNECTION (connection), NM_CONNECTION_SERIALIZE_ALL);
call->call = dbus_g_proxy_begin_call (priv->proxy, "UpdateUnsaved",
remote_call_dbus_cb, call, NULL,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, settings,
......
......@@ -485,7 +485,7 @@ nm_remote_settings_add_connection (NMRemoteSettings *settings,
info->callback = callback;
info->callback_data = user_data;
new_settings = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
new_settings = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
dbus_g_proxy_begin_call (priv->proxy, "AddConnection",
add_connection_done,
info,
......@@ -538,7 +538,7 @@ nm_remote_settings_add_connection_unsaved (NMRemoteSettings *settings,
info->callback = callback;
info->callback_data = user_data;
new_settings = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
new_settings = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
dbus_g_proxy_begin_call (priv->proxy, "AddConnectionUnsaved",
add_connection_done,
info,
......
......@@ -330,7 +330,7 @@ verify_request (NMSecretAgent *self,
/* Make sure the given connection is valid */
g_assert (out_connection);
connection = nm_simple_connection_new_from_hash (connection_hash, &local);
connection = nm_simple_connection_new_from_dbus (connection_hash, &local);
if (connection) {
nm_connection_set_path (connection, connection_path);
*out_connection = connection;
......
......@@ -86,7 +86,7 @@ typedef struct {
* has returned
* @secrets: (element-type utf8 GLib.HashTable): the #GHashTable containing
* the requested secrets in the same format as an #NMConnection hash (as
* created by nm_connection_to_hash() for example). Each key in @secrets
* created by nm_connection_to_dbus() for example). Each key in @secrets
* should be the name of a #NMSetting object (like "802-11-wireless-security")
* and each value should be a #GHashTable. The sub-hashes map string:#GValue
* where the string is the setting property name (like "psk") and the value
......@@ -114,7 +114,7 @@ typedef struct {
* NM_SETTING_WIRELESS_SECURITY_PSK, "my really cool PSK",
* NULL);
* nm_connection_add_setting (secrets, NM_SETTING (s_wsec));
* secrets_hash = nm_connection_to_hash (secrets, NM_SETTING_HASH_FLAG_ALL);
* secrets_hash = nm_connection_to_dbus (secrets, NM_CONNECTION_SERIALIZE_ALL);
*
* (call the NMSecretAgentGetSecretsFunc with secrets_hash)
*
......
......@@ -451,7 +451,7 @@ _connect_generic (NMVpnPlugin *plugin,
return FALSE;
}
connection = nm_simple_connection_new_from_hash (properties, &local);
connection = nm_simple_connection_new_from_dbus (properties, &local);
if (!connection) {
g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Invalid connection: (%d) %s",
......@@ -525,7 +525,7 @@ impl_vpn_plugin_need_secrets (NMVpnPlugin *plugin,
g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE);
g_return_val_if_fail (properties != NULL, FALSE);
connection = nm_simple_connection_new_from_hash (properties, &cnfh_err);
connection = nm_simple_connection_new_from_dbus (properties, &cnfh_err);
if (!connection) {
g_set_error (err,
NM_VPN_PLUGIN_ERROR,
......@@ -580,7 +580,7 @@ impl_vpn_plugin_new_secrets (NMVpnPlugin *plugin,
return FALSE;
}
connection = nm_simple_connection_new_from_hash (properties, &local);
connection = nm_simple_connection_new_from_dbus (properties, &local);
if (!connection) {
g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Invalid connection: (%d) %s",
......
......@@ -471,7 +471,7 @@ _dispatcher_call (DispatcherAction action,
}
if (connection) {
connection_hash = nm_connection_to_hash (