Commit 6c8f8608 authored by Dan Winship's avatar Dan Winship

core: port IP/DHCP config to gdbus

parent 7f6e39ec
......@@ -35,6 +35,10 @@
</tp:docstring>
</property>
<property name="Nameservers" type="aay" access="read">
<!-- gdbus-codegen assumes that "aay" means "array of non-UTF-8
string" and so would make this a char **.
-->
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="1"/>
<tp:docstring>The nameservers in use.</tp:docstring>
</property>
<property name="Domains" type="as" access="read">
......
......@@ -2991,3 +2991,24 @@ nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects)
}
g_value_take_boxed (value, paths);
}
/**
* nm_utils_g_value_set_strv:
* @value: a #GValue, initialized to store a #G_TYPE_STRV
* @strings: a #GPtrArray of strings
*
* Converts @strings to a #GStrv and stores it in @value.
*/
void
nm_utils_g_value_set_strv (GValue *value, GPtrArray *strings)
{
char **strv;
int i;
strv = g_new (char *, strings->len + 1);
for (i = 0; i < strings->len; i++)
strv[i] = g_strdup (strings->pdata[i]);
strv[i] = NULL;
g_value_take_boxed (value, strv);
}
......@@ -253,5 +253,6 @@ void _nm_utils_set_testing (NMUtilsTestFlags flags);
void nm_utils_g_value_set_object_path (GValue *value, gpointer object);
void nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects);
void nm_utils_g_value_set_strv (GValue *value, GPtrArray *strings);
#endif /* __NETWORKMANAGER_UTILS_H__ */
......@@ -25,10 +25,10 @@
#include "nm-default.h"
#include "nm-dbus-interface.h"
#include "nm-dhcp4-config.h"
#include "nm-dhcp4-config-glue.h"
#include "nm-dbus-glib-types.h"
#include "nm-utils.h"
#include "nmdbus-dhcp4-config.h"
G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_EXPORTED_OBJECT)
#define NM_DHCP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigPrivate))
......@@ -128,11 +128,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_OPTIONS:
/* dbus_g_value_parse_g_variant() will call g_value_init(), but
* @value is already inited.
*/
g_value_unset (value);
dbus_g_value_parse_g_variant (priv->options, value);
g_value_set_variant (value, priv->options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -157,11 +153,13 @@ nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class)
/* properties */
g_object_class_install_property
(object_class, PROP_OPTIONS,
g_param_spec_boxed (NM_DHCP4_CONFIG_OPTIONS, "", "",
DBUS_TYPE_G_MAP_OF_VARIANT,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_param_spec_variant (NM_DHCP4_CONFIG_OPTIONS, "", "",
G_VARIANT_TYPE ("a{sv}"),
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
&dbus_glib_nm_dhcp4_config_object_info);
NMDBUS_TYPE_DHCP4_CONFIG_SKELETON,
NULL);
}
......@@ -25,10 +25,10 @@
#include "nm-default.h"
#include "nm-dbus-interface.h"
#include "nm-dhcp6-config.h"
#include "nm-dhcp6-config-glue.h"
#include "nm-dbus-glib-types.h"
#include "nm-utils.h"
#include "nmdbus-dhcp6-config.h"
G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_EXPORTED_OBJECT)
#define NM_DHCP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigPrivate))
......@@ -128,11 +128,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_OPTIONS:
/* dbus_g_value_parse_g_variant() will call g_value_init(), but
* @value is already inited.
*/
g_value_unset (value);
dbus_g_value_parse_g_variant (priv->options, value);
g_value_set_variant (value, priv->options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -157,11 +153,13 @@ nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class)
/* properties */
g_object_class_install_property
(object_class, PROP_OPTIONS,
g_param_spec_boxed (NM_DHCP6_CONFIG_OPTIONS, "", "",
DBUS_TYPE_G_MAP_OF_VARIANT,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_param_spec_variant (NM_DHCP6_CONFIG_OPTIONS, "", "",
G_VARIANT_TYPE ("a{sv}"),
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
&dbus_glib_nm_dhcp6_config_object_info);
NMDBUS_TYPE_DHCP6_CONFIG_SKELETON,
NULL);
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment