about summary refs log tree commit diff
path: root/libnm/nm-dns-manager.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2019-12-18 18:29:24 +0100
committerMichael Biebl <biebl@debian.org>2019-12-18 18:29:24 +0100
commit28028b26b3371756811e95d894f709f4b1207c00 (patch)
tree6fe7316fd743b51042db47601a8ef8814b3134ac /libnm/nm-dns-manager.c
parente22609983008e1a669196ad64ba3a59ae8c76e0d (diff)
New upstream version 1.22.0 upstream/1.22.0
Diffstat (limited to 'libnm/nm-dns-manager.c')
-rw-r--r--libnm/nm-dns-manager.c233
1 files changed, 2 insertions, 231 deletions
diff --git a/libnm/nm-dns-manager.c b/libnm/nm-dns-manager.c
index 3b2ed90c..9fe759d3 100644
--- a/libnm/nm-dns-manager.c
+++ b/libnm/nm-dns-manager.c
@@ -1,20 +1,6 @@
+// SPDX-License-Identifier: LGPL-2.1+
 /*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2016 Red Hat, Inc.
+ * Copyright (C) 2016 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -28,28 +14,6 @@
 #include "nm-dbus-helpers.h"
 #include "nm-core-internal.h"
 
-#include "introspection/org.freedesktop.NetworkManager.DnsManager.h"
-
-G_DEFINE_TYPE (NMDnsManager, nm_dns_manager, NM_TYPE_OBJECT)
-
-#define NM_DNS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DNS_MANAGER, NMDnsManagerPrivate))
-
-typedef struct {
-	NMDBusDnsManager *proxy;
-	char *mode;
-	char *rc_manager;
-	GPtrArray *configuration;
-} NMDnsManagerPrivate;
-
-enum {
-	PROP_0,
-	PROP_MODE,
-	PROP_RC_MANAGER,
-	PROP_CONFIGURATION,
-
-	LAST_PROP
-};
-
 /*****************************************************************************
  * NMDnsEntry
  *****************************************************************************/
@@ -251,196 +215,3 @@ nm_dns_entry_get_priority (NMDnsEntry *entry)
 
 	return entry->priority;
 }
-
-/*****************************************************************************/
-
-static gboolean
-demarshal_dns_configuration (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
-{
-	NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (object);
-	GVariant *entry_var;
-	GVariantIter iter, *iterp;
-	NMDnsEntry *entry;
-	GPtrArray *array;
-
-	g_return_val_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE ("aa{sv}")), FALSE);
-
-	g_variant_iter_init (&iter, value);
-	g_ptr_array_unref (priv->configuration);
-	priv->configuration = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_dns_entry_unref);
-
-	while (g_variant_iter_next (&iter, "@a{sv}", &entry_var)) {
-		char **nameservers = NULL, **domains = NULL;
-		gboolean vpn = FALSE;
-		char *interface = NULL, *str;
-		int priority;
-
-		if (   !g_variant_lookup (entry_var, "nameservers", "as", &iterp)
-		    || !g_variant_lookup (entry_var, "priority", "i", &priority)) {
-			g_warning ("Ignoring invalid DNS configuration");
-			g_variant_unref (entry_var);
-			continue;
-		}
-
-		array = g_ptr_array_new ();
-		while (g_variant_iter_next (iterp, "&s", &str))
-			g_ptr_array_add (array, str);
-		g_ptr_array_add (array, NULL);
-		nameservers = (char **) g_ptr_array_free (array, FALSE);
-		g_variant_iter_free (iterp);
-
-		if (g_variant_lookup (entry_var, "domains", "as", &iterp)) {
-			array = g_ptr_array_new ();
-			while (g_variant_iter_next (iterp, "&s", &str))
-				g_ptr_array_add (array, str);
-			g_ptr_array_add (array, NULL);
-			domains = (char **) g_ptr_array_free (array, FALSE);
-			g_variant_iter_free (iterp);
-		}
-
-		g_variant_lookup (entry_var, "interface", "&s", &interface);
-		g_variant_lookup (entry_var, "priority", "i", &priority);
-		g_variant_lookup (entry_var, "vpn", "b", &vpn);
-
-		entry = nm_dns_entry_new (interface,
-		                          (const char * const *) nameservers,
-		                          (const char * const *) domains,
-		                          priority,
-		                          vpn);
-		g_free (domains);
-		g_free (nameservers);
-		g_variant_unref (entry_var);
-		if (!entry) {
-			g_warning ("Ignoring invalid DNS entry");
-			continue;
-		}
-
-		g_ptr_array_add (priv->configuration, entry);
-	}
-
-	_nm_object_queue_notify (object, NM_DNS_MANAGER_CONFIGURATION);
-
-	return TRUE;
-}
-
-/*****************************************************************************/
-const char *
-nm_dns_manager_get_mode (NMDnsManager *manager)
-{
-	return NM_DNS_MANAGER_GET_PRIVATE (manager)->mode;
-}
-
-const char *
-nm_dns_manager_get_rc_manager (NMDnsManager *manager)
-{
-	return NM_DNS_MANAGER_GET_PRIVATE (manager)->rc_manager;
-}
-
-const GPtrArray *
-nm_dns_manager_get_configuration (NMDnsManager *manager)
-{
-	return NM_DNS_MANAGER_GET_PRIVATE (manager)->configuration;
-}
-/*****************************************************************************/
-
-static void
-nm_dns_manager_init (NMDnsManager *self)
-{
-	NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self);
-
-	priv->configuration = g_ptr_array_new ();
-}
-
-static void
-init_dbus (NMObject *object)
-{
-	NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (object);
-	const NMPropertiesInfo property_info[] = {
-		{ NM_DNS_MANAGER_MODE,          &priv->mode },
-		{ NM_DNS_MANAGER_RC_MANAGER,    &priv->rc_manager },
-		{ NM_DNS_MANAGER_CONFIGURATION, &priv->configuration, demarshal_dns_configuration },
-		{ NULL },
-	};
-
-	NM_OBJECT_CLASS (nm_dns_manager_parent_class)->init_dbus (object);
-
-	priv->proxy = NMDBUS_DNS_MANAGER (_nm_object_get_proxy (object, NM_DBUS_INTERFACE_DNS_MANAGER));
-	_nm_object_register_properties (object,
-	                                NM_DBUS_INTERFACE_DNS_MANAGER,
-	                                property_info);
-}
-
-static void
-dispose (GObject *object)
-{
-	NMDnsManager *self = NM_DNS_MANAGER (object);
-	NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self);
-
-	g_clear_pointer (&priv->mode, g_free);
-	g_clear_pointer (&priv->rc_manager, g_free);
-	g_clear_pointer (&priv->configuration, g_ptr_array_unref);
-
-	G_OBJECT_CLASS (nm_dns_manager_parent_class)->dispose (object);
-}
-
-static void
-get_property (GObject *object, guint prop_id,
-              GValue *value, GParamSpec *pspec)
-{
-	NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (object);
-
-	switch (prop_id) {
-	case PROP_MODE:
-		g_value_set_string (value, priv->mode);
-		break;
-	case PROP_RC_MANAGER:
-		g_value_set_string (value, priv->rc_manager);
-		break;
-	case PROP_CONFIGURATION:
-		g_value_take_boxed (value, _nm_utils_copy_array (priv->configuration,
-		                                                 (NMUtilsCopyFunc) nm_dns_entry_dup,
-		                                                 (GDestroyNotify) nm_dns_entry_unref));
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-		break;
-	}
-}
-
-static void
-nm_dns_manager_class_init (NMDnsManagerClass *class)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS (class);
-	NMObjectClass *nm_object_class = NM_OBJECT_CLASS (class);
-
-	g_type_class_add_private (class, sizeof (NMDnsManagerPrivate));
-
-	/* Virtual methods */
-	object_class->get_property = get_property;
-	object_class->dispose = dispose;
-
-	nm_object_class->init_dbus = init_dbus;
-
-	/* Properties */
-
-	g_object_class_install_property
-		(object_class, PROP_MODE,
-		 g_param_spec_string (NM_DNS_MANAGER_MODE, "", "",
-		                      NULL,
-		                      G_PARAM_READABLE |
-		                      G_PARAM_STATIC_STRINGS));
-
-	g_object_class_install_property
-		(object_class, PROP_RC_MANAGER,
-		 g_param_spec_string (NM_DNS_MANAGER_RC_MANAGER, "", "",
-		                      NULL,
-		                      G_PARAM_READABLE |
-		                      G_PARAM_STATIC_STRINGS));
-
-	g_object_class_install_property
-		(object_class, PROP_CONFIGURATION,
-		 g_param_spec_boxed (NM_DNS_MANAGER_CONFIGURATION, "", "",
-		                     G_TYPE_PTR_ARRAY,
-		                     G_PARAM_READABLE |
-		                     G_PARAM_STATIC_STRINGS));
-}