mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 11:18:28 +02:00
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.
This commit is contained in:
parent
b3d56e4885
commit
8e9f782082
18 changed files with 92 additions and 159 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 *
|
||||
|
|
|
|||
|
|
@ -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 *
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue