mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-29 07:00:44 +02:00
merge: remove mostly-unused hostname provider functionality (bgo #727609)
This commit is contained in:
commit
66eb52b53d
8 changed files with 100 additions and 266 deletions
|
|
@ -220,8 +220,6 @@ nm_sources = \
|
|||
nm-dispatcher.h \
|
||||
nm-enum-types.c \
|
||||
nm-enum-types.h \
|
||||
nm-hostname-provider.c \
|
||||
nm-hostname-provider.h \
|
||||
nm-ip4-config.c \
|
||||
nm-ip4-config.h \
|
||||
nm-ip6-config.c \
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ typedef struct {
|
|||
guint32 mtu;
|
||||
|
||||
/* Generic DHCP stuff */
|
||||
NMDHCPManager * dhcp_manager;
|
||||
guint32 dhcp_timeout;
|
||||
GByteArray * dhcp_anycast_address;
|
||||
|
||||
|
|
@ -510,8 +509,6 @@ constructor (GType type,
|
|||
if (NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities)
|
||||
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
|
||||
|
||||
priv->dhcp_manager = nm_dhcp_manager_get ();
|
||||
|
||||
priv->fw_manager = nm_firewall_manager_get ();
|
||||
|
||||
device_get_driver_info (priv->iface, &priv->driver_version, &priv->firmware_version);
|
||||
|
|
@ -2779,7 +2776,7 @@ dhcp4_start (NMDevice *self,
|
|||
|
||||
/* Begin DHCP on the interface */
|
||||
g_warn_if_fail (priv->dhcp4_client == NULL);
|
||||
priv->dhcp4_client = nm_dhcp_manager_start_ip4 (priv->dhcp_manager,
|
||||
priv->dhcp4_client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (),
|
||||
nm_device_get_ip_iface (self),
|
||||
tmp,
|
||||
nm_connection_get_uuid (connection),
|
||||
|
|
@ -3219,7 +3216,7 @@ dhcp6_start (NMDevice *self,
|
|||
g_byte_array_append (tmp, priv->hw_addr, priv->hw_addr_len);
|
||||
}
|
||||
|
||||
priv->dhcp6_client = nm_dhcp_manager_start_ip6 (priv->dhcp_manager,
|
||||
priv->dhcp6_client = nm_dhcp_manager_start_ip6 (nm_dhcp_manager_get (),
|
||||
nm_device_get_ip_iface (self),
|
||||
tmp,
|
||||
nm_connection_get_uuid (connection),
|
||||
|
|
@ -5797,9 +5794,6 @@ finalize (GObject *object)
|
|||
NMDevice *self = NM_DEVICE (object);
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
if (priv->dhcp_manager)
|
||||
g_object_unref (priv->dhcp_manager);
|
||||
|
||||
if (priv->fw_manager)
|
||||
g_object_unref (priv->fw_manager);
|
||||
|
||||
|
|
@ -6950,7 +6944,6 @@ find_ip4_lease_config (NMDevice *device,
|
|||
NMConnection *connection,
|
||||
NMIP4Config *ext_ip4_config)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
||||
const char *ip_iface = nm_device_get_ip_iface (device);
|
||||
GSList *leases, *liter;
|
||||
NMIP4Config *found = NULL;
|
||||
|
|
@ -6958,7 +6951,7 @@ find_ip4_lease_config (NMDevice *device,
|
|||
g_return_val_if_fail (NM_IS_IP4_CONFIG (ext_ip4_config), NULL);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
leases = nm_dhcp_manager_get_lease_ip_configs (priv->dhcp_manager,
|
||||
leases = nm_dhcp_manager_get_lease_ip_configs (nm_dhcp_manager_get (),
|
||||
ip_iface,
|
||||
nm_connection_get_uuid (connection),
|
||||
FALSE);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
#include "nm-dhcp-dhcpcd.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-hostname-provider.h"
|
||||
#include "nm-config.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
|
@ -63,8 +62,6 @@ nm_dhcp_manager_error_quark (void)
|
|||
#define PRIV_SOCK_PATH NMRUNDIR "/private-dhcp"
|
||||
#define PRIV_SOCK_TAG "dhcp"
|
||||
|
||||
static NMDHCPManager *singleton = NULL;
|
||||
|
||||
/* default to installed helper, but can be modified for testing */
|
||||
const char *nm_dhcp_helper_path = LIBEXECDIR "/nm-dhcp-helper";
|
||||
|
||||
|
|
@ -81,7 +78,7 @@ typedef struct {
|
|||
|
||||
GHashTable * clients;
|
||||
DBusGProxy * proxy;
|
||||
NMHostnameProvider *hostname_provider;
|
||||
char * default_hostname;
|
||||
} NMDHCPManagerPrivate;
|
||||
|
||||
|
||||
|
|
@ -342,71 +339,6 @@ get_client_type (const char *client, GError **error)
|
|||
return G_TYPE_INVALID;
|
||||
}
|
||||
|
||||
NMDHCPManager *
|
||||
nm_dhcp_manager_get (void)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
const char *client;
|
||||
GError *error = NULL;
|
||||
#if !HAVE_DBUS_GLIB_100
|
||||
DBusGConnection *g_connection;
|
||||
#endif
|
||||
|
||||
if (singleton)
|
||||
return g_object_ref (singleton);
|
||||
|
||||
singleton = g_object_new (NM_TYPE_DHCP_MANAGER, NULL);
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE (singleton);
|
||||
|
||||
/* Client-specific setup */
|
||||
client = nm_config_get_dhcp_client (nm_config_get ());
|
||||
priv->client_type = get_client_type (client, &error);
|
||||
|
||||
if (priv->client_type == NM_TYPE_DHCP_DHCLIENT)
|
||||
priv->get_lease_ip_configs_func = nm_dhcp_dhclient_get_lease_ip_configs;
|
||||
else if (priv->client_type == G_TYPE_INVALID) {
|
||||
nm_log_warn (LOGD_DHCP, "No usable DHCP client found (%s)! DHCP configurations will fail.",
|
||||
error->message);
|
||||
}
|
||||
g_clear_error (&error);
|
||||
|
||||
priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
NULL,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
g_assert (priv->clients);
|
||||
|
||||
priv->dbus_mgr = nm_dbus_manager_get ();
|
||||
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
/* Register the socket our DHCP clients will return lease info on */
|
||||
nm_dbus_manager_private_server_register (priv->dbus_mgr, PRIV_SOCK_PATH, PRIV_SOCK_TAG);
|
||||
priv->new_conn_id = g_signal_connect (priv->dbus_mgr,
|
||||
NM_DBUS_MANAGER_PRIVATE_CONNECTION_NEW "::" PRIV_SOCK_TAG,
|
||||
(GCallback) new_connection_cb,
|
||||
singleton);
|
||||
priv->dis_conn_id = g_signal_connect (priv->dbus_mgr,
|
||||
NM_DBUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG,
|
||||
(GCallback) dis_connection_cb,
|
||||
singleton);
|
||||
#else
|
||||
g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
||||
priv->proxy = dbus_g_proxy_new_for_name (g_connection,
|
||||
"org.freedesktop.nm_dhcp_client",
|
||||
"/",
|
||||
NM_DHCP_CLIENT_DBUS_IFACE);
|
||||
g_assert (priv->proxy);
|
||||
dbus_g_proxy_add_signal (priv->proxy,
|
||||
"Event",
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT,
|
||||
G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal (priv->proxy, "Event",
|
||||
G_CALLBACK (nm_dhcp_manager_handle_event),
|
||||
singleton,
|
||||
NULL);
|
||||
#endif
|
||||
return singleton;
|
||||
}
|
||||
|
||||
#define REMOVE_ID_TAG "remove-id"
|
||||
#define TIMEOUT_ID_TAG "timeout-id"
|
||||
|
||||
|
|
@ -505,6 +437,15 @@ client_start (NMDHCPManager *self,
|
|||
return client;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_send_hostname (NMDHCPManager *self, const char *setting_hostname)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
/* Always prefer the explicit dhcp-send-hostname if given */
|
||||
return setting_hostname ? setting_hostname : priv->default_hostname;
|
||||
}
|
||||
|
||||
/* Caller owns a reference to the NMDHCPClient on return */
|
||||
NMDHCPClient *
|
||||
nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
|
||||
|
|
@ -515,36 +456,18 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
|
|||
guint32 timeout,
|
||||
GByteArray *dhcp_anycast_addr)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
const char *hostname, *method;
|
||||
const char *hostname = NULL, *method;
|
||||
gboolean send_hostname;
|
||||
|
||||
g_return_val_if_fail (self, NULL);
|
||||
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL);
|
||||
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
||||
g_return_val_if_fail (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, NULL);
|
||||
|
||||
send_hostname = nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4);
|
||||
if (send_hostname) {
|
||||
hostname = nm_setting_ip4_config_get_dhcp_hostname (s_ip4);
|
||||
|
||||
/* If we're supposed to send the hostname to the DHCP server but
|
||||
* the user didn't specify one, then use the hostname from the
|
||||
* hostname provider if there is one, otherwise use the persistent
|
||||
* hostname.
|
||||
*/
|
||||
if (!hostname && priv->hostname_provider) {
|
||||
hostname = nm_hostname_provider_get_hostname (priv->hostname_provider);
|
||||
if ( hostname
|
||||
&& (!strcmp (hostname, "localhost.localdomain") ||
|
||||
!strcmp (hostname, "localhost6.localdomain6")))
|
||||
hostname = NULL;
|
||||
}
|
||||
} else
|
||||
hostname = NULL;
|
||||
if (send_hostname)
|
||||
hostname = get_send_hostname (self, nm_setting_ip4_config_get_dhcp_hostname (s_ip4));
|
||||
|
||||
return client_start (self, iface, hwaddr, uuid, FALSE, nm_setting_ip4_config_get_dhcp_client_id (s_ip4), timeout, dhcp_anycast_addr, hostname, FALSE);
|
||||
}
|
||||
|
|
@ -560,50 +483,28 @@ nm_dhcp_manager_start_ip6 (NMDHCPManager *self,
|
|||
GByteArray *dhcp_anycast_addr,
|
||||
gboolean info_only)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
const char *hostname;
|
||||
|
||||
g_return_val_if_fail (self, NULL);
|
||||
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL);
|
||||
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
hostname = nm_setting_ip6_config_get_dhcp_hostname (s_ip6);
|
||||
if (!hostname && priv->hostname_provider) {
|
||||
hostname = nm_hostname_provider_get_hostname (priv->hostname_provider);
|
||||
if ( g_strcmp0 (hostname, "localhost.localdomain") == 0
|
||||
|| g_strcmp0 (hostname, "localhost6.localdomain6") == 0)
|
||||
hostname = NULL;
|
||||
}
|
||||
hostname = get_send_hostname (self, nm_setting_ip6_config_get_dhcp_hostname (s_ip6));
|
||||
|
||||
return client_start (self, iface, hwaddr, uuid, TRUE, NULL, timeout, dhcp_anycast_addr, hostname, info_only);
|
||||
}
|
||||
|
||||
static void
|
||||
hostname_provider_destroyed (gpointer data, GObject *destroyed_object)
|
||||
{
|
||||
NM_DHCP_MANAGER_GET_PRIVATE (data)->hostname_provider = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
nm_dhcp_manager_set_hostname_provider (NMDHCPManager *manager,
|
||||
NMHostnameProvider *provider)
|
||||
nm_dhcp_manager_set_default_hostname (NMDHCPManager *manager, const char *hostname)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
NMDHCPManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
|
||||
|
||||
g_return_if_fail (NM_IS_DHCP_MANAGER (manager));
|
||||
g_clear_pointer (&priv->default_hostname, g_free);
|
||||
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
|
||||
/* Never send 'localhost'-type names to the DHCP server */
|
||||
if (g_strcmp0 (hostname, "localhost.localdomain") == 0 ||
|
||||
g_strcmp0 (hostname, "localhost6.localdomain6") == 0)
|
||||
return;
|
||||
|
||||
if (priv->hostname_provider) {
|
||||
g_object_weak_unref (G_OBJECT (priv->hostname_provider), hostname_provider_destroyed, manager);
|
||||
priv->hostname_provider = NULL;
|
||||
}
|
||||
|
||||
if (provider) {
|
||||
priv->hostname_provider = provider;
|
||||
g_object_weak_ref (G_OBJECT (provider), hostname_provider_destroyed, manager);
|
||||
}
|
||||
priv->default_hostname = g_strdup (hostname);
|
||||
}
|
||||
|
||||
GSList *
|
||||
|
|
@ -656,13 +557,73 @@ nm_dhcp_manager_test_ip4_options_to_config (const char *dhcp_client,
|
|||
|
||||
/***************************************************/
|
||||
|
||||
static void
|
||||
nm_dhcp_manager_init (NMDHCPManager *manager)
|
||||
NMDHCPManager *
|
||||
nm_dhcp_manager_get (void)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (manager);
|
||||
static NMDHCPManager *singleton = NULL;
|
||||
|
||||
if (G_UNLIKELY (singleton == NULL))
|
||||
singleton = g_object_new (NM_TYPE_DHCP_MANAGER, NULL);
|
||||
g_assert (singleton);
|
||||
return singleton;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_dhcp_manager_init (NMDHCPManager *self)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
|
||||
const char *client;
|
||||
GError *error = NULL;
|
||||
#if !HAVE_DBUS_GLIB_100
|
||||
DBusGConnection *g_connection;
|
||||
#endif
|
||||
|
||||
/* Maps DBusGConnection :: DBusGProxy */
|
||||
priv->proxies = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
|
||||
|
||||
/* Client-specific setup */
|
||||
client = nm_config_get_dhcp_client (nm_config_get ());
|
||||
priv->client_type = get_client_type (client, &error);
|
||||
|
||||
if (priv->client_type == NM_TYPE_DHCP_DHCLIENT)
|
||||
priv->get_lease_ip_configs_func = nm_dhcp_dhclient_get_lease_ip_configs;
|
||||
else if (priv->client_type == G_TYPE_INVALID) {
|
||||
nm_log_warn (LOGD_DHCP, "No usable DHCP client found (%s)! DHCP configurations will fail.",
|
||||
error->message);
|
||||
}
|
||||
g_clear_error (&error);
|
||||
|
||||
priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
NULL,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
g_assert (priv->clients);
|
||||
|
||||
priv->dbus_mgr = nm_dbus_manager_get ();
|
||||
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
/* Register the socket our DHCP clients will return lease info on */
|
||||
nm_dbus_manager_private_server_register (priv->dbus_mgr, PRIV_SOCK_PATH, PRIV_SOCK_TAG);
|
||||
priv->new_conn_id = g_signal_connect (priv->dbus_mgr,
|
||||
NM_DBUS_MANAGER_PRIVATE_CONNECTION_NEW "::" PRIV_SOCK_TAG,
|
||||
(GCallback) new_connection_cb,
|
||||
self);
|
||||
priv->dis_conn_id = g_signal_connect (priv->dbus_mgr,
|
||||
NM_DBUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG,
|
||||
(GCallback) dis_connection_cb,
|
||||
self);
|
||||
#else
|
||||
g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
||||
priv->proxy = dbus_g_proxy_new_for_name (g_connection,
|
||||
"org.freedesktop.nm_dhcp_client",
|
||||
"/",
|
||||
NM_DHCP_CLIENT_DBUS_IFACE);
|
||||
g_assert (priv->proxy);
|
||||
dbus_g_proxy_add_signal (priv->proxy, "Event", DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal (priv->proxy, "Event",
|
||||
G_CALLBACK (nm_dhcp_manager_handle_event),
|
||||
self,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -703,10 +664,7 @@ finalize (GObject *object)
|
|||
{
|
||||
NMDHCPManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE (object);
|
||||
|
||||
if (priv->hostname_provider) {
|
||||
g_object_weak_unref (G_OBJECT (priv->hostname_provider), hostname_provider_destroyed, object);
|
||||
priv->hostname_provider = NULL;
|
||||
}
|
||||
g_free (priv->default_hostname);
|
||||
|
||||
if (priv->clients)
|
||||
g_hash_table_destroy (priv->clients);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
#include "nm-dhcp-client.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include "nm-dhcp4-config.h"
|
||||
#include "nm-hostname-provider.h"
|
||||
|
||||
typedef enum {
|
||||
NM_DHCP_MANAGER_ERROR_BAD_CLIENT = 0, /*< nick=BadClient >*/
|
||||
|
|
@ -60,10 +59,10 @@ typedef struct {
|
|||
|
||||
GType nm_dhcp_manager_get_type (void);
|
||||
|
||||
NMDHCPManager *nm_dhcp_manager_get (void);
|
||||
NMDHCPManager *nm_dhcp_manager_get (void);
|
||||
|
||||
void nm_dhcp_manager_set_hostname_provider(NMDHCPManager *manager,
|
||||
NMHostnameProvider *provider);
|
||||
void nm_dhcp_manager_set_default_hostname (NMDHCPManager *manager,
|
||||
const char *hostname);
|
||||
|
||||
NMDHCPClient * nm_dhcp_manager_start_ip4 (NMDHCPManager *manager,
|
||||
const char *iface,
|
||||
|
|
|
|||
10
src/main.c
10
src/main.c
|
|
@ -49,7 +49,6 @@
|
|||
#include "nm-supplicant-manager.h"
|
||||
#include "nm-dhcp-manager.h"
|
||||
#include "nm-firewall-manager.h"
|
||||
#include "nm-hostname-provider.h"
|
||||
#include "nm-vpn-manager.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-config.h"
|
||||
|
|
@ -598,6 +597,10 @@ main (int argc, char *argv[])
|
|||
dns_mgr = nm_dns_manager_get ();
|
||||
g_assert (dns_mgr != NULL);
|
||||
|
||||
/* Initialize DHCP manager */
|
||||
dhcp_mgr = nm_dhcp_manager_get ();
|
||||
g_assert (dhcp_mgr != NULL);
|
||||
|
||||
settings = nm_settings_new (&error);
|
||||
if (!settings) {
|
||||
nm_log_err (LOGD_CORE, "failed to initialize settings storage: %s",
|
||||
|
|
@ -622,11 +625,6 @@ main (int argc, char *argv[])
|
|||
sup_mgr = nm_supplicant_manager_get ();
|
||||
g_assert (sup_mgr != NULL);
|
||||
|
||||
/* Initialize DHCP manager */
|
||||
dhcp_mgr = nm_dhcp_manager_get ();
|
||||
g_assert (dhcp_mgr != NULL);
|
||||
nm_dhcp_manager_set_hostname_provider (dhcp_mgr, NM_HOSTNAME_PROVIDER (manager));
|
||||
|
||||
/* Initialize Firewall manager */
|
||||
fw_mgr = nm_firewall_manager_get ();
|
||||
g_assert (fw_mgr != NULL);
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2009 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-hostname-provider.h"
|
||||
|
||||
const char *
|
||||
nm_hostname_provider_get_hostname (NMHostnameProvider *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_HOSTNAME_PROVIDER (self), NULL);
|
||||
|
||||
return NM_HOSTNAME_PROVIDER_GET_INTERFACE (self)->get_hostname (self);
|
||||
}
|
||||
|
||||
GType
|
||||
nm_hostname_provider_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (!G_UNLIKELY (type)) {
|
||||
const GTypeInfo type_info = {
|
||||
sizeof (NMHostnameProvider), /* class_size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0,
|
||||
0, /* n_preallocs */
|
||||
NULL
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_INTERFACE, "NMHostnameProvider", &type_info, 0);
|
||||
g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2009 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_HOSTNAME_PROVIDER_H
|
||||
#define NM_HOSTNAME_PROVIDER_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#define NM_TYPE_HOSTNAME_PROVIDER (nm_hostname_provider_get_type ())
|
||||
#define NM_HOSTNAME_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_HOSTNAME_PROVIDER, NMHostnameProvider))
|
||||
#define NM_IS_HOSTNAME_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_HOSTNAME_PROVIDER))
|
||||
#define NM_HOSTNAME_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_HOSTNAME_PROVIDER, NMHostnameProvider))
|
||||
|
||||
typedef struct _NMHostnameProvider NMHostnameProvider;
|
||||
|
||||
struct _NMHostnameProvider {
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Methods */
|
||||
const char *(*get_hostname) (NMHostnameProvider *self);
|
||||
};
|
||||
|
||||
GType nm_hostname_provider_get_type (void);
|
||||
|
||||
const char *nm_hostname_provider_get_hostname (NMHostnameProvider *self);
|
||||
|
||||
#endif /* NM_HOSTNAME_PROVIDER_H */
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-rfkill-manager.h"
|
||||
#include "nm-hostname-provider.h"
|
||||
#include "nm-dhcp-manager.h"
|
||||
#include "nm-settings.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-manager-auth.h"
|
||||
|
|
@ -133,8 +133,6 @@ static void impl_manager_check_connectivity (NMManager *manager,
|
|||
static void add_device (NMManager *self, NMDevice *device, gboolean generate_con);
|
||||
static void remove_device (NMManager *self, NMDevice *device, gboolean quitting);
|
||||
|
||||
static void hostname_provider_init (NMHostnameProvider *provider_class);
|
||||
|
||||
static NMActiveConnection *_new_active_connection (NMManager *self,
|
||||
NMConnection *connection,
|
||||
const char *specific_object,
|
||||
|
|
@ -221,9 +219,7 @@ typedef struct {
|
|||
|
||||
#define NM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MANAGER, NMManagerPrivate))
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (NMManager, nm_manager, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (NM_TYPE_HOSTNAME_PROVIDER,
|
||||
hostname_provider_init))
|
||||
G_DEFINE_TYPE (NMManager, nm_manager, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
DEVICE_ADDED,
|
||||
|
|
@ -810,18 +806,6 @@ aipd_handle_event (DBusGProxy *proxy,
|
|||
nm_log_warn (LOGD_AUTOIP4, "(%s): unhandled avahi-autoipd event", iface);
|
||||
}
|
||||
|
||||
static const char *
|
||||
hostname_provider_get_hostname (NMHostnameProvider *provider)
|
||||
{
|
||||
return NM_MANAGER_GET_PRIVATE (provider)->hostname;
|
||||
}
|
||||
|
||||
static void
|
||||
hostname_provider_init (NMHostnameProvider *provider_class)
|
||||
{
|
||||
provider_class->get_hostname = hostname_provider_get_hostname;
|
||||
}
|
||||
|
||||
NMState
|
||||
nm_manager_get_state (NMManager *manager)
|
||||
{
|
||||
|
|
@ -1219,6 +1203,8 @@ system_hostname_changed_cb (NMSettings *settings,
|
|||
priv->hostname = (hostname && strlen (hostname)) ? g_strdup (hostname) : NULL;
|
||||
g_object_notify (G_OBJECT (self), NM_MANAGER_HOSTNAME);
|
||||
|
||||
nm_dhcp_manager_set_default_hostname (nm_dhcp_manager_get (), priv->hostname);
|
||||
|
||||
g_free (hostname);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue