NetworkManager/src/settings/nm-settings-plugin.c

195 lines
6.1 KiB
C
Raw Normal View History

/* NetworkManager system settings service
*
* 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.
*
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.
2018-08-24 13:37:06 +02:00
* Copyright (C) 2007 - 2018 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
*/
#include "nm-default.h"
#include "nm-settings-plugin.h"
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.
2018-08-24 13:37:06 +02:00
#include "nm-settings-connection.h"
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.
2018-08-24 13:37:06 +02:00
/*****************************************************************************/
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.
2018-08-24 13:37:06 +02:00
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)
/*****************************************************************************/
GSList *
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.
2018-08-24 13:37:06 +02:00
nm_settings_plugin_get_connections (NMSettingsPlugin *self)
{
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.
2018-08-24 13:37:06 +02:00
g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
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.
2018-08-24 13:37:06 +02:00
if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_connections)
return NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_connections (self);
return NULL;
}
gboolean
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.
2018-08-24 13:37:06 +02:00
nm_settings_plugin_load_connection (NMSettingsPlugin *self,
const char *filename)
{
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.
2018-08-24 13:37:06 +02:00
g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), FALSE);
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.
2018-08-24 13:37:06 +02:00
if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->load_connection)
return NM_SETTINGS_PLUGIN_GET_CLASS (self)->load_connection (self, filename);
return FALSE;
}
void
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.
2018-08-24 13:37:06 +02:00
nm_settings_plugin_reload_connections (NMSettingsPlugin *self)
{
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.
2018-08-24 13:37:06 +02:00
g_return_if_fail (NM_IS_SETTINGS_PLUGIN (self));
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.
2018-08-24 13:37:06 +02:00
if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->reload_connections)
NM_SETTINGS_PLUGIN_GET_CLASS (self)->reload_connections (self);
}
GSList *
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.
2018-08-24 13:37:06 +02:00
nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *self)
{
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.
2018-08-24 13:37:06 +02:00
g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
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.
2018-08-24 13:37:06 +02:00
if (NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_unmanaged_specs)
return NM_SETTINGS_PLUGIN_GET_CLASS (self)->get_unmanaged_specs (self);
return NULL;
}
GSList *
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.
2018-08-24 13:37:06 +02:00
nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *self)
{
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.
2018-08-24 13:37:06 +02:00
g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
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.
2018-08-24 13:37:06 +02:00
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:
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.
2018-08-24 13:37:06 +02:00
* @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
* not save to disk
* @error: on return, a location to store any errors that may occur
*
* Creates a new #NMSettingsConnection for the given source @connection. If the
* plugin cannot handle the given connection type, it should return %NULL and
* set @error. The plugin owns the returned object and the caller must reference
* the object if it wishes to continue using it.
*
* Returns: the new #NMSettingsConnection or %NULL
*/
NMSettingsConnection *
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.
2018-08-24 13:37:06 +02:00
nm_settings_plugin_add_connection (NMSettingsPlugin *self,
NMConnection *connection,
gboolean save_to_disk,
GError **error)
{
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.
2018-08-24 13:37:06 +02:00
NMSettingsPluginClass *klass;
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.
2018-08-24 13:37:06 +02:00
g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (self), NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
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.
2018-08-24 13:37:06 +02:00
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;
}
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.
2018-08-24 13:37:06 +02:00
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);
}