summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-08-24 13:37:06 +0200
committerThomas Haller <thaller@redhat.com>2018-09-06 07:41:22 +0200
commit657b0714b8e272129800e9fd406f9fcb150d7c1f (patch)
tree3eedfae50a33aa3478ad689a41f8e91efedf9c86
parent32442b2661305ae2b99177d516aec18450f2b6ed (diff)
settings: make NMSettingsPlugin a regular GObject instance and not an interface
NMSettingsPlugin was a glib interface, not a regular GObject instance. Accordingly, settings plugins would implement this interface instead of subclassing a parent type. Refactor the code, and make NMSettingsPlugin a GObject type. Plugins are now required to subclass this type. Glib interfaces are more cumbersome than helpful. At least, unless there is a good reason for using them. Our settings plugins are all internal API and are entirely under our control. It also means, this change is fine, as there are no implementations outside of this source tree. Using interfaces do would allow more flexibility in implementing the settings plugin. For example, the plugin would be able to derive from any other GObject type, like NMKimchiRefrigerator. But why would we even? Let's not add monster classes that implement house appliances beside NMSettingsPluginInterface. The settings plugin should have one purpose only: being a settings plugin. Hence, requiring it to subclass NMSettingsPlugin is more than resonable. We don't need interfaces for this. Now that NMSettingsPlugin is a regular object instance, it may also have state, and potentially could provide common functionality for the plugin implementation -- if that turns out to be useful. Arguably, an interface can have state too, for example by attaching the state somewhere else (like NMConnection does). But let's just say no. On a minor note, this also avoids some tiny overhead that comes with glib interfaces.
-rw-r--r--src/settings/nm-settings-plugin.c183
-rw-r--r--src/settings/nm-settings-plugin.h79
-rw-r--r--src/settings/plugins/ibft/nms-ibft-plugin.c25
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c59
-rw-r--r--src/settings/plugins/ifupdown/nms-ifupdown-plugin.c41
-rw-r--r--src/settings/plugins/keyfile/nms-keyfile-plugin.c42
6 files changed, 224 insertions, 205 deletions
diff --git a/src/settings/nm-settings-plugin.c b/src/settings/nm-settings-plugin.c
index 212311387b..e7275631dc 100644
--- a/src/settings/nm-settings-plugin.c
+++ b/src/settings/nm-settings-plugin.c
@@ -15,117 +15,94 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2007 - 2011 Red Hat, Inc.
+ * Copyright (C) 2007 - 2018 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
#include "nm-default.h"
#include "nm-settings-plugin.h"
+
#include "nm-settings-connection.h"
-G_DEFINE_INTERFACE (NMSettingsPlugin, nm_settings_plugin, G_TYPE_OBJECT)
+/*****************************************************************************/
-static void
-nm_settings_plugin_default_init (NMSettingsPluginInterface *g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Signals */
- g_signal_new (NM_SETTINGS_PLUGIN_CONNECTION_ADDED,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsPluginInterface, connection_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- NM_TYPE_SETTINGS_CONNECTION);
-
- g_signal_new (NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsPluginInterface, unmanaged_specs_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_signal_new (NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsPluginInterface, unrecognized_specs_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
-}
+enum {
+ CONNECTION_ADDED,
+ UNMANAGED_SPECS_CHANGED,
+ UNRECOGNIZED_SPECS_CHANGED,
+
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (NMSettingsPlugin, nm_settings_plugin, G_TYPE_OBJECT)
+
+/*****************************************************************************/
void
-nm_settings_plugin_initialize (NMSettingsPlugin *config)
+nm_settings_plugin_initialize (NMSettingsPlugin *self)
{
- g_return_if_fail (config != NULL);
+ g_return_if_fail (NM_IS_SETTINGS_PLUGIN (self));
- if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->initialize)
- NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->initialize (config);
+ if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->initialize)
+ NM_SETTINGS_PLUGIN_GET_CLASS (self)->initialize (self);
}
GSList *
-nm_settings_plugin_get_connections (NMSettingsPlugin *config)
+nm_settings_plugin_get_connections (NMSettingsPlugin *self)
{
- g_return_val_if_fail (config != NULL, NULL);
+ g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
- if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_connections)
- return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_connections (config);
+ if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_connections)
+ return NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_connections (self);
return NULL;
}
gboolean
-nm_settings_plugin_load_connection (NMSettingsPlugin *config,
+nm_settings_plugin_load_connection (NMSettingsPlugin *self,
const char *filename)
{
- g_return_val_if_fail (config != NULL, FALSE);
+ g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), FALSE);
- if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->load_connection)
- return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->load_connection (config, filename);
+ if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->load_connection)
+ return NM_SETTINGS_PLUGIN_GET_CLASS (self)->load_connection (self, filename);
return FALSE;
}
void
-nm_settings_plugin_reload_connections (NMSettingsPlugin *config)
+nm_settings_plugin_reload_connections (NMSettingsPlugin *self)
{
- g_return_if_fail (config != NULL);
+ g_return_if_fail (NM_IS_SETTINGS_PLUGIN (self));
- if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->reload_connections)
- NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->reload_connections (config);
+ if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->reload_connections)
+ NM_SETTINGS_PLUGIN_GET_CLASS (self)->reload_connections (self);
}
GSList *
-nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *config)
+nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *self)
{
- g_return_val_if_fail (config != NULL, NULL);
+ g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
- if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unmanaged_specs)
- return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unmanaged_specs (config);
+ if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_unmanaged_specs)
+ return NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_unmanaged_specs (self);
return NULL;
}
GSList *
-nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *config)
+nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *self)
{
- g_return_val_if_fail (config != NULL, NULL);
+ g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
- if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unrecognized_specs)
- return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unrecognized_specs (config);
+ if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_unrecognized_specs)
+ return NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_unrecognized_specs (self);
return NULL;
}
/**
* nm_settings_plugin_add_connection:
- * @config: the #NMSettingsPlugin
+ * @self: the #NMSettingsPlugin
* @connection: the source connection to create a plugin-specific
* #NMSettingsConnection from
* @save_to_disk: %TRUE to save the connection to disk immediately, %FALSE to
@@ -140,22 +117,88 @@ nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *config)
* Returns: the new #NMSettingsConnection or %NULL
*/
NMSettingsConnection *
-nm_settings_plugin_add_connection (NMSettingsPlugin *config,
+nm_settings_plugin_add_connection (NMSettingsPlugin *self,
NMConnection *connection,
gboolean save_to_disk,
GError **error)
{
- NMSettingsPluginInterface *config_interface;
+ NMSettingsPluginClass *klass;
- g_return_val_if_fail (config != NULL, NULL);
+ g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
- config_interface = NM_SETTINGS_PLUGIN_GET_INTERFACE (config);
- if (!config_interface->add_connection) {
+ klass = NM_SETTINGS_PLUGIN_GET_CLASS (self);
+ if (!klass->add_connection) {
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"Plugin does not support adding connections");
return NULL;
}
- return config_interface->add_connection (config, connection, save_to_disk, error);
+ return klass->add_connection (self, connection, save_to_disk, error);
+}
+
+/*****************************************************************************/
+
+void
+_nm_settings_plugin_emit_signal_connection_added (NMSettingsPlugin *self,
+ NMSettingsConnection *sett_conn)
+{
+ nm_assert (NM_IS_SETTINGS_PLUGIN (self));
+ nm_assert (NM_IS_SETTINGS_CONNECTION (sett_conn));
+
+ g_signal_emit (self, signals[CONNECTION_ADDED], 0, sett_conn);
+}
+
+void
+_nm_settings_plugin_emit_signal_unmanaged_specs_changed (NMSettingsPlugin *self)
+{
+ nm_assert (NM_IS_SETTINGS_PLUGIN (self));
+
+ g_signal_emit (self, signals[UNMANAGED_SPECS_CHANGED], 0);
+}
+
+void
+_nm_settings_plugin_emit_signal_unrecognized_specs_changed (NMSettingsPlugin *self)
+{
+ nm_assert (NM_IS_SETTINGS_PLUGIN (self));
+
+ g_signal_emit (self, signals[UNRECOGNIZED_SPECS_CHANGED], 0);
+}
+
+/*****************************************************************************/
+
+static void
+nm_settings_plugin_init (NMSettingsPlugin *self)
+{
+}
+
+static void
+nm_settings_plugin_class_init (NMSettingsPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ signals[CONNECTION_ADDED] =
+ g_signal_new (NM_SETTINGS_PLUGIN_CONNECTION_ADDED,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ NM_TYPE_SETTINGS_CONNECTION);
+
+ signals[UNMANAGED_SPECS_CHANGED] =
+ g_signal_new (NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[UNRECOGNIZED_SPECS_CHANGED] =
+ g_signal_new (NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
diff --git a/src/settings/nm-settings-plugin.h b/src/settings/nm-settings-plugin.h
index 933615cf20..cd56d6d15d 100644
--- a/src/settings/nm-settings-plugin.h
+++ b/src/settings/nm-settings-plugin.h
@@ -15,53 +15,52 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2007 - 2011 Red Hat, Inc.
+ * Copyright (C) 2007 - 2018 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
-#ifndef __NETWORKMANAGER_SETTINGS_PLUGIN_H__
-#define __NETWORKMANAGER_SETTINGS_PLUGIN_H__
+#ifndef __NM_SETTINGS_PLUGIN_H__
+#define __NM_SETTINGS_PLUGIN_H__
#include "nm-connection.h"
-/* Plugin's factory function that returns a GObject that implements
- * NMSettingsPlugin.
- */
-GObject * nm_settings_plugin_factory (void);
-
#define NM_TYPE_SETTINGS_PLUGIN (nm_settings_plugin_get_type ())
#define NM_SETTINGS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_PLUGIN, NMSettingsPlugin))
+#define NM_SETTINGS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTINGS_PLUGIN, NMSettingsPluginClass))
#define NM_IS_SETTINGS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_PLUGIN))
-#define NM_SETTINGS_PLUGIN_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_PLUGIN, NMSettingsPluginInterface))
+#define NM_IS_SETTINGS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTINGS_PLUGIN))
+#define NM_SETTINGS_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTINGS_PLUGIN, NMSettingsPluginClass))
-#define NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED "unmanaged-specs-changed"
+#define NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED "unmanaged-specs-changed"
#define NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED "unrecognized-specs-changed"
-#define NM_SETTINGS_PLUGIN_CONNECTION_ADDED "connection-added"
+#define NM_SETTINGS_PLUGIN_CONNECTION_ADDED "connection-added"
-typedef struct _NMSettingsPlugin NMSettingsPlugin;
+typedef struct {
+ GObject parent;
+} NMSettingsPlugin;
typedef struct {
- GTypeInterface g_iface;
+ GObjectClass parent;
/* Called when the plugin is loaded to initialize it */
- void (*initialize) (NMSettingsPlugin *config);
+ void (*initialize) (NMSettingsPlugin *plugin);
/* Returns a GSList of NMSettingsConnection objects that represent
* connections the plugin knows about. The returned list is freed by the
* system settings service.
*/
- GSList * (*get_connections) (NMSettingsPlugin *config);
+ GSList * (*get_connections) (NMSettingsPlugin *plugin);
/* Requests that the plugin load/reload a single connection, if it
* recognizes the filename. Returns success or failure.
*/
- gboolean (*load_connection) (NMSettingsPlugin *config,
+ gboolean (*load_connection) (NMSettingsPlugin *plugin,
const char *filename);
/* Requests that the plugin reload all connection files from disk,
* and emit signals reflecting new, changed, and removed connections.
*/
- void (*reload_connections) (NMSettingsPlugin *config);
+ void (*reload_connections) (NMSettingsPlugin *plugin);
/*
* Return a string list of specifications of devices which NetworkManager
@@ -72,7 +71,7 @@ typedef struct {
* Each string in the list must be in one of the formats recognized by
* nm_device_spec_match_list().
*/
- GSList * (*get_unmanaged_specs) (NMSettingsPlugin *config);
+ GSList * (*get_unmanaged_specs) (NMSettingsPlugin *plugin);
/*
* Return a string list of specifications of devices for which at least
@@ -84,7 +83,7 @@ typedef struct {
* Each string in the list must be in one of the formats recognized by
* nm_device_spec_match_list().
*/
- GSList * (*get_unrecognized_specs) (NMSettingsPlugin *config);
+ GSList * (*get_unrecognized_specs) (NMSettingsPlugin *plugin);
/*
* Initialize the plugin-specific connection and return a new
@@ -93,40 +92,40 @@ typedef struct {
* storage if @save_to_disk is TRUE. The returned object is owned by the
* plugin and must be referenced by the owner if necessary.
*/
- NMSettingsConnection * (*add_connection) (NMSettingsPlugin *config,
+ NMSettingsConnection * (*add_connection) (NMSettingsPlugin *plugin,
NMConnection *connection,
gboolean save_to_disk,
GError **error);
-
- /* Signals */
-
- /* Emitted when a new connection has been found by the plugin */
- void (*connection_added) (NMSettingsPlugin *config,
- NMSettingsConnection *connection);
-
- /* Emitted when the list of unmanaged device specifications changes */
- void (*unmanaged_specs_changed) (NMSettingsPlugin *config);
-
- /* Emitted when the list of devices with unrecognized connections changes */
- void (*unrecognized_specs_changed) (NMSettingsPlugin *config);
-} NMSettingsPluginInterface;
+} NMSettingsPluginClass;
GType nm_settings_plugin_get_type (void);
+/* Plugin's factory function that returns a #NMSettingsPlugin */
+NMSettingsPlugin *nm_settings_plugin_factory (void);
+
void nm_settings_plugin_initialize (NMSettingsPlugin *config);
-GSList *nm_settings_plugin_get_connections (NMSettingsPlugin *config);
+GSList *nm_settings_plugin_get_connections (NMSettingsPlugin *plugin);
-gboolean nm_settings_plugin_load_connection (NMSettingsPlugin *config,
+gboolean nm_settings_plugin_load_connection (NMSettingsPlugin *plugin,
const char *filename);
-void nm_settings_plugin_reload_connections (NMSettingsPlugin *config);
+void nm_settings_plugin_reload_connections (NMSettingsPlugin *plugin);
-GSList *nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *config);
-GSList *nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *config);
+GSList *nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *plugin);
+GSList *nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *plugin);
-NMSettingsConnection *nm_settings_plugin_add_connection (NMSettingsPlugin *config,
+NMSettingsConnection *nm_settings_plugin_add_connection (NMSettingsPlugin *plugin,
NMConnection *connection,
gboolean save_to_disk,
GError **error);
-#endif /* __NETWORKMANAGER_SETTINGS_PLUGIN_H__ */
+/* internal API */
+
+void _nm_settings_plugin_emit_signal_connection_added (NMSettingsPlugin *plugin,
+ NMSettingsConnection *sett_conn);
+
+void _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NMSettingsPlugin *plugin);
+
+void _nm_settings_plugin_emit_signal_unrecognized_specs_changed (NMSettingsPlugin *plugin);
+
+#endif /* __NM_SETTINGS_PLUGIN_H__ */
diff --git a/src/settings/plugins/ibft/nms-ibft-plugin.c b/src/settings/plugins/ibft/nms-ibft-plugin.c
index 906889800e..69dd3733e9 100644
--- a/src/settings/plugins/ibft/nms-ibft-plugin.c
+++ b/src/settings/plugins/ibft/nms-ibft-plugin.c
@@ -42,19 +42,15 @@ typedef struct {
} NMSIbftPluginPrivate;
struct _NMSIbftPlugin {
- GObject parent;
+ NMSettingsPlugin parent;
NMSIbftPluginPrivate _priv;
};
struct _NMSIbftPluginClass {
- GObjectClass parent;
+ NMSettingsPluginClass parent;
};
-static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface);
-
-G_DEFINE_TYPE_EXTENDED (NMSIbftPlugin, nms_ibft_plugin, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN,
- settings_plugin_interface_init))
+G_DEFINE_TYPE (NMSIbftPlugin, nms_ibft_plugin, NM_TYPE_SETTINGS_PLUGIN);
#define NMS_IBFT_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSIbftPlugin, NMS_IS_IBFT_PLUGIN)
@@ -143,23 +139,20 @@ dispose (GObject *object)
}
static void
-nms_ibft_plugin_class_init (NMSIbftPluginClass *req_class)
+nms_ibft_plugin_class_init (NMSIbftPluginClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (req_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS (klass);
object_class->dispose = dispose;
-}
-static void
-settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface)
-{
- plugin_iface->get_connections = get_connections;
+ plugin_class->get_connections = get_connections;
}
/*****************************************************************************/
-G_MODULE_EXPORT GObject *
+G_MODULE_EXPORT NMSettingsPlugin *
nm_settings_plugin_factory (void)
{
- return G_OBJECT (g_object_ref (nms_ibft_plugin_get ()));
+ return NM_SETTINGS_PLUGIN (g_object_ref (nms_ibft_plugin_get ()));
}
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
index f8c25092f8..6cac8cb6b8 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
@@ -70,19 +70,15 @@ typedef struct {
} SettingsPluginIfcfgPrivate;
struct _SettingsPluginIfcfg {
- GObject parent;
+ NMSettingsPlugin parent;
SettingsPluginIfcfgPrivate _priv;
};
struct _SettingsPluginIfcfgClass {
- GObjectClass parent;
+ NMSettingsPluginClass parent;
};
-static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface);
-
-G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN,
- settings_plugin_interface_init))
+G_DEFINE_TYPE (SettingsPluginIfcfg, settings_plugin_ifcfg, NM_TYPE_SETTINGS_PLUGIN)
#define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginIfcfg, SETTINGS_IS_PLUGIN_IFCFG)
@@ -164,9 +160,9 @@ remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection)
/* Emit changes _after_ removing the connection */
if (unmanaged)
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NM_SETTINGS_PLUGIN (self));
if (unrecognized)
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unrecognized_specs_changed (NM_SETTINGS_PLUGIN (self));
}
static NMIfcfgConnection *
@@ -349,18 +345,20 @@ update_connection (SettingsPluginIfcfg *self,
if (old_unmanaged /* && !new_unmanaged */) {
_LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" and its device because NM_CONTROLLED was true.",
NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid);
+ _nm_settings_plugin_emit_signal_connection_added (NM_SETTINGS_PLUGIN (self),
+ NM_SETTINGS_CONNECTION (connection_by_uuid));
} else if (old_unrecognized /* && !new_unrecognized */) {
_LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" because it is now a recognized type.",
NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid);
+ _nm_settings_plugin_emit_signal_connection_added (NM_SETTINGS_PLUGIN (self),
+ NM_SETTINGS_CONNECTION (connection_by_uuid));
}
}
if (unmanaged_changed)
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NM_SETTINGS_PLUGIN (self));
if (unrecognized_changed)
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unrecognized_specs_changed (NM_SETTINGS_PLUGIN (self));
}
nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (connection_by_uuid), full_path);
g_object_unref (connection_new);
@@ -398,11 +396,13 @@ update_connection (SettingsPluginIfcfg *self,
/* Only raise the signal if we were called without source, i.e. if we read the connection from file.
* Otherwise, we were called by add_connection() which does not expect the signal. */
if (nm_ifcfg_connection_get_unmanaged_spec (connection_new))
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NM_SETTINGS_PLUGIN (self));
else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new))
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED);
- else
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new);
+ _nm_settings_plugin_emit_signal_unrecognized_specs_changed (NM_SETTINGS_PLUGIN (self));
+ else {
+ _nm_settings_plugin_emit_signal_connection_added (NM_SETTINGS_PLUGIN (self),
+ NM_SETTINGS_CONNECTION (connection_new));
+ }
}
return connection_new;
}
@@ -1058,29 +1058,26 @@ dispose (GObject *object)
}
static void
-settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class)
+settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (req_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS (klass);
object_class->constructed = constructed;
object_class->dispose = dispose;
-}
-static void
-settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface)
-{
- plugin_iface->get_connections = get_connections;
- plugin_iface->add_connection = add_connection;
- plugin_iface->load_connection = load_connection;
- plugin_iface->reload_connections = reload_connections;
- plugin_iface->get_unmanaged_specs = get_unmanaged_specs;
- plugin_iface->get_unrecognized_specs = get_unrecognized_specs;
+ plugin_class->get_connections = get_connections;
+ plugin_class->add_connection = add_connection;
+ plugin_class->load_connection = load_connection;
+ plugin_class->reload_connections = reload_connections;
+ plugin_class->get_unmanaged_specs = get_unmanaged_specs;
+ plugin_class->get_unrecognized_specs = get_unrecognized_specs;
}
/*****************************************************************************/
-G_MODULE_EXPORT GObject *
+G_MODULE_EXPORT NMSettingsPlugin *
nm_settings_plugin_factory (void)
{
- return G_OBJECT (g_object_ref (settings_plugin_ifcfg_get ()));
+ return NM_SETTINGS_PLUGIN (g_object_ref (settings_plugin_ifcfg_get ()));
}
diff --git a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c
index 2138db24e4..4970ccbc4e 100644
--- a/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c
+++ b/src/settings/plugins/ifupdown/nms-ifupdown-plugin.c
@@ -76,19 +76,15 @@ typedef struct {
} SettingsPluginIfupdownPrivate;
struct _SettingsPluginIfupdown {
- GObject parent;
+ NMSettingsPlugin parent;
SettingsPluginIfupdownPrivate _priv;
};
struct _SettingsPluginIfupdownClass {
- GObjectClass parent;
+ NMSettingsPluginClass parent;
};
-static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface);
-
-G_DEFINE_TYPE_EXTENDED (SettingsPluginIfupdown, settings_plugin_ifupdown, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN,
- settings_plugin_interface_init))
+G_DEFINE_TYPE (SettingsPluginIfupdown, settings_plugin_ifupdown, NM_TYPE_SETTINGS_PLUGIN)
#define SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginIfupdown, SETTINGS_IS_PLUGIN_IFUPDOWN)
@@ -174,7 +170,7 @@ udev_device_added (SettingsPluginIfupdown *self, struct udev_device *device)
bind_device_to_connection (self, device, exported);
if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
- g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NM_SETTINGS_PLUGIN (self));
}
static void
@@ -194,7 +190,7 @@ udev_device_removed (SettingsPluginIfupdown *self, struct udev_device *device)
return;
if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
- g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NM_SETTINGS_PLUGIN (self));
}
static void
@@ -214,7 +210,7 @@ udev_device_changed (SettingsPluginIfupdown *self, struct udev_device *device)
return;
if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
- g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED);
+ _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NM_SETTINGS_PLUGIN (self));
}
static void
@@ -455,9 +451,8 @@ initialize (NMSettingsPlugin *config)
GList *cl_iter;
for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) {
- g_signal_emit_by_name (self,
- NM_SETTINGS_PLUGIN_CONNECTION_ADDED,
- NM_SETTINGS_CONNECTION (cl_iter->data));
+ _nm_settings_plugin_emit_signal_connection_added (NM_SETTINGS_PLUGIN (self),
+ NM_SETTINGS_CONNECTION (cl_iter->data));
}
g_list_free (con_list);
}
@@ -487,26 +482,22 @@ dispose (GObject *object)
}
static void
-settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class)
+settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (req_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS (klass);
object_class->dispose = dispose;
-}
-static void
-settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface)
-{
- plugin_iface->initialize = initialize;
- plugin_iface->get_connections = get_connections;
- plugin_iface->get_unmanaged_specs = get_unmanaged_specs;
+ plugin_class->initialize = initialize;
+ plugin_class->get_connections = get_connections;
+ plugin_class->get_unmanaged_specs = get_unmanaged_specs;
}
/*****************************************************************************/
-G_MODULE_EXPORT GObject *
+G_MODULE_EXPORT NMSettingsPlugin *
nm_settings_plugin_factory (void)
{
- return G_OBJECT (g_object_ref (settings_plugin_ifupdown_get ()));
+ return NM_SETTINGS_PLUGIN (g_object_ref (settings_plugin_ifupdown_get ()));
}
-
diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/settings/plugins/keyfile/nms-keyfile-plugin.c
index d97edd1ad4..89b894674e 100644
--- a/src/settings/plugins/keyfile/nms-keyfile-plugin.c
+++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.c
@@ -56,19 +56,15 @@ typedef struct {
} NMSKeyfilePluginPrivate;
struct _NMSKeyfilePlugin {
- GObject parent;
+ NMSettingsPlugin parent;
NMSKeyfilePluginPrivate _priv;
};
struct _NMSKeyfilePluginClass {
- GObjectClass parent;
+ NMSettingsPluginClass parent;
};
-static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface);
-
-G_DEFINE_TYPE_EXTENDED (NMSKeyfilePlugin, nms_keyfile_plugin, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN,
- settings_plugin_interface_init))
+G_DEFINE_TYPE (NMSKeyfilePlugin, nms_keyfile_plugin, NM_TYPE_SETTINGS_PLUGIN)
#define NMS_KEYFILE_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSKeyfilePlugin, NMS_IS_KEYFILE_PLUGIN)
@@ -287,8 +283,10 @@ update_connection (NMSKeyfilePlugin *self,
if (!source) {
/* Only raise the signal if we were called without source, i.e. if we read the connection from file.
* Otherwise, we were called by add_connection() which does not expect the signal. */
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new);
+ _nm_settings_plugin_emit_signal_connection_added (NM_SETTINGS_PLUGIN (self),
+ NM_SETTINGS_CONNECTION (connection_new));
}
+
return connection_new;
}
}
@@ -341,13 +339,14 @@ config_changed_cb (NMConfig *config,
NMConfigData *old_data,
NMSKeyfilePlugin *self)
{
- gs_free char *old_value = NULL, *new_value = NULL;
+ gs_free char *old_value = NULL;
+ gs_free char *new_value = NULL;
old_value = nm_config_data_get_value (old_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC);
new_value = nm_config_data_get_value (config_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC);
- if (g_strcmp0 (old_value, new_value) != 0)
- g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED);
+ if (!nm_streq0 (old_value, new_value))
+ _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NM_SETTINGS_PLUGIN (self));
}
static void
@@ -616,20 +615,17 @@ dispose (GObject *object)
}
static void
-nms_keyfile_plugin_class_init (NMSKeyfilePluginClass *req_class)
+nms_keyfile_plugin_class_init (NMSKeyfilePluginClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (req_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMSettingsPluginClass *plugin_class = NM_SETTINGS_PLUGIN_CLASS (klass);
object_class->constructed = constructed;
- object_class->dispose = dispose;
-}
+ object_class->dispose = dispose;
-static void
-settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface)
-{
- plugin_iface->get_connections = get_connections;
- plugin_iface->load_connection = load_connection;
- plugin_iface->reload_connections = reload_connections;
- plugin_iface->add_connection = add_connection;
- plugin_iface->get_unmanaged_specs = get_unmanaged_specs;
+ plugin_class->get_connections = get_connections;
+ plugin_class->load_connection = load_connection;
+ plugin_class->reload_connections = reload_connections;
+ plugin_class->add_connection = add_connection;
+ plugin_class->get_unmanaged_specs = get_unmanaged_specs;
}