mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 18:10:08 +01:00
dns: drop get_name() and is_caching() virtual functions for klass variables
The plugin name and whether a plugin is caching only depends on the type, it does not require a virtual function where types would decided depending on other reasons. Convert the virtual functions into fields of the class.
This commit is contained in:
parent
5bf2112056
commit
807fd682fb
5 changed files with 29 additions and 76 deletions
|
|
@ -425,20 +425,6 @@ child_quit (NMDnsPlugin *plugin, int status)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
is_caching (NMDnsPlugin *plugin)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_name (NMDnsPlugin *plugin)
|
||||
{
|
||||
return "dnsmasq";
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_dns_dnsmasq_init (NMDnsDnsmasq *self)
|
||||
{
|
||||
|
|
@ -473,8 +459,8 @@ nm_dns_dnsmasq_class_init (NMDnsDnsmasqClass *dns_class)
|
|||
|
||||
object_class->dispose = dispose;
|
||||
|
||||
plugin_class->child_quit = child_quit;
|
||||
plugin_class->is_caching = is_caching;
|
||||
plugin_class->update = update;
|
||||
plugin_class->get_name = get_name;
|
||||
plugin_class->plugin_name = "dnsmasq";
|
||||
plugin_class->is_caching = TRUE;
|
||||
plugin_class->child_quit = child_quit;
|
||||
plugin_class->update = update;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,23 +74,22 @@ nm_dns_plugin_update (NMDnsPlugin *self,
|
|||
hostname);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_caching (NMDnsPlugin *self)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dns_plugin_is_caching (NMDnsPlugin *self)
|
||||
{
|
||||
return NM_DNS_PLUGIN_GET_CLASS (self)->is_caching (self);
|
||||
return NM_DNS_PLUGIN_GET_CLASS (self)->is_caching;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_dns_plugin_get_name (NMDnsPlugin *self)
|
||||
{
|
||||
g_assert (NM_DNS_PLUGIN_GET_CLASS (self)->get_name);
|
||||
return NM_DNS_PLUGIN_GET_CLASS (self)->get_name (self);
|
||||
NMDnsPluginClass *klass;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DNS_PLUGIN (self), NULL);
|
||||
|
||||
klass = NM_DNS_PLUGIN_GET_CLASS (self);
|
||||
nm_assert (klass->plugin_name);
|
||||
return klass->plugin_name;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -275,8 +274,6 @@ nm_dns_plugin_class_init (NMDnsPluginClass *plugin_class)
|
|||
|
||||
object_class->dispose = dispose;
|
||||
|
||||
plugin_class->is_caching = is_caching;
|
||||
|
||||
/* Emitted by the plugin and consumed by NMDnsManager when
|
||||
* some error happens with the nameserver subprocess. Causes NM to fall
|
||||
* back to writing out a non-local-caching resolv.conf until the next
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
/* Copyright (C) 2010 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_DNS_PLUGIN_H__
|
||||
#define __NETWORKMANAGER_DNS_PLUGIN_H__
|
||||
#ifndef __NM_DNS_PLUGIN_H__
|
||||
#define __NM_DNS_PLUGIN_H__
|
||||
|
||||
#include "nm-dns-manager.h"
|
||||
#include "nm-config-data.h"
|
||||
|
|
@ -28,8 +28,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
GObjectClass parent;
|
||||
|
||||
/* Methods */
|
||||
|
||||
/* Called when DNS information is changed. 'configs' is an array
|
||||
* of pointers to NMDnsIPConfigData sorted by priority.
|
||||
* 'global_config' is the optional global DNS
|
||||
|
|
@ -40,16 +38,7 @@ typedef struct {
|
|||
const CList *ip_config_lst_head,
|
||||
const char *hostname);
|
||||
|
||||
/* Subclasses should override and return TRUE if they start a local
|
||||
* caching nameserver that listens on localhost and would block any
|
||||
* other local caching nameserver from operating.
|
||||
*/
|
||||
gboolean (*is_caching) (NMDnsPlugin *self);
|
||||
|
||||
/* Subclasses should override this and return their plugin name */
|
||||
const char *(*get_name) (NMDnsPlugin *self);
|
||||
|
||||
/* Signals */
|
||||
const char *plugin_name;
|
||||
|
||||
/* Emitted by the plugin base class when the nameserver subprocess
|
||||
* quits. This signal is consumed by the plugin subclasses and not
|
||||
|
|
@ -57,6 +46,13 @@ typedef struct {
|
|||
* by waitpid(2)) is fatal it should then emit the 'failed' signal.
|
||||
*/
|
||||
void (*child_quit) (NMDnsPlugin *self, int status);
|
||||
|
||||
/* Types should set to TRUE if they start a local caching nameserver
|
||||
* that listens on localhost and would block any other local caching
|
||||
* nameserver from operating.
|
||||
*/
|
||||
bool is_caching:1;
|
||||
|
||||
} NMDnsPluginClass;
|
||||
|
||||
GType nm_dns_plugin_get_type (void);
|
||||
|
|
@ -89,4 +85,4 @@ GPid nm_dns_plugin_child_pid (NMDnsPlugin *self);
|
|||
|
||||
gboolean nm_dns_plugin_child_kill (NMDnsPlugin *self);
|
||||
|
||||
#endif /* __NETWORKMANAGER_DNS_PLUGIN_H__ */
|
||||
#endif /* __NM_DNS_PLUGIN_H__ */
|
||||
|
|
|
|||
|
|
@ -388,20 +388,6 @@ update (NMDnsPlugin *plugin,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
is_caching (NMDnsPlugin *plugin)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_name (NMDnsPlugin *plugin)
|
||||
{
|
||||
return "systemd-resolved";
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
name_owner_changed (NMDnsSystemdResolved *self,
|
||||
const char *owner)
|
||||
|
|
@ -553,7 +539,7 @@ nm_dns_systemd_resolved_class_init (NMDnsSystemdResolvedClass *dns_class)
|
|||
|
||||
object_class->dispose = dispose;
|
||||
|
||||
plugin_class->is_caching = is_caching;
|
||||
plugin_class->update = update;
|
||||
plugin_class->get_name = get_name;
|
||||
plugin_class->plugin_name = "systemd-resolved";
|
||||
plugin_class->is_caching = TRUE;
|
||||
plugin_class->update = update;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,18 +46,6 @@ update (NMDnsPlugin *plugin,
|
|||
return (status == 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_caching (NMDnsPlugin *plugin)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_name (NMDnsPlugin *plugin)
|
||||
{
|
||||
return "unbound";
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -76,7 +64,7 @@ nm_dns_unbound_class_init (NMDnsUnboundClass *klass)
|
|||
{
|
||||
NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (klass);
|
||||
|
||||
plugin_class->update = update;
|
||||
plugin_class->is_caching = is_caching;
|
||||
plugin_class->get_name = get_name;
|
||||
plugin_class->plugin_name = "unbound";
|
||||
plugin_class->is_caching = TRUE;
|
||||
plugin_class->update = update;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue