diff options
author | Dan Winship <danw@gnome.org> | 2013-05-23 12:59:22 -0300 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-03-18 11:40:18 -0400 |
commit | 598e3114d53f23838bbd1610c0631c9c21717e3b (patch) | |
tree | 552db048d9174bf957434ddb4fac6e0309928fac | |
parent | 3302fba21cbc35c769b6ca760501ee2b7ad90942 (diff) | |
download | NetworkManager-598e3114d53f23838bbd1610c0631c9c21717e3b.tar.gz |
core: fix up NMConnectionProvider and NMHostnameProvider interfaces
The code was using "NMConnectionProvider" as the name of both the
interface struct and the instance struct in different places (likewise
with NMHostnameProvider). Fix that by adding "Interface" to the name
of the interface struct, which then also lets us use
G_DEFINE_INTERFACE.
Also, move some gtk-docs from nm-connection-provider.h to
nm-connection-provider.c.
(NMSystemConfigInterface still has the same problem, but is more
awkward to fix since it has "interface" in its name already...)
-rw-r--r-- | src/nm-connection-provider.c | 66 | ||||
-rw-r--r-- | src/nm-connection-provider.h | 22 | ||||
-rw-r--r-- | src/nm-hostname-provider.c | 27 | ||||
-rw-r--r-- | src/nm-hostname-provider.h | 5 | ||||
-rw-r--r-- | src/nm-manager.c | 6 | ||||
-rw-r--r-- | src/settings/nm-settings.c | 12 |
6 files changed, 51 insertions, 87 deletions
diff --git a/src/nm-connection-provider.c b/src/nm-connection-provider.c index f6ee7454d9..5f4a090b8c 100644 --- a/src/nm-connection-provider.c +++ b/src/nm-connection-provider.c @@ -16,6 +16,24 @@ #include "nm-connection-provider.h" #include "nm-utils.h" +G_DEFINE_INTERFACE (NMConnectionProvider, nm_connection_provider, G_TYPE_OBJECT) + +/** + * nm_connection_provider_get_best_connections: + * @self: the #NMConnectionProvider + * @max_requested: if non-zero, the maximum number of connections to return + * @ctype1: an #NMSetting base type (eg NM_SETTING_WIRELESS_SETTING_NAME) to + * filter connections against + * @ctype2: a second #NMSetting base type (eg NM_SETTING_WIRELESS_SETTING_NAME) + * to filter connections against + * @func: caller-supplied function for filtering connections + * @func_data: caller-supplied data passed to @func + * + * Returns: a #GSList of #NMConnection objects in sorted order representing the + * "best" or highest-priority connections filtered by @ctype1 and/or @ctype2, + * and/or @func. Caller is responsible for freeing the returned #GSList, but + * the contained values do not need to be unreffed. + */ GSList * nm_connection_provider_get_best_connections (NMConnectionProvider *self, guint max_requested, @@ -31,6 +49,14 @@ nm_connection_provider_get_best_connections (NMConnectionProvider *self, return NULL; } +/** + * nm_connection_provider_get_connections: + * @self: the #NMConnectionProvider + * + * Returns: a #GSList of #NMConnection objects representing all known + * connections. Returned list is owned by the connection provider and must + * not be freed. + */ const GSList * nm_connection_provider_get_connections (NMConnectionProvider *self) { @@ -89,20 +115,15 @@ nm_connection_provider_get_connection_by_uuid (NMConnectionProvider *self, /*****************************************************************************/ static void -nm_connection_provider_init (gpointer g_iface) +nm_connection_provider_default_init (NMConnectionProviderInterface *iface) { - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); - static gboolean initialized = FALSE; - - if (initialized) - return; - initialized = TRUE; + GType iface_type = G_TYPE_FROM_INTERFACE (iface); /* Signals */ 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); @@ -110,7 +131,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); @@ -118,33 +139,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 5093d05536..064a094db5 100644 --- a/src/nm-connection-provider.h +++ b/src/nm-connection-provider.h @@ -22,9 +22,10 @@ #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_CONNECTION_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_CONNECTION_PROVIDER, NMConnectionProviderInterface)) typedef struct _NMConnectionProvider NMConnectionProvider; +typedef struct _NMConnectionProviderInterface NMConnectionProviderInterface; #define NM_CP_SIGNAL_CONNECTION_ADDED "cp-connection-added" #define NM_CP_SIGNAL_CONNECTION_UPDATED "cp-connection-updated" @@ -44,7 +45,7 @@ typedef gboolean (*NMConnectionFilterFunc) (NMConnectionProvider *provider, gpointer func_data); -struct _NMConnectionProvider { +struct _NMConnectionProviderInterface { GTypeInterface g_iface; /* Methods */ @@ -106,25 +107,8 @@ GSList *nm_connection_provider_get_best_connections (NMConnectionProvider *self, NMConnectionFilterFunc func, gpointer func_data); -/** - * nm_connection_provider_get_connections: - * @self: the #NMConnectionProvider - * - * Returns: a #GSList of #NMConnection objects representing all known - * connections. Returned list is owned by the connection provider and must - * not be freed. - */ const GSList *nm_connection_provider_get_connections (NMConnectionProvider *self); -/** - * nm_connection_provider_add_connection: - * @self: the #NMConnectionProvider - * @connection: the connection to be added - * @save_to_disk: whether to store the connection on disk - * @error: returns any error if adding fails - * - * returns: a newly added #NMConnection. - */ NMConnection *nm_connection_provider_add_connection (NMConnectionProvider *self, NMConnection *connection, gboolean save_to_disk, diff --git a/src/nm-hostname-provider.c b/src/nm-hostname-provider.c index 1cd1ca6cba..ecda7fe6c3 100644 --- a/src/nm-hostname-provider.c +++ b/src/nm-hostname-provider.c @@ -16,10 +16,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Copyright (C) 2009 Novell, Inc. + * Copyright (C) 2013 Red Hat, Inc. */ #include "nm-hostname-provider.h" +G_DEFINE_INTERFACE (NMHostnameProvider, nm_hostname_provider, G_TYPE_OBJECT) + const char * nm_hostname_provider_get_hostname (NMHostnameProvider *self) { @@ -28,27 +31,7 @@ nm_hostname_provider_get_hostname (NMHostnameProvider *self) return NM_HOSTNAME_PROVIDER_GET_INTERFACE (self)->get_hostname (self); } -GType -nm_hostname_provider_get_type (void) +static void +nm_hostname_provider_default_init (NMHostnameProviderInterface *iface) { - static GType type = 0; - - if (!G_UNLIKELY (type)) { - const GTypeInfo type_info = { - sizeof (NMHostnameProvider), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - type = g_type_register_static (G_TYPE_INTERFACE, "NMHostnameProvider", &type_info, 0); - g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); - } - - return type; } diff --git a/src/nm-hostname-provider.h b/src/nm-hostname-provider.h index 7fe5c00623..10b6f18ca7 100644 --- a/src/nm-hostname-provider.h +++ b/src/nm-hostname-provider.h @@ -26,11 +26,12 @@ #define NM_TYPE_HOSTNAME_PROVIDER (nm_hostname_provider_get_type ()) #define NM_HOSTNAME_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_HOSTNAME_PROVIDER, NMHostnameProvider)) #define NM_IS_HOSTNAME_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_HOSTNAME_PROVIDER)) -#define NM_HOSTNAME_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_HOSTNAME_PROVIDER, NMHostnameProvider)) +#define NM_HOSTNAME_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_HOSTNAME_PROVIDER, NMHostnameProviderInterface)) typedef struct _NMHostnameProvider NMHostnameProvider; +typedef struct _NMHostnameProviderInterface NMHostnameProviderInterface; -struct _NMHostnameProvider { +struct _NMHostnameProviderInterface { GTypeInterface g_iface; /* Methods */ diff --git a/src/nm-manager.c b/src/nm-manager.c index 1466a429f0..8edab333d2 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -133,7 +133,7 @@ static void impl_manager_check_connectivity (NMManager *manager, static void add_device (NMManager *self, NMDevice *device, gboolean generate_con); static void remove_device (NMManager *self, NMDevice *device, gboolean quitting); -static void hostname_provider_init (NMHostnameProvider *provider_class); +static void hostname_provider_init (NMHostnameProviderInterface *provider_iface); static NMActiveConnection *_new_active_connection (NMManager *self, NMConnection *connection, @@ -827,9 +827,9 @@ hostname_provider_get_hostname (NMHostnameProvider *provider) } static void -hostname_provider_init (NMHostnameProvider *provider_class) +hostname_provider_init (NMHostnameProviderInterface *provider_iface) { - provider_class->get_hostname = hostname_provider_get_hostname; + provider_iface->get_hostname = hostname_provider_get_hostname; } NMState diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 852fa6d145..3c59a5925e 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -120,7 +120,7 @@ static void impl_settings_save_hostname (NMSettings *self, static void unmanaged_specs_changed (NMSystemConfigInterface *config, gpointer user_data); static void unrecognized_specs_changed (NMSystemConfigInterface *config, gpointer user_data); -static void connection_provider_init (NMConnectionProvider *cp_class); +static void connection_provider_init (NMConnectionProviderInterface *cp_iface); G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION_PROVIDER, connection_provider_init)) @@ -1815,12 +1815,12 @@ nm_settings_new (GError **error) } static void -connection_provider_init (NMConnectionProvider *cp_class) +connection_provider_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 |