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.
This commit is contained in:
Dan Winship 2014-08-06 19:35:31 -04:00
parent c9653a9e67
commit 773d3f0ab6
27 changed files with 119 additions and 119 deletions

View file

@ -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 ();

View file

@ -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))

View file

@ -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);

View file

@ -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,

View file

@ -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);

View file

@ -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);
}

View file

@ -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 */

View file

@ -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 */

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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));

View file

@ -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;

View file

@ -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);

View file

@ -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,

View file

@ -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,

View file

@ -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;

View file

@ -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)
*

View file

@ -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",

View file

@ -471,7 +471,7 @@ _dispatcher_call (DispatcherAction action,
}
if (connection) {
connection_hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_NO_SECRETS);
connection_hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_NO_SECRETS);
connection_props = value_hash_create ();
value_hash_add_object_path (connection_props,

View file

@ -1195,7 +1195,7 @@ nm_agent_manager_get_secrets (NMAgentManager *self,
/* NOTE: a few things in the Request handling depend on existing_secrets
* being NULL if there aren't any system-owned secrets for this connection.
* This in turn depends on nm_connection_to_hash() and nm_setting_to_hash()
* This in turn depends on nm_connection_to_dbus() and nm_setting_to_hash()
* both returning NULL if they didn't hash anything.
*/

View file

@ -293,7 +293,7 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
g_return_val_if_fail (priv->proxy != NULL, NULL);
hash = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
/* Mask off the private ONLY_SYSTEM flag if present */
flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM;
@ -379,7 +379,7 @@ agent_save_delete_cb (DBusGProxy *proxy,
static gpointer
agent_new_save_delete (NMSecretAgent *self,
NMConnection *connection,
NMSettingHashFlags hash_flags,
NMConnectionSerializationFlags flags,
const char *method,
NMSecretAgentCallback callback,
gpointer callback_data)
@ -389,7 +389,7 @@ agent_new_save_delete (NMSecretAgent *self,
Request *r;
const char *cpath = nm_connection_get_path (connection);
hash = nm_connection_to_hash (connection, hash_flags);
hash = nm_connection_to_dbus (connection, flags);
r = request_new (self, cpath, NULL, callback, callback_data);
r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
@ -419,7 +419,7 @@ nm_secret_agent_save_secrets (NMSecretAgent *self,
/* Caller should have ensured that only agent-owned secrets exist in 'connection' */
return agent_new_save_delete (self,
connection,
NM_SETTING_HASH_FLAG_ALL,
NM_CONNECTION_SERIALIZE_ALL,
"SaveSecrets",
callback,
callback_data);
@ -437,7 +437,7 @@ nm_secret_agent_delete_secrets (NMSecretAgent *self,
/* No secrets sent; agents must be smart enough to track secrets using the UUID or something */
return agent_new_save_delete (self,
connection,
NM_SETTING_HASH_FLAG_NO_SECRETS,
NM_CONNECTION_SERIALIZE_NO_SECRETS,
"DeleteSecrets",
callback,
callback_data);

View file

@ -478,7 +478,7 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
* in the replacement connection data if it was eg reread from disk.
*/
if (priv->agent_secrets) {
hash = nm_connection_to_hash (priv->agent_secrets, NM_SETTING_HASH_FLAG_ONLY_SECRETS);
hash = nm_connection_to_dbus (priv->agent_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (hash) {
(void) nm_connection_update_secrets (NM_CONNECTION (self), NULL, hash, NULL);
g_hash_table_destroy (hash);
@ -811,7 +811,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
/* Update the connection with our existing secrets from backing storage */
nm_connection_clear_secrets (NM_CONNECTION (self));
hash = nm_connection_to_hash (priv->system_secrets, NM_SETTING_HASH_FLAG_ONLY_SECRETS);
hash = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (!hash || nm_connection_update_secrets (NM_CONNECTION (self), setting_name, hash, &local)) {
/* Update the connection with the agent's secrets; by this point if any
* system-owned secrets exist in 'secrets' the agent that provided them
@ -915,7 +915,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
return 0;
}
existing_secrets = nm_connection_to_hash (priv->system_secrets, NM_SETTING_HASH_FLAG_ONLY_SECRETS);
existing_secrets = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
call_id = nm_agent_manager_get_secrets (priv->agent_mgr,
NM_CONNECTION (self),
subject,
@ -1181,7 +1181,7 @@ get_settings_auth_cb (NMSettingsConnection *self,
* get returned by the GetSecrets method which can be better
* protected against leakage of secrets to unprivileged callers.
*/
settings = nm_connection_to_hash (NM_CONNECTION (dupl_con), NM_SETTING_HASH_FLAG_NO_SECRETS);
settings = nm_connection_to_dbus (NM_CONNECTION (dupl_con), NM_CONNECTION_SERIALIZE_NO_SECRETS);
g_assert (settings);
dbus_g_method_return (context, settings);
g_hash_table_destroy (settings);
@ -1343,7 +1343,7 @@ impl_settings_connection_update_helper (NMSettingsConnection *self,
/* Check if the settings are valid first */
if (new_settings) {
tmp = nm_simple_connection_new_from_hash (new_settings, &error);
tmp = nm_simple_connection_new_from_dbus (new_settings, &error);
if (!tmp) {
g_assert (error);
goto error;
@ -1510,7 +1510,7 @@ dbus_get_agent_secrets_cb (NMSettingsConnection *self,
* secrets from backing storage and those returned from the agent
* by the time we get here.
*/
hash = nm_connection_to_hash (NM_CONNECTION (self), NM_SETTING_HASH_FLAG_ONLY_SECRETS);
hash = nm_connection_to_dbus (NM_CONNECTION (self), NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (!hash)
hash = g_hash_table_new (NULL, NULL);
dbus_g_method_return (context, hash);

View file

@ -1224,7 +1224,7 @@ impl_settings_add_connection_helper (NMSettings *self,
NMConnection *connection;
GError *error = NULL;
connection = nm_simple_connection_new_from_hash (settings, &error);
connection = nm_simple_connection_new_from_dbus (settings, &error);
if (connection) {
nm_settings_add_connection_dbus (self,
connection,

View file

@ -1466,14 +1466,14 @@ _hash_with_username (NMConnection *connection, const char *username)
g_assert (s_vpn);
existing = nm_setting_vpn_get_user_name (s_vpn);
if (username == NULL || existing)
return nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL);
return nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
dup = nm_simple_connection_new_clone (connection);
g_assert (dup);
s_vpn = nm_connection_get_setting_vpn (dup);
g_assert (s_vpn);
g_object_set (s_vpn, NM_SETTING_VPN_USER_NAME, username, NULL);
hash = nm_connection_to_hash (dup, NM_SETTING_HASH_FLAG_ALL);
hash = nm_connection_to_dbus (dup, NM_CONNECTION_SERIALIZE_ALL);
g_object_unref (dup);
return hash;
}