diff options
author | Dan Winship <danw@redhat.com> | 2015-04-16 09:05:49 -0400 |
---|---|---|
committer | Dan Winship <danw@redhat.com> | 2015-09-10 13:43:47 -0400 |
commit | 8e9f7820829bf7f586b73d2954a8727f87df2e74 (patch) | |
tree | 1eb20a1c702e7dd81525beb555e9c04d53050f5f | |
parent | b3d56e4885fc3395337e46acbaf8b6f8bcd2985e (diff) | |
download | NetworkManager-8e9f7820829bf7f586b73d2954a8727f87df2e74.tar.gz |
core: fix interface type names
A GObject interface, like a class, has two different C types
associated with it; the type of the "class" struct (eg, GObjectClass,
GFileIface), and the type of instances of that class/interface (eg,
GObject, GFile).
NetworkManager was doing this wrong though, and using the same C type
to point to both the interface's class struct and to instances of the
interface. This ends up not actually breaking anything, since for
interface types, the instance type is a non-dereferenceable dummy type
anyway. But it's wrong, since if, eg, NMDeviceFactory is a struct type
containing members "start", "device_added", etc, then you should not
be using an NMDeviceFactory* to point to an object that does not
contain those members.
Fix this by splitting NMDeviceFactory into NMDeviceFactoryInterface
and NMDeviceFactory; by splitting NMConnectionProvider into
NMConnectionProviderInterface and NMConnectionProvider; and by
splitting NMSettingsPlugin into NMSettingsPluginInterface and
NMSettingsPlugin; and then use the right types in the right places.
As a bonus, this also lets us now use G_DEFINE_INTERFACE.
-rw-r--r-- | src/devices/adsl/nm-atm-manager.c | 4 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-bluez-manager.c | 4 | ||||
-rw-r--r-- | src/devices/nm-device-factory.c | 29 | ||||
-rw-r--r-- | src/devices/nm-device-factory.h | 10 | ||||
-rw-r--r-- | src/devices/team/nm-team-factory.c | 4 | ||||
-rw-r--r-- | src/devices/wifi/nm-wifi-factory.c | 4 | ||||
-rw-r--r-- | src/devices/wwan/nm-wwan-factory.c | 4 | ||||
-rw-r--r-- | src/nm-connection-provider.c | 35 | ||||
-rw-r--r-- | src/nm-connection-provider.h | 12 | ||||
-rw-r--r-- | src/settings/nm-settings-plugin.c | 40 | ||||
-rw-r--r-- | src/settings/nm-settings-plugin.h | 6 | ||||
-rw-r--r-- | src/settings/nm-settings.c | 14 | ||||
-rw-r--r-- | src/settings/plugins/README | 8 | ||||
-rw-r--r-- | src/settings/plugins/ibft/plugin.c | 10 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/plugin.c | 20 | ||||
-rw-r--r-- | src/settings/plugins/ifnet/plugin.c | 17 | ||||
-rw-r--r-- | src/settings/plugins/ifupdown/plugin.c | 12 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/plugin.c | 18 |
18 files changed, 92 insertions, 159 deletions
diff --git a/src/devices/adsl/nm-atm-manager.c b/src/devices/adsl/nm-atm-manager.c index 6a33d21b1e..b29bc7b19a 100644 --- a/src/devices/adsl/nm-atm-manager.c +++ b/src/devices/adsl/nm-atm-manager.c @@ -39,7 +39,7 @@ typedef struct { static GType nm_atm_manager_get_type (void); -static void device_factory_interface_init (NMDeviceFactory *factory_iface); +static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); G_DEFINE_TYPE_EXTENDED (NMAtmManager, nm_atm_manager, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) @@ -220,7 +220,7 @@ nm_atm_manager_init (NMAtmManager *self) } static void -device_factory_interface_init (NMDeviceFactory *factory_iface) +device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) { factory_iface->get_supported_types = get_supported_types; factory_iface->start = start; diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index bd7c7cab33..db98d2808c 100644 --- a/src/devices/bluetooth/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -56,7 +56,7 @@ typedef struct { static GType nm_bluez_manager_get_type (void); -static void device_factory_interface_init (NMDeviceFactory *factory_iface); +static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); G_DEFINE_TYPE_EXTENDED (NMBluezManager, nm_bluez_manager, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) @@ -421,7 +421,7 @@ create_device (NMDeviceFactory *factory, } static void -device_factory_interface_init (NMDeviceFactory *factory_iface) +device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) { factory_iface->get_supported_types = get_supported_types; factory_iface->create_device = create_device; diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c index 0aea7a69e2..07804da758 100644 --- a/src/devices/nm-device-factory.c +++ b/src/devices/nm-device-factory.c @@ -33,6 +33,8 @@ const NMLinkType _nm_device_factory_no_default_links[] = { NM_LINK_TYPE_NONE }; const char *_nm_device_factory_no_default_settings[] = { NULL }; +G_DEFINE_INTERFACE (NMDeviceFactory, nm_device_factory, G_TYPE_OBJECT) + enum { DEVICE_ADDED, COMPONENT_ADDED, @@ -86,7 +88,7 @@ nm_device_factory_create_device (NMDeviceFactory *factory, gboolean *out_ignore, GError **error) { - NMDeviceFactory *interface; + NMDeviceFactoryInterface *interface; const NMLinkType *link_types = NULL; const char **setting_types = NULL; int i; @@ -188,7 +190,7 @@ nm_device_factory_get_virtual_iface_name (NMDeviceFactory *factory, /*******************************************************************/ static void -default_init (NMDeviceFactory *factory_iface) +nm_device_factory_default_init (NMDeviceFactoryInterface *factory_iface) { factory_iface->get_virtual_iface_name = get_virtual_iface_name; @@ -196,37 +198,18 @@ default_init (NMDeviceFactory *factory_iface) signals[DEVICE_ADDED] = g_signal_new (NM_DEVICE_FACTORY_DEVICE_ADDED, NM_TYPE_DEVICE_FACTORY, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDeviceFactory, device_added), + G_STRUCT_OFFSET (NMDeviceFactoryInterface, device_added), NULL, NULL, NULL, G_TYPE_NONE, 1, NM_TYPE_DEVICE); signals[COMPONENT_ADDED] = g_signal_new (NM_DEVICE_FACTORY_COMPONENT_ADDED, NM_TYPE_DEVICE_FACTORY, G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NMDeviceFactory, component_added), + G_STRUCT_OFFSET (NMDeviceFactoryInterface, component_added), g_signal_accumulator_true_handled, NULL, NULL, G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT); } -GType -nm_device_factory_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - if (g_once_init_enter (&g_define_type_id__volatile)) { - GType g_define_type_id = - g_type_register_static_simple (G_TYPE_INTERFACE, - g_intern_static_string ("NMDeviceFactory"), - sizeof (NMDeviceFactory), - (GClassInitFunc) default_init, - 0, - (GInstanceInitFunc) NULL, - (GTypeFlags) 0); - g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - return g_define_type_id__volatile; -} - /*******************************************************************/ static GSList *internal_types = NULL; diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h index 1bee6b76cb..7568b0fdfb 100644 --- a/src/devices/nm-device-factory.h +++ b/src/devices/nm-device-factory.h @@ -53,13 +53,13 @@ typedef NMDeviceFactory * (*NMDeviceFactoryCreateFunc) (GError **error); #define NM_TYPE_DEVICE_FACTORY (nm_device_factory_get_type ()) #define NM_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactory)) #define NM_IS_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_FACTORY)) -#define NM_DEVICE_FACTORY_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactory)) +#define NM_DEVICE_FACTORY_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_DEVICE_FACTORY, NMDeviceFactoryInterface)) /* signals */ #define NM_DEVICE_FACTORY_COMPONENT_ADDED "component-added" #define NM_DEVICE_FACTORY_DEVICE_ADDED "device-added" -struct _NMDeviceFactory { +typedef struct { GTypeInterface g_iface; /** @@ -164,7 +164,7 @@ struct _NMDeviceFactory { * Returns: %TRUE if the component was claimed by a device, %FALSE if not */ gboolean (*component_added) (NMDeviceFactory *factory, GObject *component); -}; +} NMDeviceFactoryInterface; GType nm_device_factory_get_type (void); @@ -223,7 +223,7 @@ extern const char *_nm_device_factory_no_default_settings[]; typedef GObjectClass NM##mixed##FactoryClass; \ \ static GType nm_##lower##_factory_get_type (void); \ - static void device_factory_interface_init (NMDeviceFactory *factory_iface); \ + static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); \ \ G_DEFINE_TYPE_EXTENDED (NM##mixed##Factory, nm_##lower##_factory, G_TYPE_OBJECT, 0, \ G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init) \ @@ -243,7 +243,7 @@ extern const char *_nm_device_factory_no_default_settings[]; NM_DEVICE_FACTORY_DECLARE_TYPES(st_code) \ \ static void \ - device_factory_interface_init (NMDeviceFactory *factory_iface) \ + device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) \ { \ factory_iface->get_supported_types = get_supported_types; \ dfi_code \ diff --git a/src/devices/team/nm-team-factory.c b/src/devices/team/nm-team-factory.c index 8591782495..d30aa31747 100644 --- a/src/devices/team/nm-team-factory.c +++ b/src/devices/team/nm-team-factory.c @@ -32,7 +32,7 @@ static GType nm_team_factory_get_type (void); -static void device_factory_interface_init (NMDeviceFactory *factory_iface); +static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); G_DEFINE_TYPE_EXTENDED (NMTeamFactory, nm_team_factory, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) @@ -70,7 +70,7 @@ nm_team_factory_init (NMTeamFactory *self) } static void -device_factory_interface_init (NMDeviceFactory *factory_iface) +device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) { factory_iface->create_device = create_device; factory_iface->get_supported_types = get_supported_types; diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c index eca4e1de53..20b0a07508 100644 --- a/src/devices/wifi/nm-wifi-factory.c +++ b/src/devices/wifi/nm-wifi-factory.c @@ -43,7 +43,7 @@ typedef struct { static GType nm_wifi_factory_get_type (void); -static void device_factory_interface_init (NMDeviceFactory *factory_iface); +static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); G_DEFINE_TYPE_EXTENDED (NMWifiFactory, nm_wifi_factory, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) @@ -80,7 +80,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES ( ) static void -device_factory_interface_init (NMDeviceFactory *factory_iface) +device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) { factory_iface->create_device = create_device; factory_iface->get_supported_types = get_supported_types; diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c index 479b5a94cc..97ef4161c9 100644 --- a/src/devices/wwan/nm-wwan-factory.c +++ b/src/devices/wwan/nm-wwan-factory.c @@ -34,7 +34,7 @@ static GType nm_wwan_factory_get_type (void); -static void device_factory_interface_init (NMDeviceFactory *factory_iface); +static void device_factory_interface_init (NMDeviceFactoryInterface *factory_iface); G_DEFINE_TYPE_EXTENDED (NMWwanFactory, nm_wwan_factory, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_FACTORY, device_factory_interface_init)) @@ -128,7 +128,7 @@ nm_wwan_factory_init (NMWwanFactory *self) } static void -device_factory_interface_init (NMDeviceFactory *factory_iface) +device_factory_interface_init (NMDeviceFactoryInterface *factory_iface) { factory_iface->get_supported_types = get_supported_types; factory_iface->create_device = create_device; diff --git a/src/nm-connection-provider.c b/src/nm-connection-provider.c index 51caf400f1..8185b8c60f 100644 --- a/src/nm-connection-provider.c +++ b/src/nm-connection-provider.c @@ -18,6 +18,8 @@ #include "nm-connection-provider.h" #include "nm-utils.h" +G_DEFINE_INTERFACE (NMConnectionProvider, nm_connection_provider, G_TYPE_OBJECT) + GSList * nm_connection_provider_get_best_connections (NMConnectionProvider *self, guint max_requested, @@ -91,7 +93,7 @@ nm_connection_provider_get_connection_by_uuid (NMConnectionProvider *self, /*****************************************************************************/ static void -nm_connection_provider_init (gpointer g_iface) +nm_connection_provider_default_init (NMConnectionProviderInterface *g_iface) { GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); static gboolean initialized = FALSE; @@ -104,7 +106,7 @@ nm_connection_provider_init (gpointer g_iface) g_signal_new (NM_CP_SIGNAL_CONNECTION_ADDED, iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMConnectionProvider, connection_added), + G_STRUCT_OFFSET (NMConnectionProviderInterface, connection_added), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); @@ -112,7 +114,7 @@ nm_connection_provider_init (gpointer g_iface) g_signal_new (NM_CP_SIGNAL_CONNECTION_UPDATED, iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMConnectionProvider, connection_updated), + G_STRUCT_OFFSET (NMConnectionProviderInterface, connection_updated), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); @@ -120,33 +122,8 @@ nm_connection_provider_init (gpointer g_iface) g_signal_new (NM_CP_SIGNAL_CONNECTION_REMOVED, iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMConnectionProvider, connection_removed), + G_STRUCT_OFFSET (NMConnectionProviderInterface, connection_removed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); } - -GType -nm_connection_provider_get_type (void) -{ - static GType cp_type = 0; - - if (!G_UNLIKELY (cp_type)) { - const GTypeInfo cp_info = { - sizeof (NMConnectionProvider), /* class_size */ - nm_connection_provider_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - cp_type = g_type_register_static (G_TYPE_INTERFACE, "NMConnectionProvider", &cp_info, 0); - g_type_interface_add_prerequisite (cp_type, G_TYPE_OBJECT); - } - - return cp_type; -} diff --git a/src/nm-connection-provider.h b/src/nm-connection-provider.h index 1f15216447..2485c56f4f 100644 --- a/src/nm-connection-provider.h +++ b/src/nm-connection-provider.h @@ -20,10 +20,10 @@ #include "nm-default.h" -#define NM_TYPE_CONNECTION_PROVIDER (nm_connection_provider_get_type ()) -#define NM_CONNECTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_PROVIDER, NMConnectionProvider)) -#define NM_IS_CONNECTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_PROVIDER)) -#define NM_CONNECTION_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_CONNECTION_PROVIDER, NMConnectionProvider)) +#define NM_TYPE_CONNECTION_PROVIDER (nm_connection_provider_get_type ()) +#define NM_CONNECTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_PROVIDER, NMConnectionProvider)) +#define NM_IS_CONNECTION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_PROVIDER)) +#define NM_CONNECTION_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_CONNECTION_PROVIDER, NMConnectionProviderInterface)) #define NM_CP_SIGNAL_CONNECTION_ADDED "cp-connection-added" #define NM_CP_SIGNAL_CONNECTION_UPDATED "cp-connection-updated" @@ -43,7 +43,7 @@ typedef gboolean (*NMConnectionFilterFunc) (NMConnectionProvider *provider, gpointer func_data); -struct _NMConnectionProvider { +typedef struct { GTypeInterface g_iface; /* Methods */ @@ -71,7 +71,7 @@ struct _NMConnectionProvider { void (*connection_removed) (NMConnectionProvider *self, NMConnection *connection); -}; +} NMConnectionProviderInterface; GType nm_connection_provider_get_type (void); diff --git a/src/settings/nm-settings-plugin.c b/src/settings/nm-settings-plugin.c index 15803ad985..0bce8957d0 100644 --- a/src/settings/nm-settings-plugin.c +++ b/src/settings/nm-settings-plugin.c @@ -24,8 +24,10 @@ #include "nm-settings-plugin.h" #include "nm-settings-connection.h" +G_DEFINE_INTERFACE (NMSettingsPlugin, nm_settings_plugin, G_TYPE_OBJECT) + static void -interface_init (gpointer g_iface) +nm_settings_plugin_default_init (NMSettingsPluginInterface *g_iface) { GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); static gboolean initialized = FALSE; @@ -61,7 +63,7 @@ interface_init (gpointer g_iface) g_signal_new (NM_SETTINGS_PLUGIN_CONNECTION_ADDED, iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsPlugin, connection_added), + G_STRUCT_OFFSET (NMSettingsPluginInterface, connection_added), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, @@ -70,7 +72,7 @@ interface_init (gpointer g_iface) g_signal_new (NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED, iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsPlugin, unmanaged_specs_changed), + G_STRUCT_OFFSET (NMSettingsPluginInterface, unmanaged_specs_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -78,7 +80,7 @@ interface_init (gpointer g_iface) g_signal_new (NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED, iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsPlugin, unrecognized_specs_changed), + G_STRUCT_OFFSET (NMSettingsPluginInterface, unrecognized_specs_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -86,36 +88,6 @@ interface_init (gpointer g_iface) initialized = TRUE; } - -GType -nm_settings_plugin_get_type (void) -{ - static GType settings_plugin_type = 0; - - if (!settings_plugin_type) { - const GTypeInfo settings_plugin_info = { - sizeof (NMSettingsPlugin), /* class_size */ - interface_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - settings_plugin_type = g_type_register_static (G_TYPE_INTERFACE, - "NMSettingsPlugin", - &settings_plugin_info, - 0); - - g_type_interface_add_prerequisite (settings_plugin_type, G_TYPE_OBJECT); - } - - return settings_plugin_type; -} - void nm_settings_plugin_init (NMSettingsPlugin *config) { diff --git a/src/settings/nm-settings-plugin.h b/src/settings/nm-settings-plugin.h index 2dd46c00b9..ab88e7c2b5 100644 --- a/src/settings/nm-settings-plugin.h +++ b/src/settings/nm-settings-plugin.h @@ -36,7 +36,7 @@ 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_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, NMSettingsPlugin)) +#define NM_SETTINGS_PLUGIN_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_PLUGIN, NMSettingsPluginInterface)) #define NM_SETTINGS_PLUGIN_NAME "name" @@ -67,7 +67,7 @@ typedef enum { typedef struct _NMSettingsPlugin NMSettingsPlugin; -struct _NMSettingsPlugin { +typedef struct { GTypeInterface g_iface; /* Called when the plugin is loaded to initialize it */ @@ -136,7 +136,7 @@ struct _NMSettingsPlugin { /* Emitted when the list of devices with unrecognized connections changes */ void (*unrecognized_specs_changed) (NMSettingsPlugin *config); -}; +} NMSettingsPluginInterface; GType nm_settings_plugin_get_type (void); diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 21ef55f685..491ccf8de3 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -124,10 +124,10 @@ static void claim_connection (NMSettings *self, static void unmanaged_specs_changed (NMSettingsPlugin *config, gpointer user_data); static void unrecognized_specs_changed (NMSettingsPlugin *config, gpointer user_data); -static void connection_provider_init (NMConnectionProvider *cp_class); +static void connection_provider_iface_init (NMConnectionProviderInterface *cp_iface); G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION_PROVIDER, connection_provider_init)) + G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION_PROVIDER, connection_provider_iface_init)) typedef struct { @@ -2152,12 +2152,12 @@ nm_settings_start (NMSettings *self, GError **error) } static void -connection_provider_init (NMConnectionProvider *cp_class) +connection_provider_iface_init (NMConnectionProviderInterface *cp_iface) { - cp_class->get_best_connections = get_best_connections; - cp_class->get_connections = get_connections; - cp_class->add_connection = _nm_connection_provider_add_connection; - cp_class->get_connection_by_uuid = cp_get_connection_by_uuid; + cp_iface->get_best_connections = get_best_connections; + cp_iface->get_connections = get_connections; + cp_iface->add_connection = _nm_connection_provider_add_connection; + cp_iface->get_connection_by_uuid = cp_get_connection_by_uuid; } static void diff --git a/src/settings/plugins/README b/src/settings/plugins/README index 2d7d163ed6..307d0bb1ed 100644 --- a/src/settings/plugins/README +++ b/src/settings/plugins/README @@ -20,12 +20,12 @@ is nm_settings_plugin_factory(). That function creates and returns a singleton instance of the plugin's main object, which implements NMSettingsPlugin. That interface is implemented via the object definition in G_DEFINE_TYPE_EXTENDED in plugin.c, which registers the interface setup function -settings_plugin_init(), which when called actually sets up the vtables -for the functions defined by NMSettingsPlugin. Thus there are two +settings_plugin_interface_init(), which when called actually sets up the vtables +for the functions defined by NMSettingsPluginInterface. Thus there are two entry points into the plugin: nm_settings_plugin_factory() and -the NMSettingsPlugin methods. +the NMSettingsPluginInterface methods. -The plugin also emits various signals (defined by NMSettingsPlugin) +The plugin also emits various signals (defined by NMSettingsPluginInterface) which NetworkManager listens for. These include notifications of new connections if they were created via changes to the on-disk files. The "connection" objects can also emit signals (defined by the NMSettingsConnection diff --git a/src/settings/plugins/ibft/plugin.c b/src/settings/plugins/ibft/plugin.c index 95e488783e..555725d1a3 100644 --- a/src/settings/plugins/ibft/plugin.c +++ b/src/settings/plugins/ibft/plugin.c @@ -36,11 +36,11 @@ #include "reader.h" #include "nm-ibft-connection.h" -static void settings_plugin_init (NMSettingsPlugin *settings_plugin_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); G_DEFINE_TYPE_EXTENDED (SettingsPluginIbft, settings_plugin_ibft, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_init)) + settings_plugin_interface_init)) #define SETTINGS_PLUGIN_IBFT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftPrivate)) @@ -184,11 +184,11 @@ settings_plugin_ibft_class_init (SettingsPluginIbftClass *req_class) } static void -settings_plugin_init (NMSettingsPlugin *settings_plugin_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - settings_plugin_class->get_connections = get_connections; - settings_plugin_class->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->init = init; } G_MODULE_EXPORT GObject * diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index e55fb4d4ba..70e06db9f7 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -76,11 +76,11 @@ static NMIfcfgConnection *update_connection (SettingsPluginIfcfg *plugin, GHashTable *protected_connections, GError **error); -static void settings_plugin_init (NMSettingsPlugin *settings_plugin_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, NM_TYPE_EXPORTED_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_init)) + settings_plugin_interface_init)) #define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgPrivate)) @@ -883,16 +883,16 @@ settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class) } static void -settings_plugin_init (NMSettingsPlugin *settings_plugin_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - settings_plugin_class->get_connections = get_connections; - settings_plugin_class->add_connection = add_connection; - settings_plugin_class->load_connection = load_connection; - settings_plugin_class->reload_connections = reload_connections; - settings_plugin_class->get_unmanaged_specs = get_unmanaged_specs; - settings_plugin_class->get_unrecognized_specs = get_unrecognized_specs; - settings_plugin_class->init = init; + 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_iface->init = init; } G_MODULE_EXPORT GObject * diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c index 0ccd452f86..b670cdac72 100644 --- a/src/settings/plugins/ifnet/plugin.c +++ b/src/settings/plugins/ifnet/plugin.c @@ -62,12 +62,13 @@ typedef struct { gpointer user_data; } FileMonitorInfo; -static void settings_plugin_init (NMSettingsPlugin *class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); static void reload_connections (NMSettingsPlugin *config); G_DEFINE_TYPE_EXTENDED (SettingsPluginIfnet, settings_plugin_ifnet, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, settings_plugin_init)) + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) #define SETTINGS_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetPrivate)) static SettingsPluginIfnet *settings_plugin_ifnet_get (void); @@ -407,13 +408,13 @@ get_connections (NMSettingsPlugin *config) } static void -settings_plugin_init (NMSettingsPlugin *class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - class->init = init; - class->get_connections = get_connections; - class->get_unmanaged_specs = get_unmanaged_specs; - class->add_connection = add_connection; - class->reload_connections = reload_connections; + plugin_iface->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; + plugin_iface->add_connection = add_connection; + plugin_iface->reload_connections = reload_connections; } static void diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c index 5f7dcebb82..fc361de5c1 100644 --- a/src/settings/plugins/ifupdown/plugin.c +++ b/src/settings/plugins/ifupdown/plugin.c @@ -81,11 +81,11 @@ typedef struct { } SettingsPluginIfupdownPrivate; static void -settings_plugin_init (NMSettingsPlugin *settings_plugin_class); +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_init)) + settings_plugin_interface_init)) #define SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownPrivate)) @@ -126,11 +126,11 @@ static void GObject__dispose (GObject *object); static void -settings_plugin_init (NMSettingsPlugin *settings_plugin_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - settings_plugin_class->init = SettingsPluginIfupdown_init; - settings_plugin_class->get_connections = SettingsPluginIfupdown_get_connections; - settings_plugin_class->get_unmanaged_specs = SettingsPluginIfupdown_get_unmanaged_specs; + plugin_iface->init = SettingsPluginIfupdown_init; + plugin_iface->get_connections = SettingsPluginIfupdown_get_connections; + plugin_iface->get_unmanaged_specs = SettingsPluginIfupdown_get_unmanaged_specs; } static void diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index c6961ca1e0..b6c0080a4b 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -44,11 +44,11 @@ #include "common.h" #include "utils.h" -static void settings_plugin_init (NMSettingsPlugin *settings_plugin_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); G_DEFINE_TYPE_EXTENDED (SettingsPluginKeyfile, settings_plugin_keyfile, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, - settings_plugin_init)) + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) #define SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfilePrivate)) @@ -634,14 +634,14 @@ settings_plugin_keyfile_class_init (SettingsPluginKeyfileClass *req_class) } static void -settings_plugin_init (NMSettingsPlugin *settings_plugin_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - settings_plugin_class->get_connections = get_connections; - settings_plugin_class->load_connection = load_connection; - settings_plugin_class->reload_connections = reload_connections; - settings_plugin_class->add_connection = add_connection; - settings_plugin_class->get_unmanaged_specs = get_unmanaged_specs; + 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; } GObject * |