Commit acf86f68 authored by Dan Winship's avatar Dan Winship

libnm-core: change connection hash tables to variants in API

In preparation for porting to GDBus, make nm_connection_to_dbus(),
etc, represent connections as GVariants of type 'a{sa{sv}}' rather
than as GHashTables-of-GHashTables-of-GValues.

This means we're constantly converting back and forth internally, but
this is just a stepping stone on the way to the full GDBus port, and
all of that code will go away again later.
parent 47505595
......@@ -406,7 +406,7 @@ nm_dispatcher_utils_construct_envp (const char *action,
}
/* UUID and ID */
con_setting = g_variant_lookup_value (connection_dict, NM_SETTING_CONNECTION_SETTING_NAME, G_VARIANT_TYPE ("a{sv}"));
con_setting = g_variant_lookup_value (connection_dict, NM_SETTING_CONNECTION_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
if (!con_setting) {
g_warning ("Failed to read connection setting");
return NULL;
......
......@@ -30,25 +30,9 @@
#include "nm-dispatcher-utils.h"
#include "nm-dispatcher-api.h"
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
/*******************************************/
static GVariant *
connection_hash_to_dict (GHashTable *hash)
{
GValue val = { 0, };
GVariant *dict;
g_value_init (&val, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT);
g_value_set_boxed (&val, hash);
dict = dbus_g_value_build_g_variant (&val);
g_value_unset (&val);
g_variant_ref_sink (dict);
return dict;
}
static gboolean
parse_main (GKeyFile *kf,
GVariant **out_con_dict,
......@@ -62,7 +46,6 @@ parse_main (GKeyFile *kf,
NMConnection *connection;
NMSettingConnection *s_con;
GVariantBuilder props;
GHashTable *con_hash;
*out_expected_iface = g_key_file_get_string (kf, "main", "expected-iface", error);
if (*out_expected_iface == NULL)
......@@ -93,10 +76,8 @@ parse_main (GKeyFile *kf,
g_free (id);
nm_connection_add_setting (connection, NM_SETTING (s_con));
con_hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
*out_con_dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
g_object_unref (connection);
*out_con_dict = connection_hash_to_dict (con_hash);
g_hash_table_unref (con_hash);
g_variant_builder_init (&props, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&props, "{sv}",
......
......@@ -5343,19 +5343,19 @@ gen_cmd_print0 (const char *text, int state)
char *ret = NULL;
if (!state) {
GHashTable *settings;
GHashTableIter iter;
GVariant *settings;
GVariantIter iter;
const char *setting_name;
int i = 0;
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))
words = g_new (char *, g_variant_n_children (settings) + 2);
g_variant_iter_init (&iter, settings);
while (g_variant_iter_next (&iter, "{&s@a{sv}}", &setting_name, NULL))
words [i++] = g_strdup (setting_name);
words[i++] = g_strdup ("all");
words[i] = NULL;
g_hash_table_unref (settings);
g_variant_unref (settings);
}
if (words) {
......
......@@ -162,31 +162,21 @@ save_connection_and_exit (NmtNewtButton *button,
static void
got_secrets (NMRemoteConnection *connection,
GHashTable *secrets,
GVariant *secrets,
GError *error,
gpointer op)
{
GHashTable *copy = NULL, *setting;
GHashTableIter iter;
const char *name;
if (secrets) {
/* 'secrets' is owned by the caller so we must copy it */
copy = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
g_hash_table_iter_init (&iter, secrets);
while (g_hash_table_iter_next (&iter, (gpointer) &name, (gpointer) &setting))
g_hash_table_insert (copy, g_strdup (name), nm_utils_gvalue_hash_dup (setting));
}
nmt_sync_op_complete_pointer (op, copy, error);
if (secrets)
g_variant_ref (secrets);
nmt_sync_op_complete_pointer (op, secrets, error);
}
static NMConnection *
build_edit_connection (NMConnection *orig_connection)
{
NMConnection *edit_connection;
GHashTable *settings, *secrets;
GHashTableIter iter;
GVariant *settings, *secrets;
GVariantIter iter;
const char *setting_name;
NmtSyncOp op;
......@@ -196,8 +186,8 @@ build_edit_connection (NMConnection *orig_connection)
return edit_connection;
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)) {
g_variant_iter_init (&iter, settings);
while (g_variant_iter_next (&iter, "{&s@a{sv}}", &setting_name, NULL)) {
nmt_sync_op_init (&op);
nm_remote_connection_get_secrets (NM_REMOTE_CONNECTION (orig_connection),
setting_name, got_secrets, &op);
......@@ -205,10 +195,10 @@ build_edit_connection (NMConnection *orig_connection)
secrets = nmt_sync_op_wait_pointer (&op, NULL);
if (secrets) {
(void) nm_connection_update_secrets (edit_connection, setting_name, secrets, NULL);
g_hash_table_unref (secrets);
g_variant_unref (secrets);
}
}
g_hash_table_unref (settings);
g_variant_unref (settings);
return edit_connection;
}
......
......@@ -482,14 +482,6 @@ nmt_secret_agent_get_secrets (NMSecretAgent *agent,
request_secrets_from_ui (request);
}
static void
gvalue_destroy_notify (gpointer data)
{
GValue *value = data;
g_value_unset (value);
g_slice_free (GValue, value);
}
/**
* nmt_secret_agent_response:
* @self: the #NmtSecretAgent
......@@ -511,8 +503,7 @@ nmt_secret_agent_response (NmtSecretAgent *self,
{
NmtSecretAgentPrivate *priv;
NmtSecretAgentRequest *request;
GHashTable *hash = NULL, *setting_hash;
GValue *value;
GVariant *dict = NULL;
GError *error = NULL;
int i;
......@@ -523,32 +514,41 @@ nmt_secret_agent_response (NmtSecretAgent *self,
g_return_if_fail (request != NULL);
if (secrets) {
hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_hash_table_unref);
GVariantBuilder conn_builder, *setting_builder;
GHashTable *settings;
GHashTableIter iter;
const char *name;
settings = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < secrets->len; i++) {
NmtSecretAgentSecretReal *secret = secrets->pdata[i];
setting_hash = g_hash_table_lookup (hash, nm_setting_get_name (secret->setting));
if (!setting_hash) {
setting_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, gvalue_destroy_notify);
g_hash_table_insert (hash, (char *)nm_setting_get_name (secret->setting),
setting_hash);
setting_builder = g_hash_table_lookup (settings, nm_setting_get_name (secret->setting));
if (!setting_builder) {
setting_builder = g_variant_builder_new (NM_VARIANT_TYPE_SETTING);
g_hash_table_insert (settings, (char *) nm_setting_get_name (secret->setting),
setting_builder);
}
value = g_slice_new0 (GValue);
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, secret->base.value);
g_hash_table_insert (setting_hash, g_strdup (secret->property), value);
g_variant_builder_add (setting_builder, "{sv}",
secret->property,
g_variant_new_string (secret->base.value));
}
g_variant_builder_init (&conn_builder, NM_VARIANT_TYPE_CONNECTION);
g_hash_table_iter_init (&iter, settings);
while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &setting_builder))
g_variant_builder_add (&conn_builder, "{sa{sv}}", name, setting_builder);
dict = g_variant_builder_end (&conn_builder);
g_hash_table_destroy (settings);
} else {
error = g_error_new (NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_USER_CANCELED,
"User cancelled");
}
request->callback (NM_SECRET_AGENT (self), request->connection, hash, error, request->callback_data);
request->callback (NM_SECRET_AGENT (self), request->connection, dict, error, request->callback_data);
g_clear_pointer (&hash, g_hash_table_unref);
g_clear_pointer (&dict, g_variant_unref);
g_clear_error (&error);
g_hash_table_remove (priv->requests, request_id);
}
......
......@@ -62,8 +62,7 @@ GTKDOC_CFLAGS = \
-I$(top_srcdir)/libnm \
-I$(top_builddir)/libnm \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS)
$(GLIB_CFLAGS)
GTKDOC_LIBS = \
$(top_builddir)/libnm/libnm.la \
......
......@@ -81,6 +81,5 @@ libnm_core_sources = \
$(core)/nm-setting-wireless.c \
$(core)/nm-setting.c \
$(core)/nm-simple-connection.c \
$(core)/nm-utils.c \
$(core)/nm-value-transforms.c
$(core)/nm-utils.c
This diff is collapsed.
......@@ -140,6 +140,25 @@ NMSetting *nm_connection_get_setting (NMConnection *connection,
NMSetting *nm_connection_get_setting_by_name (NMConnection *connection,
const char *name);
/**
* NM_VARIANT_TYPE_CONNECTION:
*
* #GVariantType for a dictionary mapping from setting names to
* %NM_VARIANT_TYPE_SETTING variants. This is used to represent an
* #NMConnection, and is the type taken by nm_simple_connection_new_from_dbus()
* and returned from nm_connection_to_dbus().
*/
#define NM_VARIANT_TYPE_CONNECTION (G_VARIANT_TYPE ("a{sa{sv}}"))
/**
* NM_VARIANT_TYPE_SETTING:
*
* #GVariantType for a dictionary mapping from property names to values. This is
* an alias for %G_VARIANT_TYPE_VARDICT, and is the type of each element of
* an %NM_VARIANT_TYPE_CONNECTION dictionary.
*/
#define NM_VARIANT_TYPE_SETTING G_VARIANT_TYPE_VARDICT
/**
* NMConnectionSerializationFlags:
* @NM_CONNECTION_SERIALIZE_ALL: serialize all properties (including secrets)
......@@ -155,11 +174,11 @@ typedef enum { /*< flags >*/
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
} NMConnectionSerializationFlags;
GHashTable *nm_connection_to_dbus (NMConnection *connection,
GVariant *nm_connection_to_dbus (NMConnection *connection,
NMConnectionSerializationFlags flags);
gboolean nm_connection_replace_settings (NMConnection *connection,
GHashTable *new_settings,
GVariant *new_settings,
GError **error);
void nm_connection_replace_settings_from_connection (NMConnection *connection,
......@@ -193,7 +212,7 @@ void nm_connection_clear_secrets_with_flags (NMConnection *connection,
gboolean nm_connection_update_secrets (NMConnection *connection,
const char *setting_name,
GHashTable *secrets,
GVariant *secrets,
GError **error);
void nm_connection_set_path (NMConnection *connection,
......
......@@ -78,4 +78,9 @@ GPtrArray *_nm_utils_copy_array (const GPtrArray *array,
GDestroyNotify free_func);
GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array);
/* compat */
GVariant *_nm_utils_connection_hash_to_dict (GHashTable *hash);
GHashTable *_nm_utils_connection_dict_to_hash (GVariant *dict);
#endif
This diff is collapsed.
......@@ -23,8 +23,8 @@
#ifndef __NM_PROPERTY_COMPARE_H__
#define __NM_PROPERTY_COMPARE_H__
#include <glib-object.h>
#include <glib.h>
int nm_property_compare (const GValue *value1, const GValue *value2);
int nm_property_compare (GVariant *value1, GVariant *value2);
#endif /* __NM_PROPERTY_COMPARE_H__ */
......@@ -21,12 +21,10 @@
*/
#include <string.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-8021x.h"
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
#include "crypto.h"
#include "nm-utils-private.h"
#include "nm-setting-private.h"
......@@ -3188,7 +3186,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_CA_CERT,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_bytes_to_dbus,
_nm_utils_bytes_from_dbus);
......@@ -3257,7 +3255,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_CLIENT_CERT,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_bytes_to_dbus,
_nm_utils_bytes_from_dbus);
......@@ -3370,7 +3368,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_CA_CERT,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_bytes_to_dbus,
_nm_utils_bytes_from_dbus);
......@@ -3444,7 +3442,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_CLIENT_CERT,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_bytes_to_dbus,
_nm_utils_bytes_from_dbus);
......@@ -3493,7 +3491,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
NM_SETTING_PARAM_SECRET |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PASSWORD_RAW,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_bytes_to_dbus,
_nm_utils_bytes_from_dbus);
......@@ -3548,7 +3546,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PRIVATE_KEY,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_bytes_to_dbus,
_nm_utils_bytes_from_dbus);
......@@ -3617,7 +3615,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_bytes_to_dbus,
_nm_utils_bytes_from_dbus);
......
......@@ -24,7 +24,6 @@
#include <net/ethernet.h>
#include <glib/gi18n.h>
#include "nm-dbus-glib-types.h"
#include "nm-setting-bluetooth.h"
#include "nm-setting-cdma.h"
#include "nm-setting-gsm.h"
......@@ -276,7 +275,7 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_BLUETOOTH_BDADDR,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_hwaddr_to_dbus,
_nm_utils_hwaddr_from_dbus);
......
......@@ -24,13 +24,11 @@
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-bond.h"
#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-setting-private.h"
/**
......@@ -734,11 +732,12 @@ nm_setting_bond_class_init (NMSettingBondClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_BOND_OPTIONS,
DBUS_TYPE_G_MAP_OF_STRING,
G_VARIANT_TYPE ("a{ss}"),
_nm_utils_strdict_to_dbus,
_nm_utils_strdict_from_dbus);
_nm_setting_class_add_dbus_only_property (parent_class, "interface-name", G_TYPE_STRING,
_nm_setting_class_add_dbus_only_property (parent_class, "interface-name",
G_VARIANT_TYPE_STRING,
_nm_setting_get_deprecated_virtual_interface_name,
NULL);
}
......@@ -22,7 +22,6 @@
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-bridge-port.h"
......
......@@ -22,7 +22,6 @@
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-bridge.h"
......@@ -388,7 +387,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_BRIDGE_MAC_ADDRESS,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_hwaddr_to_dbus,
_nm_utils_hwaddr_from_dbus);
......@@ -478,7 +477,8 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_add_dbus_only_property (parent_class, "interface-name", G_TYPE_STRING,
_nm_setting_class_add_dbus_only_property (parent_class, "interface-name",
G_VARIANT_TYPE_STRING,
_nm_setting_get_deprecated_virtual_interface_name,
NULL);
}
......@@ -949,35 +949,34 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
static const char *
find_virtual_interface_name (GHashTable *connection_hash)
find_virtual_interface_name (GVariant *connection_dict)
{
GHashTable *setting_hash;
GValue *value;
setting_hash = g_hash_table_lookup (connection_hash, NM_SETTING_BOND_SETTING_NAME);
if (!setting_hash)
setting_hash = g_hash_table_lookup (connection_hash, NM_SETTING_BRIDGE_SETTING_NAME);
if (!setting_hash)
setting_hash = g_hash_table_lookup (connection_hash, NM_SETTING_TEAM_SETTING_NAME);
if (!setting_hash)
setting_hash = g_hash_table_lookup (connection_hash, NM_SETTING_VLAN_SETTING_NAME);
if (!setting_hash)
GVariant *setting_dict;
const char *interface_name;
setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_BOND_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
if (!setting_dict)
setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_BRIDGE_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
if (!setting_dict)
setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_TEAM_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
if (!setting_dict)
setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_VLAN_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
if (!setting_dict)
return NULL;
/* All of the deprecated virtual interface name properties were named "interface-name". */
value = g_hash_table_lookup (setting_hash, "interface-name");
if (!value || !G_VALUE_HOLDS_STRING (value))
if (!g_variant_lookup (setting_dict, "interface-name", "&s", &interface_name))
return NULL;
return g_value_get_string (value);
return interface_name;
}
static void
nm_setting_connection_set_interface_name (NMSetting *setting,
GHashTable *connection_hash,
GVariant *connection_dict,
const char *property,
const GValue *value)
GVariant *value)
{
const char *interface_name;
......@@ -985,9 +984,9 @@ nm_setting_connection_set_interface_name (NMSetting *setting,
* we need to make verification fail, even if that virtual name would be
* overridden by a valid connection.interface-name.
*/
interface_name = find_virtual_interface_name (connection_hash);
interface_name = find_virtual_interface_name (connection_dict);
if (!interface_name || nm_utils_iface_valid_name (interface_name))
interface_name = g_value_get_string (value);
interface_name = g_variant_get_string (value, NULL);
g_object_set (G_OBJECT (setting),
NM_SETTING_CONNECTION_INTERFACE_NAME, interface_name,
......@@ -996,12 +995,12 @@ nm_setting_connection_set_interface_name (NMSetting *setting,
static void
nm_setting_connection_no_interface_name (NMSetting *setting,
GHashTable *connection_hash,
GVariant *connection_dict,
const char *property)
{
const char *virtual_interface_name;
virtual_interface_name = find_virtual_interface_name (connection_hash);
virtual_interface_name = find_virtual_interface_name (connection_dict);
g_object_set (G_OBJECT (setting),
NM_SETTING_CONNECTION_INTERFACE_NAME, virtual_interface_name,
NULL);
......@@ -1271,7 +1270,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_override_property (parent_class, NM_SETTING_CONNECTION_INTERFACE_NAME,
G_TYPE_STRING,
G_VARIANT_TYPE_STRING,
NULL,
nm_setting_connection_set_interface_name,
nm_setting_connection_no_interface_name);
......
......@@ -20,13 +20,11 @@
*/
#include <string.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-dcb.h"
#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-setting-private.h"
/**
......@@ -777,23 +775,23 @@ set_gvalue_from_array (GValue *v, uint *a, size_t len)
#define SET_GVALUE_FROM_ARRAY(v, a) set_gvalue_from_array (v, a, G_N_ELEMENTS (a))
static void
_nm_setting_dcb_uint_array_to_dbus (const GValue *prop_value,
GValue *dbus_value)
static GVariant *
_nm_setting_dcb_uint_array_to_dbus (const GValue *prop_value)
{
GArray *src = g_value_get_boxed (prop_value);
set_gvalue_from_array (dbus_value, (guint *) src->data, src->len);
return g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, src->data, src->len, sizeof (guint32));
}
static void
_nm_setting_dcb_uint_array_from_dbus (const GValue *dbus_value,
_nm_setting_dcb_uint_array_from_dbus (GVariant *dbus_value,
GValue *prop_value)
{
GArray *src = g_value_get_boxed (dbus_value);
set_gvalue_from_array (prop_value, (guint *) src->data, src->len);
gconstpointer array;
gsize length;
array = g_variant_get_fixed_array (dbus_value, &length, sizeof (guint32));
set_gvalue_from_array (prop_value, (guint *) array, length);
}
static void
......@@ -1058,7 +1056,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL,
DBUS_TYPE_G_UINT_ARRAY,
G_VARIANT_TYPE ("au"),
_nm_setting_dcb_uint_array_to_dbus,
_nm_setting_dcb_uint_array_from_dbus);
......@@ -1092,7 +1090,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_GROUP_ID,
DBUS_TYPE_G_UINT_ARRAY,
G_VARIANT_TYPE ("au"),
_nm_setting_dcb_uint_array_to_dbus,
_nm_setting_dcb_uint_array_from_dbus);
......@@ -1113,7 +1111,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH,
DBUS_TYPE_G_UINT_ARRAY,
G_VARIANT_TYPE ("au"),
_nm_setting_dcb_uint_array_to_dbus,
_nm_setting_dcb_uint_array_from_dbus);
......@@ -1135,7 +1133,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_BANDWIDTH,
DBUS_TYPE_G_UINT_ARRAY,
G_VARIANT_TYPE ("au"),
_nm_setting_dcb_uint_array_to_dbus,
_nm_setting_dcb_uint_array_from_dbus);
......@@ -1155,7 +1153,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH,
DBUS_TYPE_G_UINT_ARRAY,
G_VARIANT_TYPE ("au"),
_nm_setting_dcb_uint_array_to_dbus,
_nm_setting_dcb_uint_array_from_dbus);
......@@ -1175,7 +1173,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS,
DBUS_TYPE_G_UINT_ARRAY,
G_VARIANT_TYPE ("au"),
_nm_setting_dcb_uint_array_to_dbus,
_nm_setting_dcb_uint_array_from_dbus);
}
......@@ -625,9 +625,9 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
/* Ignore incoming deprecated properties */
_nm_setting_class_add_dbus_only_property (parent_class, "allowed-bands",
G_TYPE_UINT,
G_VARIANT_TYPE_UINT32,
NULL, NULL);
_nm_setting_class_add_dbus_only_property (parent_class, "network-type",
G_TYPE_INT,
G_VARIANT_TYPE_INT32,
NULL, NULL);
}
......@@ -20,7 +20,6 @@
*/
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-infiniband.h"
......@@ -419,7 +418,7 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_transform_property (parent_class, NM_SETTING_INFINIBAND_MAC_ADDRESS,
DBUS_TYPE_G_UCHAR_ARRAY,
G_VARIANT_TYPE_BYTESTRING,
_nm_utils_hwaddr_to_dbus,
_nm_utils_hwaddr_from_dbus);
......
......@@ -21,12 +21,10 @@
*/
#include <string.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-ip4-config.h"
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"