const char * nm_dhcp6_config_get_dbus_path (NMDHCP6Config *self) { g_return_val_if_fail (NM_IS_DHCP6_CONFIG (self), NULL); return NM_DHCP6_CONFIG_GET_PRIVATE (self)->dbus_path; }
static GObject* constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params) { NMObject *object; DBusGConnection *connection; NMDHCP6ConfigPrivate *priv; object = (NMObject *) G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructor (type, n_construct_params, construct_params); if (!object) return NULL; priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); connection = nm_object_get_connection (object); priv->proxy = dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, nm_object_get_path (object), NM_DBUS_INTERFACE_DHCP6_CONFIG); register_for_property_changed (NM_DHCP6_CONFIG (object)); return G_OBJECT (object); }
void nm_dhcp6_config_reset (NMDHCP6Config *self) { g_return_if_fail (NM_IS_DHCP6_CONFIG (self)); g_hash_table_remove_all (NM_DHCP6_CONFIG_GET_PRIVATE (self)->options); g_object_notify (G_OBJECT (self), NM_DHCP6_CONFIG_OPTIONS); }
/** * nm_dhcp6_config_get_options: * @config: a #NMDHCP6Config * * Gets all the options contained in the configuration. * * Returns: (transfer none) (element-type utf8 GObject.Value): the #GHashTable containing strings for keys and values. * This is the internal copy used by the configuration, and must not be modified. **/ GHashTable * nm_dhcp6_config_get_options (NMDHCP6Config *config) { g_return_val_if_fail (NM_IS_DHCP6_CONFIG (config), NULL); _nm_object_ensure_inited (NM_OBJECT (config)); return NM_DHCP6_CONFIG_GET_PRIVATE (config)->options; }
static void finalize (GObject *object) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); g_free (priv->dbus_path); g_hash_table_destroy (priv->options); G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->finalize (object); }
static void nm_dhcp6_config_init (NMDHCP6Config *self) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (self); static guint32 counter = 0; priv->dbus_path = g_strdup_printf (NM_DBUS_PATH "/DHCP6Config/%d", counter++); nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->dbus_path, self); priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy); }
const char * nm_dhcp6_config_get_option (NMDHCP6Config *self, const char *key) { GValue *value; g_return_val_if_fail (NM_IS_DHCP6_CONFIG (self), NULL); g_return_val_if_fail (key != NULL, NULL); value = g_hash_table_lookup (NM_DHCP6_CONFIG_GET_PRIVATE (self)->options, key); return value ? g_value_get_string (value) : NULL; }
static void constructed (GObject *object) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructed (object); priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DHCP6_CONFIG); register_properties (NM_DHCP6_CONFIG (object)); }
static void register_properties (NMDHCP6Config *config) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (config); const NMPropertiesInfo property_info[] = { { NM_DHCP6_CONFIG_OPTIONS, &priv->options, demarshal_dhcp6_options }, { NULL }, }; _nm_object_register_properties (NM_OBJECT (config), priv->proxy, property_info); }
static gboolean demarshal_dhcp6_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); GHashTable *new_options; g_hash_table_remove_all (priv->options); new_options = g_value_get_boxed (value); if (new_options) g_hash_table_foreach (new_options, copy_options, priv->options); _nm_object_queue_notify (object, NM_DHCP6_CONFIG_OPTIONS); return TRUE; }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); switch (prop_id) { case PROP_OPTIONS: g_value_set_boxed (value, priv->options); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/* Caller owns the list, but not the values in the list */ GSList * nm_dhcp6_config_list_options (NMDHCP6Config *self) { GHashTableIter iter; const char *option = NULL; GSList *list = NULL; g_return_val_if_fail (NM_IS_DHCP6_CONFIG (self), NULL); g_hash_table_iter_init (&iter, NM_DHCP6_CONFIG_GET_PRIVATE (self)->options); while (g_hash_table_iter_next (&iter, (gpointer) &option, NULL)) list = g_slist_prepend (list, (gpointer) option); return list; }
static void nm_dhcp6_config_init (NMDHCP6Config *self) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (self); static guint32 counter = 0; DBusGConnection *connection; NMDBusManager *dbus_mgr; dbus_mgr = nm_dbus_manager_get (); connection = nm_dbus_manager_get_connection (dbus_mgr); priv->dbus_path = g_strdup_printf (NM_DBUS_PATH "/DHCP6Config/%d", counter++); dbus_g_connection_register_g_object (connection, priv->dbus_path, G_OBJECT (self)); g_object_unref (dbus_mgr); priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy); }
void nm_dhcp6_config_add_option (NMDHCP6Config *self, const char *key, const char *option) { GValue *svalue; g_return_if_fail (NM_IS_DHCP6_CONFIG (self)); g_return_if_fail (key != NULL); g_return_if_fail (option != NULL); svalue = g_slice_new0 (GValue); g_value_init (svalue, G_TYPE_STRING); g_value_set_string (svalue, option); g_hash_table_insert (NM_DHCP6_CONFIG_GET_PRIVATE (self)->options, g_strdup (key), svalue); g_object_notify (G_OBJECT (self), NM_DHCP6_CONFIG_OPTIONS); }
static void constructed (GObject *object) { DBusGConnection *connection; NMDHCP6ConfigPrivate *priv; G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructed (object); priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); connection = nm_object_get_connection (NM_OBJECT (object)); priv->proxy = dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, nm_object_get_path (NM_OBJECT (object)), NM_DBUS_INTERFACE_DHCP6_CONFIG); register_properties (NM_DHCP6_CONFIG (object)); }
/** * nm_dhcp6_config_get_options: * @config: a #NMDHCP6Config * * Gets all the options contained in the configuration. * * Returns: the #GHashTable containing strings for keys and values. * This is the internal copy used by the configuration, and must not be modified. **/ GHashTable * nm_dhcp6_config_get_options (NMDHCP6Config *config) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (config); GValue value = { 0, }; if (g_hash_table_size (priv->options)) return priv->options; if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_DHCP6_CONFIG, "Options", &value)) goto out; demarshal_dhcp6_options (NM_OBJECT (config), NULL, &value, &priv->options); g_value_unset (&value); out: return priv->options; }
static gboolean demarshal_dhcp6_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); GHashTable *new_options; GHashTableIter iter; const char *key; GValue *opt; g_hash_table_remove_all (priv->options); new_options = g_value_get_boxed (value); if (new_options) { g_hash_table_iter_init (&iter, new_options); while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &opt)) g_hash_table_insert (priv->options, g_strdup (key), g_value_dup_string (opt)); } _nm_object_queue_notify (object, NM_DHCP6_CONFIG_OPTIONS); return TRUE; }