From 7f8dc06dff95bbc0d1eba70a93e43b310dab858d Mon Sep 17 00:00:00 2001 From: Daniel Gnoutcheff Date: Thu, 5 Aug 2010 18:25:15 -0400 Subject: [PATCH] remove nm-settings-connection-interface NMSettingsConnectionInterface was created to allow the daemon and NM clients to have common code that handled both system and user connections. It's no longer needed now that user settings services are gone. This concludes the flattening of libnm-glib. --- cli/src/connections.c | 1 - cli/src/nmcli.c | 1 - docs/libnm-glib/libnm-glib-docs.sgml | 2 - libnm-glib/Makefile.am | 6 +- libnm-glib/libnm-glib.ver | 8 +- libnm-glib/nm-remote-connection.c | 152 ++++++++----- libnm-glib/nm-remote-connection.h | 37 ++++ libnm-glib/nm-settings-connection-interface.c | 192 ---------------- libnm-glib/nm-settings-connection-interface.h | 116 ---------- src/nm-manager.c | 30 +-- .../nm-default-wired-connection.c | 39 ++-- src/system-settings/nm-sysconfig-connection.c | 205 +++++++++++++----- src/system-settings/nm-sysconfig-connection.h | 62 +++++- src/system-settings/nm-sysconfig-settings.c | 41 ++-- .../nm-system-config-interface.c | 2 +- .../nm-system-config-interface.h | 10 +- .../plugins/ifcfg-rh/nm-ifcfg-connection.c | 40 ++-- system-settings/plugins/ifcfg-rh/plugin.c | 2 +- .../plugins/ifupdown/nm-ifupdown-connection.c | 38 ++-- system-settings/plugins/ifupdown/plugin.c | 20 +- .../plugins/keyfile/nm-keyfile-connection.c | 46 ++-- system-settings/plugins/keyfile/plugin.c | 2 +- 22 files changed, 463 insertions(+), 589 deletions(-) delete mode 100644 libnm-glib/nm-settings-connection-interface.c delete mode 100644 libnm-glib/nm-settings-connection-interface.h diff --git a/cli/src/connections.c b/cli/src/connections.c index 73b79b2ce..20b681b55 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -45,7 +45,6 @@ #include //#include #include -#include #include #include "utils.h" diff --git a/cli/src/nmcli.c b/cli/src/nmcli.c index edd2443d3..bfd90b15a 100644 --- a/cli/src/nmcli.c +++ b/cli/src/nmcli.c @@ -35,7 +35,6 @@ #include #include #include -#include #include "nmcli.h" #include "utils.h" diff --git a/docs/libnm-glib/libnm-glib-docs.sgml b/docs/libnm-glib/libnm-glib-docs.sgml index 84a98d07f..efe379744 100644 --- a/docs/libnm-glib/libnm-glib-docs.sgml +++ b/docs/libnm-glib/libnm-glib-docs.sgml @@ -31,8 +31,6 @@ - - diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index d18a8bae5..feb6c05eb 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -76,8 +76,7 @@ libnminclude_HEADERS = \ nm-ip6-config.h \ nm-dhcp6-config.h \ nm-remote-connection.h \ - nm-remote-settings.h \ - nm-settings-connection-interface.h + nm-remote-settings.h libnm_glib_la_SOURCES = \ nm-object.c \ @@ -106,8 +105,7 @@ libnm_glib_la_SOURCES = \ nm-dhcp6-config.c \ nm-remote-connection.c \ nm-remote-connection-private.h \ - nm-remote-settings.c \ - nm-settings-connection-interface.c + nm-remote-settings.c libnm_glib_la_LIBADD = \ $(top_builddir)/libnm-util/libnm-util.la \ diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index be8d35753..1ac3bdb5c 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -116,6 +116,9 @@ global: nm_object_get_connection; nm_object_get_path; nm_object_get_type; + nm_remote_connection_delete; + nm_remote_connection_get_secrets; + nm_remote_connection_commit_changes; nm_remote_connection_get_type; nm_remote_connection_new; nm_remote_settings_add_connection; @@ -128,11 +131,6 @@ global: nm_serial_device_get_bytes_received; nm_serial_device_get_bytes_sent; nm_serial_device_get_type; - nm_settings_connection_interface_delete; - nm_settings_connection_interface_emit_updated; - nm_settings_connection_interface_get_secrets; - nm_settings_connection_interface_get_type; - nm_settings_connection_interface_update; nm_settings_error_quark; nm_settings_get_type; nm_settings_list_connections; diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 8b96b56cb..3f716f943 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -30,14 +30,10 @@ #include "nm-remote-connection-private.h" #include "nm-dbus-glib-types.h" #include "nm-sysconfig-connection-bindings.h" -#include "nm-settings-connection-interface.h" #define NM_REMOTE_CONNECTION_BUS "bus" -static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); - -G_DEFINE_TYPE_EXTENDED (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, settings_connection_interface_init)) +G_DEFINE_TYPE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION) enum { PROP_0, @@ -47,6 +43,14 @@ enum { LAST_PROP }; +enum { + UPDATED, + REMOVED, + + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + typedef struct { NMRemoteConnection *self; @@ -88,22 +92,36 @@ static void update_cb (DBusGProxy *proxy, GError *error, gpointer user_data) { RemoteCall *call = user_data; - NMSettingsConnectionInterfaceUpdateFunc func = (NMSettingsConnectionInterfaceUpdateFunc) call->callback; + NMRemoteConnectionCommitFunc func = (NMRemoteConnectionCommitFunc) call->callback; - (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error, call->user_data); + (*func)(call->self, error, call->user_data); remote_call_complete (call->self, call); } -static gboolean -update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) +/** + * nm_remote_connection_commit_changes: + * @connection: the #NMRemoteConnection + * @callback: a function to be called when the commit completes + * @user_data: caller-specific data to be passed to @callback + * + * Save any local changes to the settings and properties of this connection and + * save them in the settings service. + **/ +void +nm_remote_connection_commit_changes (NMRemoteConnection *self, + NMRemoteConnectionCommitFunc callback, + gpointer user_data) { - NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + NMRemoteConnectionPrivate *priv; GHashTable *settings = NULL; RemoteCall *call; + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_REMOTE_CONNECTION (self)); + g_return_if_fail (callback != NULL); + + priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + call = g_malloc0 (sizeof (RemoteCall)); call->self = self; call->callback = (GFunc) callback; @@ -120,29 +138,40 @@ update (NMSettingsConnectionInterface *connection, priv->calls = g_slist_append (priv->calls, call); g_hash_table_destroy (settings); - - return TRUE; } static void delete_cb (DBusGProxy *proxy, GError *error, gpointer user_data) { RemoteCall *call = user_data; - NMSettingsConnectionInterfaceDeleteFunc func = (NMSettingsConnectionInterfaceDeleteFunc) call->callback; + NMRemoteConnectionDeleteFunc func = (NMRemoteConnectionDeleteFunc) call->callback; - (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error, call->user_data); + (*func)(call->self, error, call->user_data); remote_call_complete (call->self, call); } -static gboolean -do_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data) +/** + * nm_remote_connection_delete: + * @connection: the #NMRemoteConnection + * @callback: a function to be called when the delete completes + * @user_data: caller-specific data to be passed to @callback + * + * Delete the connection. + **/ +void +nm_remote_connection_delete (NMRemoteConnection *self, + NMRemoteConnectionDeleteFunc callback, + gpointer user_data) { - NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + NMRemoteConnectionPrivate *priv; RemoteCall *call; + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_REMOTE_CONNECTION (self)); + g_return_if_fail (callback != NULL); + + priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + call = g_malloc0 (sizeof (RemoteCall)); call->self = self; call->callback = (GFunc) callback; @@ -154,32 +183,47 @@ do_delete (NMSettingsConnectionInterface *connection, call); g_assert (call->call); priv->calls = g_slist_append (priv->calls, call); - - return TRUE; } static void get_secrets_cb (DBusGProxy *proxy, GHashTable *secrets, GError *error, gpointer user_data) { RemoteCall *call = user_data; - NMSettingsConnectionInterfaceGetSecretsFunc func = (NMSettingsConnectionInterfaceGetSecretsFunc) call->callback; + NMRemoteConnectionGetSecretsFunc func = (NMRemoteConnectionGetSecretsFunc) call->callback; - (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error ? NULL : secrets, error, call->user_data); + (*func)(call->self, error ? NULL : secrets, error, call->user_data); remote_call_complete (call->self, call); } -static gboolean -get_secrets (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data) +/** + * nm_remote_connection_get_secrets: + * @connection: the #NMRemoteConnection + * @setting_name: the #NMSetting object name to get secrets for + * @hints: #NMSetting key names to get secrets for (optional) + * @request_new: hint that new secrets (instead of cached or stored secrets) + * should be returned + * @callback: a function to be called when the update completes + * @user_data: caller-specific data to be passed to @callback + * + * Request the connection's secrets. + **/ +void +nm_remote_connection_get_secrets (NMRemoteConnection *self, + const char *setting_name, + const char **hints, + gboolean request_new, + NMRemoteConnectionGetSecretsFunc callback, + gpointer user_data) { - NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + NMRemoteConnectionPrivate *priv; RemoteCall *call; + g_return_if_fail (self != NULL); + g_return_if_fail (NM_IS_REMOTE_CONNECTION (self)); + g_return_if_fail (callback != NULL); + + priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); + call = g_malloc0 (sizeof (RemoteCall)); call->self = self; call->callback = (GFunc) callback; @@ -194,8 +238,6 @@ get_secrets (NMSettingsConnectionInterface *connection, call); g_assert (call->call); priv->calls = g_slist_append (priv->calls, call); - - return TRUE; } /****************************************************************/ @@ -218,7 +260,7 @@ replace_settings (NMRemoteConnection *self, GHashTable *new_settings) /* Emit update irregardless to let listeners figure out what to do with * the connection; whether to delete / ignore it or not. */ - nm_settings_connection_interface_emit_updated (NM_SETTINGS_CONNECTION_INTERFACE (self)); + g_signal_emit (self, signals[UPDATED], 0, new_settings); return TRUE; } @@ -257,20 +299,11 @@ updated_cb (DBusGProxy *proxy, GHashTable *settings, gpointer user_data) static void removed_cb (DBusGProxy *proxy, gpointer user_data) { - g_signal_emit_by_name (G_OBJECT (user_data), "removed"); + g_signal_emit (G_OBJECT (user_data), signals[REMOVED], 0); } /****************************************************************/ -static void -settings_connection_interface_init (NMSettingsConnectionInterface *klass) -{ - /* interface implementation */ - klass->update = update; - klass->delete = do_delete; - klass->get_secrets = get_secrets; -} - /** * nm_remote_connection_new: * @bus: a valid and connected D-Bus connection @@ -425,5 +458,24 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class) NM_REMOTE_CONNECTION_INIT_RESULT_ERROR, NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN, G_PARAM_READABLE)); -} + /* Signals */ + signals[UPDATED] = + g_signal_new (NM_REMOTE_CONNECTION_UPDATED, + G_TYPE_FROM_CLASS (remote_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMRemoteConnectionClass, updated), + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT); + + signals[REMOVED] = + g_signal_new (NM_REMOTE_CONNECTION_REMOVED, + G_TYPE_FROM_CLASS (remote_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMRemoteConnectionClass, removed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + +} diff --git a/libnm-glib/nm-remote-connection.h b/libnm-glib/nm-remote-connection.h index 732ade348..0c627a604 100644 --- a/libnm-glib/nm-remote-connection.h +++ b/libnm-glib/nm-remote-connection.h @@ -38,6 +38,9 @@ G_BEGIN_DECLS #define NM_IS_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_CONNECTION)) #define NM_REMOTE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass)) +#define NM_REMOTE_CONNECTION_UPDATED "updated" +#define NM_REMOTE_CONNECTION_REMOVED "removed" + typedef struct { NMConnection parent; } NMRemoteConnection; @@ -45,6 +48,12 @@ typedef struct { typedef struct { NMConnectionClass parent_class; + /* Signals */ + void (*updated) (NMRemoteConnection *connection, + GHashTable *new_settings); + + void (*removed) (NMRemoteConnection *connection); + /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); @@ -54,10 +63,38 @@ typedef struct { void (*_reserved6) (void); } NMRemoteConnectionClass; +typedef void (*NMRemoteConnectionCommitFunc) (NMRemoteConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMRemoteConnectionDeleteFunc) (NMRemoteConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMRemoteConnectionGetSecretsFunc) (NMRemoteConnection *connection, + GHashTable *secrets, + GError *error, + gpointer user_data); + GType nm_remote_connection_get_type (void); NMRemoteConnection *nm_remote_connection_new (DBusGConnection *bus, const char *path); + +void nm_remote_connection_commit_changes (NMRemoteConnection *connection, + NMRemoteConnectionCommitFunc callback, + gpointer user_data); + +void nm_remote_connection_delete (NMRemoteConnection *connection, + NMRemoteConnectionDeleteFunc callback, + gpointer user_data); + +void nm_remote_connection_get_secrets (NMRemoteConnection *connection, + const char *setting_name, + const char **hints, + gboolean request_new, + NMRemoteConnectionGetSecretsFunc callback, + gpointer user_data); G_END_DECLS #endif /* __NM_REMOTE_CONNECTION__ */ diff --git a/libnm-glib/nm-settings-connection-interface.c b/libnm-glib/nm-settings-connection-interface.c deleted file mode 100644 index 868ad047a..000000000 --- a/libnm-glib/nm-settings-connection-interface.c +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager -- Network link manager - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2009 Red Hat, Inc. - */ - -#include "nm-settings-connection-interface.h" -#include "nm-dbus-glib-types.h" - -/** - * nm_settings_connection_interface_update: - * @connection: an object implementing #NMSettingsConnectionInterface - * @callback: a function to be called when the update completes - * @user_data: caller-specific data to be passed to @callback - * - * Update the connection with current settings and properties. - * - * Returns: TRUE on success, FALSE on failure - **/ -gboolean -nm_settings_connection_interface_update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->update) { - return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->update (connection, - callback, - user_data); - } - return FALSE; -} - -/** - * nm_settings_connection_interface_delete: - * @connection: a objecting implementing #NMSettingsConnectionInterface - * @callback: a function to be called when the delete completes - * @user_data: caller-specific data to be passed to @callback - * - * Delete the connection. - * - * Returns: TRUE on success, FALSE on failure - **/ -gboolean -nm_settings_connection_interface_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->delete) { - return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->delete (connection, - callback, - user_data); - } - return FALSE; -} - -/** - * nm_settings_connection_interface_get_secrets: - * @connection: a object implementing #NMSettingsConnectionInterface - * @setting_name: the #NMSetting object name to get secrets for - * @hints: #NMSetting key names to get secrets for (optional) - * @request_new: hint that new secrets (instead of cached or stored secrets) - * should be returned - * @callback: a function to be called when the update completes - * @user_data: caller-specific data to be passed to @callback - * - * Request the connection's secrets. - * - * Returns: TRUE on success, FALSE on failure - **/ -gboolean -nm_settings_connection_interface_get_secrets (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (connection != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->get_secrets) { - return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->get_secrets (connection, - setting_name, - hints, - request_new, - callback, - user_data); - } - return FALSE; -} - -void -nm_settings_connection_interface_emit_updated (NMSettingsConnectionInterface *connection) -{ - if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->emit_updated) - NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->emit_updated (connection); - else { - NMConnection *tmp; - GHashTable *settings; - - tmp = nm_connection_duplicate (NM_CONNECTION (connection)); - nm_connection_clear_secrets (tmp); - settings = nm_connection_to_hash (tmp); - g_object_unref (tmp); - - g_signal_emit_by_name (connection, NM_SETTINGS_CONNECTION_INTERFACE_UPDATED, settings); - g_hash_table_destroy (settings); - } -} - -static void -nm_settings_connection_interface_init (gpointer g_iface) -{ - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); - static gboolean initialized = FALSE; - - if (initialized) - return; - - /* Signals */ - g_signal_new (NM_SETTINGS_CONNECTION_INTERFACE_UPDATED, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsConnectionInterface, updated), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT); - - g_signal_new (NM_SETTINGS_CONNECTION_INTERFACE_REMOVED, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsConnectionInterface, removed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - initialized = TRUE; -} - -GType -nm_settings_connection_interface_get_type (void) -{ - static GType itype = 0; - - if (!itype) { - const GTypeInfo iinfo = { - sizeof (NMSettingsConnectionInterface), /* class_size */ - nm_settings_connection_interface_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - itype = g_type_register_static (G_TYPE_INTERFACE, - "NMSettingsConnectionInterface", - &iinfo, 0); - - g_type_interface_add_prerequisite (itype, NM_TYPE_CONNECTION); - } - - return itype; -} - diff --git a/libnm-glib/nm-settings-connection-interface.h b/libnm-glib/nm-settings-connection-interface.h deleted file mode 100644 index 7c7a198c7..000000000 --- a/libnm-glib/nm-settings-connection-interface.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * libnm_glib -- Access network status & information from glib applications - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2009 Red Hat, Inc. - */ - -#ifndef __NM_SETTINGS_CONNECTION_INTERFACE_H__ -#define __NM_SETTINGS_CONNECTION_INTERFACE_H__ - -#include -#include - -#include - -G_BEGIN_DECLS - -#define NM_TYPE_SETTINGS_CONNECTION_INTERFACE (nm_settings_connection_interface_get_type ()) -#define NM_SETTINGS_CONNECTION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE, NMSettingsConnectionInterface)) -#define NM_IS_SETTINGS_CONNECTION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE)) -#define NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE, NMSettingsConnectionInterface)) - -#define NM_SETTINGS_CONNECTION_INTERFACE_UPDATED "updated" -#define NM_SETTINGS_CONNECTION_INTERFACE_REMOVED "removed" - -typedef struct _NMSettingsConnectionInterface NMSettingsConnectionInterface; - -typedef void (*NMSettingsConnectionInterfaceUpdateFunc) (NMSettingsConnectionInterface *connection, - GError *error, - gpointer user_data); - -typedef void (*NMSettingsConnectionInterfaceDeleteFunc) (NMSettingsConnectionInterface *connection, - GError *error, - gpointer user_data); - -typedef void (*NMSettingsConnectionInterfaceGetSecretsFunc) (NMSettingsConnectionInterface *connection, - GHashTable *secrets, - GError *error, - gpointer user_data); - -struct _NMSettingsConnectionInterface { - GTypeInterface g_iface; - - /* Methods */ - gboolean (*update) (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data); - - gboolean (*delete) (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data); - - gboolean (*get_secrets) (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data); - - void (*emit_updated) (NMSettingsConnectionInterface *connection); - - /* Signals */ - /* 'new_settings' hash should *not* contain secrets */ - void (*updated) (NMSettingsConnectionInterface *connection, - GHashTable *new_settings); - - void (*removed) (NMSettingsConnectionInterface *connection); - - /* Padding for future expansion */ - void (*_reserved1) (void); - void (*_reserved2) (void); - void (*_reserved3) (void); - void (*_reserved4) (void); - void (*_reserved5) (void); - void (*_reserved6) (void); -}; - -GType nm_settings_connection_interface_get_type (void); - -gboolean nm_settings_connection_interface_update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data); - -gboolean nm_settings_connection_interface_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data); - -gboolean nm_settings_connection_interface_get_secrets (NMSettingsConnectionInterface *connection, - const char *setting_name, - const char **hints, - gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, - gpointer user_data); - -void nm_settings_connection_interface_emit_updated (NMSettingsConnectionInterface *connection); - -G_END_DECLS - -#endif /* __NM_SETTINGS_CONNECTION_INTERFACE_H__ */ - diff --git a/src/nm-manager.c b/src/nm-manager.c index 0f24a4ae3..fcef95dff 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -757,13 +757,13 @@ remove_connection (NMManager *manager, /*******************************************************************/ static void -system_connection_updated_cb (NMSettingsConnectionInterface *connection, +system_connection_updated_cb (NMSysconfigConnection *connection, gpointer unused, NMManager *manager) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); const char *path; - NMSettingsConnectionInterface *existing; + NMSysconfigConnection *existing; GError *error = NULL; path = nm_connection_get_path (NM_CONNECTION (connection)); @@ -792,7 +792,7 @@ system_connection_updated_cb (NMSettingsConnectionInterface *connection, } static void -system_connection_removed_cb (NMSettingsConnectionInterface *connection, +system_connection_removed_cb (NMSysconfigConnection *connection, NMManager *manager) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); @@ -807,16 +807,16 @@ system_connection_removed_cb (NMSettingsConnectionInterface *connection, static void system_internal_new_connection (NMManager *manager, - NMSettingsConnectionInterface *connection) + NMSysconfigConnection *connection) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); const char *path; g_return_if_fail (connection != NULL); - g_signal_connect (connection, NM_SETTINGS_CONNECTION_INTERFACE_UPDATED, + g_signal_connect (connection, NM_SYSCONFIG_CONNECTION_UPDATED, G_CALLBACK (system_connection_updated_cb), manager); - g_signal_connect (connection, NM_SETTINGS_CONNECTION_INTERFACE_REMOVED, + g_signal_connect (connection, NM_SYSCONFIG_CONNECTION_REMOVED, G_CALLBACK (system_connection_removed_cb), manager); path = nm_connection_get_path (NM_CONNECTION (connection)); @@ -826,7 +826,7 @@ system_internal_new_connection (NMManager *manager, static void system_new_connection_cb (NMSysconfigSettings *settings, - NMSettingsConnectionInterface *connection, + NMSysconfigConnection *connection, NMManager *manager) { system_internal_new_connection (manager, connection); @@ -840,7 +840,7 @@ system_query_connections (NMManager *manager) system_connections = nm_sysconfig_settings_list_connections (priv->sys_settings); for (iter = system_connections; iter; iter = g_slist_next (iter)) - system_internal_new_connection (manager, NM_SETTINGS_CONNECTION_INTERFACE (iter->data)); + system_internal_new_connection (manager, NM_SYSCONFIG_CONNECTION (iter->data)); g_slist_free (system_connections); } @@ -1838,7 +1838,7 @@ provider_cancel_secrets (NMSecretsProviderInterface *provider, gpointer user_dat } static void -system_get_secrets_reply_cb (NMSettingsConnectionInterface *connection, +system_get_secrets_reply_cb (NMSysconfigConnection *connection, GHashTable *secrets, GError *error, gpointer user_data) @@ -1886,12 +1886,12 @@ system_get_secrets_idle_cb (gpointer user_data) hints[0] = info->hint1; hints[1] = info->hint2; - nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (connection), - info->setting_name, - hints, - info->request_new, - system_get_secrets_reply_cb, - info); + nm_sysconfig_connection_get_secrets (connection, + info->setting_name, + hints, + info->request_new, + system_get_secrets_reply_cb, + info); return FALSE; } diff --git a/src/system-settings/nm-default-wired-connection.c b/src/system-settings/nm-default-wired-connection.c index 54e00d627..365589259 100644 --- a/src/system-settings/nm-default-wired-connection.c +++ b/src/system-settings/nm-default-wired-connection.c @@ -31,15 +31,8 @@ #include "nm-dbus-glib-types.h" #include "nm-marshal.h" #include "nm-default-wired-connection.h" -#include "nm-settings-connection-interface.h" -static NMSettingsConnectionInterface *parent_settings_connection_iface; - -static void settings_connection_interface_init (NMSettingsConnectionInterface *iface); - -G_DEFINE_TYPE_EXTENDED (NMDefaultWiredConnection, nm_default_wired_connection, NM_TYPE_SYSCONFIG_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, - settings_connection_interface_init)) +G_DEFINE_TYPE (NMDefaultWiredConnection, nm_default_wired_connection, NM_TYPE_SYSCONFIG_CONNECTION) #define NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEFAULT_WIRED_CONNECTION, NMDefaultWiredConnectionPrivate)) @@ -91,10 +84,10 @@ nm_default_wired_connection_get_device (NMDefaultWiredConnection *wired) return NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (wired)->device; } -static gboolean -update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) +static void +commit_changes (NMSysconfigConnection *connection, + NMSysconfigConnectionCommitFunc callback, + gpointer user_data) { NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection); @@ -105,31 +98,24 @@ update (NMSettingsConnectionInterface *connection, g_signal_emit (self, signals[TRY_UPDATE], 0); callback (connection, NULL, user_data); g_object_unref (connection); - return TRUE; } -static gboolean -do_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, +static void +do_delete (NMSysconfigConnection *connection, + NMSysconfigConnectionDeleteFunc callback, gpointer user_data) { NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection); NMDefaultWiredConnectionPrivate *priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (connection); g_signal_emit (self, signals[DELETED], 0, priv->mac); - return parent_settings_connection_iface->delete (connection, callback, user_data); + NM_SYSCONFIG_CONNECTION_CLASS (nm_default_wired_connection_parent_class)->delete (connection, + callback, + user_data); } /****************************************************************/ -static void -settings_connection_interface_init (NMSettingsConnectionInterface *iface) -{ - parent_settings_connection_iface = g_type_interface_peek_parent (iface); - iface->update = update; - iface->delete = do_delete; -} - static void nm_default_wired_connection_init (NMDefaultWiredConnection *self) { @@ -250,6 +236,7 @@ static void nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (klass); g_type_class_add_private (klass, sizeof (NMDefaultWiredConnectionPrivate)); @@ -258,6 +245,8 @@ nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass) object_class->set_property = set_property; object_class->get_property = get_property; object_class->finalize = finalize; + sysconfig_class->commit_changes = commit_changes; + sysconfig_class->delete = do_delete; /* Properties */ g_object_class_install_property diff --git a/src/system-settings/nm-sysconfig-connection.c b/src/system-settings/nm-sysconfig-connection.c index 8d0c061e8..7de46866a 100644 --- a/src/system-settings/nm-sysconfig-connection.c +++ b/src/system-settings/nm-sysconfig-connection.c @@ -26,7 +26,6 @@ #include "nm-sysconfig-connection.h" #include "nm-system-config-error.h" #include "nm-dbus-glib-types.h" -#include "nm-settings-connection-interface.h" #include "nm-polkit-helpers.h" #include "nm-logging.h" @@ -49,16 +48,20 @@ static void impl_sysconfig_connection_get_secrets (NMSysconfigConnection *connec #include "nm-sysconfig-connection-glue.h" -static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); - -G_DEFINE_TYPE_EXTENDED (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, - settings_connection_interface_init)) +G_DEFINE_TYPE (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_CONNECTION) #define NM_SYSCONFIG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ NM_TYPE_SYSCONFIG_CONNECTION, \ NMSysconfigConnectionPrivate)) +enum { + UPDATED, + REMOVED, + + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + typedef struct { PolkitAuthority *authority; GSList *pk_calls; @@ -102,7 +105,7 @@ nm_sysconfig_connection_replace_settings (NMSysconfigConnection *self, } static void -ignore_cb (NMSettingsConnectionInterface *connection, +ignore_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data) { @@ -116,7 +119,7 @@ ignore_cb (NMSettingsConnectionInterface *connection, void nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self, NMConnection *new, - NMSettingsConnectionInterfaceUpdateFunc callback, + NMSysconfigConnectionCommitFunc callback, gpointer user_data) { GError *error = NULL; @@ -133,43 +136,127 @@ nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self, if (nm_connection_compare (NM_CONNECTION (self), NM_CONNECTION (new), NM_SETTING_COMPARE_FLAG_EXACT)) { - callback (NM_SETTINGS_CONNECTION_INTERFACE (self), NULL, user_data); + callback (self, NULL, user_data); return; } if (nm_sysconfig_connection_replace_settings (self, new, &error)) { - nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (self), - callback, user_data); + nm_sysconfig_connection_commit_changes (self, callback, user_data); } else { - callback (NM_SETTINGS_CONNECTION_INTERFACE (self), error, user_data); + callback (self, error, user_data); g_clear_error (&error); } } +void +nm_sysconfig_connection_commit_changes (NMSysconfigConnection *connection, + NMSysconfigConnectionCommitFunc callback, + gpointer user_data) +{ + g_return_if_fail (connection != NULL); + g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection)); + g_return_if_fail (callback != NULL); + + if (NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->commit_changes) { + NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->commit_changes (connection, + callback, + user_data); + } else { + GError *error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR, + NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR, + "%s: %s:%d commit_changes() unimplemented", __func__, __FILE__, __LINE__); + callback (connection, error, user_data); + g_error_free (error); + } +} + +void +nm_sysconfig_connection_delete (NMSysconfigConnection *connection, + NMSysconfigConnectionDeleteFunc callback, + gpointer user_data) +{ + g_return_if_fail (connection != NULL); + g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection)); + g_return_if_fail (callback != NULL); + + if (NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->delete) { + NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->delete (connection, + callback, + user_data); + } else { + GError *error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR, + NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR, + "%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__); + callback (connection, error, user_data); + g_error_free (error); + } +} + +void +nm_sysconfig_connection_get_secrets (NMSysconfigConnection *connection, + const char *setting_name, + const char **hints, + gboolean request_new, + NMSysconfigConnectionGetSecretsFunc callback, + gpointer user_data) +{ + g_return_if_fail (connection != NULL); + g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection)); + g_return_if_fail (callback != NULL); + + if (NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->get_secrets) { + NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->get_secrets (connection, + setting_name, + hints, + request_new, + callback, + user_data); + } else { + GError *error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR, + NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR, + "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__); + callback (connection, NULL, error, user_data); + g_error_free (error); + } +} + /**************************************************************/ -static gboolean -update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) +static void +emit_updated (NMSysconfigConnection *connection) { - g_object_ref (connection); - nm_settings_connection_interface_emit_updated (connection); - callback (connection, NULL, user_data); - g_object_unref (connection); - return TRUE; + NMConnection *tmp; + GHashTable *settings; + + tmp = nm_connection_duplicate (NM_CONNECTION (connection)); + nm_connection_clear_secrets (tmp); + settings = nm_connection_to_hash (tmp); + g_object_unref (tmp); + + g_signal_emit (connection, signals[UPDATED], 0, settings); + g_hash_table_destroy (settings); } -static gboolean -do_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, +static void +commit_changes (NMSysconfigConnection *connection, + NMSysconfigConnectionCommitFunc callback, + gpointer user_data) +{ + g_object_ref (connection); + emit_updated (connection); + callback (connection, NULL, user_data); + g_object_unref (connection); +} + +static void +do_delete (NMSysconfigConnection *connection, + NMSysconfigConnectionDeleteFunc callback, gpointer user_data) { g_object_ref (connection); - g_signal_emit_by_name (connection, "removed"); + g_signal_emit (connection, signals[REMOVED], 0); callback (connection, NULL, user_data); g_object_unref (connection); - return TRUE; } static GValue * @@ -246,16 +333,15 @@ destroy_gvalue (gpointer data) g_slice_free (GValue, value); } -static gboolean -get_secrets (NMSettingsConnectionInterface *connection, +static void +get_secrets (NMSysconfigConnection *connection, const char *setting_name, const char **hints, gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, + NMSysconfigConnectionGetSecretsFunc callback, gpointer user_data) { - NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (connection); - NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self); + NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (connection); GHashTable *settings = NULL; GHashTable *secrets = NULL; NMSetting *setting; @@ -273,7 +359,7 @@ get_secrets (NMSettingsConnectionInterface *connection, __FILE__, __LINE__); (*callback) (connection, NULL, error, user_data); g_error_free (error); - return TRUE; + return; } setting = nm_connection_get_setting_by_name (priv->secrets, setting_name); @@ -284,7 +370,7 @@ get_secrets (NMSettingsConnectionInterface *connection, __FILE__, __LINE__, setting_name); (*callback) (connection, NULL, error, user_data); g_error_free (error); - return TRUE; + return; } /* Returned secrets are a{sa{sv}}; this is the outer a{s...} hash that @@ -300,7 +386,6 @@ get_secrets (NMSettingsConnectionInterface *connection, g_hash_table_insert (settings, g_strdup (setting_name), secrets); callback (connection, settings, NULL, user_data); g_hash_table_destroy (settings); - return TRUE; } /**************************************************************/ @@ -420,7 +505,7 @@ polkit_call_free (PolkitCall *call) } static void -con_update_cb (NMSettingsConnectionInterface *connection, +con_update_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data) { @@ -533,7 +618,7 @@ impl_sysconfig_connection_update (NMSysconfigConnection *self, } static void -con_delete_cb (NMSettingsConnectionInterface *connection, +con_delete_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data) { @@ -594,9 +679,7 @@ pk_delete_cb (GObject *object, GAsyncResult *result, gpointer user_data) } /* Caller is authenticated, now we can finally try to delete */ - nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (self), - con_delete_cb, - call); + nm_sysconfig_connection_delete (self, con_delete_cb, call); out: g_object_unref (pk_result); @@ -630,7 +713,7 @@ impl_sysconfig_connection_delete (NMSysconfigConnection *self, } static void -con_secrets_cb (NMSettingsConnectionInterface *connection, +con_secrets_cb (NMSysconfigConnection *connection, GHashTable *secrets, GError *error, gpointer user_data) @@ -692,12 +775,12 @@ pk_secrets_cb (GObject *object, GAsyncResult *result, gpointer user_data) } /* Caller is authenticated, now we can finally try to update */ - nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (self), - call->setting_name, - (const char **) call->hints, - call->request_new, - con_secrets_cb, - call); + nm_sysconfig_connection_get_secrets (self, + call->setting_name, + (const char **) call->hints, + call->request_new, + con_secrets_cb, + call); out: g_object_unref (pk_result); @@ -728,14 +811,6 @@ impl_sysconfig_connection_get_secrets (NMSysconfigConnection *self, /**************************************************************/ -static void -settings_connection_interface_init (NMSettingsConnectionInterface *iface) -{ - iface->update = update; - iface->delete = do_delete; - iface->get_secrets = get_secrets; -} - static void nm_sysconfig_connection_init (NMSysconfigConnection *self) { @@ -779,6 +854,28 @@ nm_sysconfig_connection_class_init (NMSysconfigConnectionClass *class) /* Virtual methods */ object_class->dispose = dispose; + class->commit_changes = commit_changes; + class->delete = do_delete; + class->get_secrets = get_secrets; + + /* Signals */ + signals[UPDATED] = + g_signal_new (NM_SYSCONFIG_CONNECTION_UPDATED, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT); + + signals[REMOVED] = + g_signal_new (NM_SYSCONFIG_CONNECTION_REMOVED, + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class), &dbus_glib_nm_sysconfig_connection_object_info); diff --git a/src/system-settings/nm-sysconfig-connection.h b/src/system-settings/nm-sysconfig-connection.h index 253c28750..f2510d288 100644 --- a/src/system-settings/nm-sysconfig-connection.h +++ b/src/system-settings/nm-sysconfig-connection.h @@ -22,7 +22,6 @@ #define NM_SYSCONFIG_CONNECTION_H #include -#include #include G_BEGIN_DECLS @@ -34,25 +33,74 @@ G_BEGIN_DECLS #define NM_IS_SYSCONFIG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SYSCONFIG_CONNECTION)) #define NM_SYSCONFIG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION, NMSysconfigConnectionClass)) -typedef struct { - NMConnection parent; -} NMSysconfigConnection; +#define NM_SYSCONFIG_CONNECTION_UPDATED "updated" +#define NM_SYSCONFIG_CONNECTION_REMOVED "removed" -typedef struct { +typedef struct _NMSysconfigConnection NMSysconfigConnection; + +typedef struct _NMSysconfigConnectionClass NMSysconfigConnectionClass; + +typedef void (*NMSysconfigConnectionCommitFunc) (NMSysconfigConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMSysconfigConnectionDeleteFunc) (NMSysconfigConnection *connection, + GError *error, + gpointer user_data); + +typedef void (*NMSysconfigConnectionGetSecretsFunc) (NMSysconfigConnection *connection, + GHashTable *secrets, + GError *error, + gpointer user_data); + +struct _NMSysconfigConnection { + NMConnection parent; +}; + +struct _NMSysconfigConnectionClass { NMConnectionClass parent; -} NMSysconfigConnectionClass; + + void (*commit_changes) (NMSysconfigConnection *connection, + NMSysconfigConnectionCommitFunc callback, + gpointer user_data); + + void (*delete) (NMSysconfigConnection *connection, + NMSysconfigConnectionDeleteFunc callback, + gpointer user_data); + + void (*get_secrets) (NMSysconfigConnection *connection, + const char *setting_name, + const char **hints, + gboolean request_new, + NMSysconfigConnectionGetSecretsFunc callback, + gpointer user_data); +}; GType nm_sysconfig_connection_get_type (void); +void nm_sysconfig_connection_commit_changes (NMSysconfigConnection *connection, + NMSysconfigConnectionCommitFunc callback, + gpointer user_data); + gboolean nm_sysconfig_connection_replace_settings (NMSysconfigConnection *self, NMConnection *new_settings, GError **error); void nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self, NMConnection *new_settings, - NMSettingsConnectionInterfaceUpdateFunc callback, + NMSysconfigConnectionCommitFunc callback, gpointer user_data); +void nm_sysconfig_connection_delete (NMSysconfigConnection *connection, + NMSysconfigConnectionDeleteFunc callback, + gpointer user_data); + +void nm_sysconfig_connection_get_secrets (NMSysconfigConnection *connection, + const char *setting_name, + const char **hints, + gboolean request_new, + NMSysconfigConnectionGetSecretsFunc callback, + gpointer user_data); G_END_DECLS diff --git a/src/system-settings/nm-sysconfig-settings.c b/src/system-settings/nm-sysconfig-settings.c index c6294cbf8..bc89b777c 100644 --- a/src/system-settings/nm-sysconfig-settings.c +++ b/src/system-settings/nm-sysconfig-settings.c @@ -76,7 +76,7 @@ EXPORT(nm_sysconfig_connection_replace_and_commit) /* END LINKER CRACKROCK */ static void claim_connection (NMSysconfigSettings *self, - NMSettingsConnectionInterface *connection, + NMSysconfigConnection *connection, gboolean do_export); static gboolean impl_settings_list_connections (NMSysconfigSettings *self, @@ -160,7 +160,7 @@ load_connections (NMSysconfigSettings *self) // priority plugin. for (elt = plugin_connections; elt; elt = g_slist_next (elt)) - claim_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (elt->data), TRUE); + claim_connection (self, NM_SYSCONFIG_CONNECTION (elt->data), TRUE); g_slist_free (plugin_connections); } @@ -342,7 +342,7 @@ nm_sysconfig_settings_get_hostname (NMSysconfigSettings *self) static void plugin_connection_added (NMSystemConfigInterface *config, - NMSettingsConnectionInterface *connection, + NMSysconfigConnection *connection, gpointer user_data) { claim_connection (NM_SYSCONFIG_SETTINGS (user_data), connection, TRUE); @@ -531,7 +531,7 @@ load_plugins (NMSysconfigSettings *self, const char *plugins, GError **error) } static void -connection_removed (NMSettingsConnectionInterface *connection, +connection_removed (NMSysconfigConnection *connection, gpointer user_data) { NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (user_data); @@ -541,14 +541,14 @@ connection_removed (NMSettingsConnectionInterface *connection, static void export_connection (NMSysconfigSettings *self, - NMSettingsConnectionInterface *connection) + NMSysconfigConnection *connection) { NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self); static guint32 ec_counter = 0; char *path; g_return_if_fail (connection != NULL); - g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection)); + g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection)); g_return_if_fail (priv->bus != NULL); /* Don't allow exporting twice */ @@ -563,13 +563,13 @@ export_connection (NMSysconfigSettings *self, static void claim_connection (NMSysconfigSettings *self, - NMSettingsConnectionInterface *connection, + NMSysconfigConnection *connection, gboolean do_export) { NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self); g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self)); - g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection)); + g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection)); if (g_hash_table_lookup (priv->connections, connection)) /* A plugin is lying to us. */ @@ -577,7 +577,7 @@ claim_connection (NMSysconfigSettings *self, g_hash_table_insert (priv->connections, g_object_ref (connection), GINT_TO_POINTER (1)); g_signal_connect (connection, - NM_SETTINGS_CONNECTION_INTERFACE_REMOVED, + NM_SYSCONFIG_CONNECTION_REMOVED, G_CALLBACK (connection_removed), self); @@ -589,16 +589,13 @@ claim_connection (NMSysconfigSettings *self, static void remove_connection (NMSysconfigSettings *self, - NMSettingsConnectionInterface *connection, + NMSysconfigConnection *connection, gboolean do_signal) { NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self); - g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self)); - g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection)); - if (g_hash_table_lookup (priv->connections, connection)) { - g_signal_emit_by_name (G_OBJECT (connection), NM_SETTINGS_CONNECTION_INTERFACE_REMOVED); + g_signal_emit_by_name (G_OBJECT (connection), NM_SYSCONFIG_CONNECTION_REMOVED); g_hash_table_remove (priv->connections, connection); } } @@ -1234,7 +1231,7 @@ cleanup: } static void -delete_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer user_data) +delete_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data) { } @@ -1256,11 +1253,11 @@ default_wired_try_update (NMDefaultWiredConnection *wired, id = nm_setting_connection_get_id (s_con); g_assert (id); - remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), FALSE); + remove_connection (self, NM_SYSCONFIG_CONNECTION (wired), FALSE); if (add_new_connection (self, NM_CONNECTION (wired), &error)) { - nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (wired), - delete_cb, - NULL); + nm_sysconfig_connection_delete (NM_SYSCONFIG_CONNECTION (wired), + delete_cb, + NULL); g_object_set_data (G_OBJECT (nm_default_wired_connection_get_device (wired)), DEFAULT_WIRED_TAG, @@ -1278,7 +1275,7 @@ default_wired_try_update (NMDefaultWiredConnection *wired, * but add it back to the system settings service. Connection is already * exported on the bus, don't export it again, thus do_export == FALSE. */ - claim_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), FALSE); + claim_connection (self, NM_SYSCONFIG_CONNECTION (wired), FALSE); return TRUE; } @@ -1329,7 +1326,7 @@ nm_sysconfig_settings_device_added (NMSysconfigSettings *self, NMDevice *device) g_signal_connect (wired, "try-update", (GCallback) default_wired_try_update, self); g_signal_connect (wired, "deleted", (GCallback) default_wired_deleted, self); - claim_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), TRUE); + claim_connection (self, NM_SYSCONFIG_CONNECTION (wired), TRUE); g_object_unref (wired); g_object_set_data (G_OBJECT (device), DEFAULT_WIRED_TAG, wired); @@ -1348,7 +1345,7 @@ nm_sysconfig_settings_device_removed (NMSysconfigSettings *self, NMDevice *devic connection = (NMDefaultWiredConnection *) g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_TAG); if (connection) - remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (connection), TRUE); + remove_connection (self, NM_SYSCONFIG_CONNECTION (connection), TRUE); } static void diff --git a/src/system-settings/nm-system-config-interface.c b/src/system-settings/nm-system-config-interface.c index 90fd93ba3..f522a9b44 100644 --- a/src/system-settings/nm-system-config-interface.c +++ b/src/system-settings/nm-system-config-interface.c @@ -73,7 +73,7 @@ interface_init (gpointer g_iface) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - NM_TYPE_SETTINGS_CONNECTION_INTERFACE); + NM_TYPE_SYSCONFIG_CONNECTION); g_signal_new (NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED, iface_type, diff --git a/src/system-settings/nm-system-config-interface.h b/src/system-settings/nm-system-config-interface.h index 3daceb89b..439586a40 100644 --- a/src/system-settings/nm-system-config-interface.h +++ b/src/system-settings/nm-system-config-interface.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include G_BEGIN_DECLS @@ -90,9 +90,9 @@ struct _NMSystemConfigInterface { /* Called when the plugin is loaded to initialize it */ void (*init) (NMSystemConfigInterface *config); - /* Returns a GSList of objects that implement NMSettingsConnectionInterface - * that represent connections the plugin knows about. The returned list - * is freed by the system settings service. + /* Returns a GSList of NMSysconfigConnection objects that represent + * connections the plugin knows about. The returned list is freed by the + * system settings service. */ GSList * (*get_connections) (NMSystemConfigInterface *config); @@ -127,7 +127,7 @@ struct _NMSystemConfigInterface { /* Emitted when a new connection has been found by the plugin */ void (*connection_added) (NMSystemConfigInterface *config, - NMSettingsConnectionInterface *connection); + NMSysconfigConnection *connection); /* Emitted when the list of unmanaged device specifications changes */ void (*unmanaged_specs_changed) (NMSystemConfigInterface *config); diff --git a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index 64f29ecaa..e8df1b376 100644 --- a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "common.h" #include "nm-ifcfg-connection.h" @@ -41,13 +40,7 @@ #include "writer.h" #include "nm-inotify-helper.h" -static NMSettingsConnectionInterface *parent_settings_connection_iface; - -static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); - -G_DEFINE_TYPE_EXTENDED (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SYSCONFIG_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, - settings_connection_interface_init)) +G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SYSCONFIG_CONNECTION) #define NM_IFCFG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionPrivate)) @@ -171,10 +164,10 @@ nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self) return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged; } -static gboolean -update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) +static void +commit_changes (NMSysconfigConnection *connection, + NMSysconfigConnectionCommitFunc callback, + gpointer user_data) { NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); GError *error = NULL; @@ -205,18 +198,18 @@ update (NMSettingsConnectionInterface *connection, &error)) { callback (connection, error, user_data); g_error_free (error); - return FALSE; + return; } out: if (reread) g_object_unref (reread); - return parent_settings_connection_iface->update (connection, callback, user_data); + NM_SYSCONFIG_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, callback, user_data); } -static gboolean -do_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, +static void +do_delete (NMSysconfigConnection *connection, + NMSysconfigConnectionDeleteFunc callback, gpointer user_data) { NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); @@ -230,19 +223,11 @@ do_delete (NMSettingsConnectionInterface *connection, if (priv->route6file) g_unlink (priv->route6file); - return parent_settings_connection_iface->delete (connection, callback, user_data); + NM_SYSCONFIG_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->delete (connection, callback, user_data); } /* GObject */ -static void -settings_connection_interface_init (NMSettingsConnectionInterface *iface) -{ - parent_settings_connection_iface = g_type_interface_peek_parent (iface); - iface->update = update; - iface->delete = do_delete; -} - static void nm_ifcfg_connection_init (NMIfcfgConnection *connection) { @@ -331,6 +316,7 @@ static void nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) { GObjectClass *object_class = G_OBJECT_CLASS (ifcfg_connection_class); + NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (ifcfg_connection_class); g_type_class_add_private (ifcfg_connection_class, sizeof (NMIfcfgConnectionPrivate)); @@ -338,6 +324,8 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) object_class->set_property = set_property; object_class->get_property = get_property; object_class->finalize = finalize; + sysconfig_class->delete = do_delete; + sysconfig_class->commit_changes = commit_changes; /* Properties */ g_object_class_install_property diff --git a/system-settings/plugins/ifcfg-rh/plugin.c b/system-settings/plugins/ifcfg-rh/plugin.c index f6db49572..c328a3336 100644 --- a/system-settings/plugins/ifcfg-rh/plugin.c +++ b/system-settings/plugins/ifcfg-rh/plugin.c @@ -204,7 +204,7 @@ read_connections (SCPluginIfcfg *plugin) /* Callback for nm_sysconfig_connection_replace_and_commit. Report any errors * encountered when commiting connection settings updates. */ static void -commit_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer unused) +commit_cb (NMSysconfigConnection *connection, GError *error, gpointer unused) { if (error) { PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error updating: %s", diff --git a/system-settings/plugins/ifupdown/nm-ifupdown-connection.c b/system-settings/plugins/ifupdown/nm-ifupdown-connection.c index 5eb83ad4b..3c584cc3f 100644 --- a/system-settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/system-settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -32,13 +32,7 @@ #include "nm-ifupdown-connection.h" #include "parser.h" -static NMSettingsConnectionInterface *parent_settings_connection_iface; - -static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); - -G_DEFINE_TYPE_EXTENDED (NMIfupdownConnection, nm_ifupdown_connection, NM_TYPE_SYSCONFIG_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, - settings_connection_interface_init)) +G_DEFINE_TYPE (NMIfupdownConnection, nm_ifupdown_connection, NM_TYPE_SYSCONFIG_CONNECTION) #define NM_IFUPDOWN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionPrivate)) @@ -63,12 +57,12 @@ nm_ifupdown_connection_new (if_block *block) NULL); } -static gboolean -get_secrets (NMSettingsConnectionInterface *connection, +static void +get_secrets (NMSysconfigConnection *connection, const gchar *setting_name, const gchar **hints, gboolean request_new, - NMSettingsConnectionInterfaceGetSecretsFunc callback, + NMSysconfigConnectionGetSecretsFunc callback, gpointer user_data) { GError *error = NULL; @@ -85,22 +79,15 @@ get_secrets (NMSettingsConnectionInterface *connection, PLUGIN_PRINT ("SCPlugin-Ifupdown", "%s", error->message); callback (connection, NULL, error, user_data); g_error_free (error); - return FALSE; + return; } - return parent_settings_connection_iface->get_secrets (connection, - setting_name, - hints, - request_new, - callback, - user_data); -} - -static void -settings_connection_interface_init (NMSettingsConnectionInterface *iface) -{ - parent_settings_connection_iface = g_type_interface_peek_parent (iface); - iface->get_secrets = get_secrets; + NM_SYSCONFIG_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->get_secrets (connection, + setting_name, + hints, + request_new, + callback, + user_data); } static void @@ -184,6 +171,7 @@ static void nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class) { GObjectClass *object_class = G_OBJECT_CLASS (ifupdown_connection_class); + NMSysconfigConnectionClass *connection_class = NM_SYSCONFIG_CONNECTION_CLASS (ifupdown_connection_class); g_type_class_add_private (ifupdown_connection_class, sizeof (NMIfupdownConnectionPrivate)); @@ -192,6 +180,8 @@ nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connectio object_class->set_property = set_property; object_class->get_property = get_property; + connection_class->get_secrets = get_secrets; + /* Properties */ g_object_class_install_property (object_class, PROP_IFBLOCK, diff --git a/system-settings/plugins/ifupdown/plugin.c b/system-settings/plugins/ifupdown/plugin.c index 4a07022c4..34f724cca 100644 --- a/system-settings/plugins/ifupdown/plugin.c +++ b/system-settings/plugins/ifupdown/plugin.c @@ -177,7 +177,7 @@ sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class) } static void -ignore_cb (NMSettingsConnectionInterface *connection, +ignore_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data) { @@ -227,9 +227,9 @@ bind_device_to_connection (SCPluginIfupdown *self, } g_byte_array_free (mac_address, TRUE); - nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (exported), - ignore_cb, - NULL); + nm_sysconfig_connection_commit_changes (NM_SYSCONFIG_CONNECTION (exported), + ignore_cb, + NULL); } static void @@ -366,9 +366,9 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) /* Remove any connection for this block that was previously found */ exported = g_hash_table_lookup (priv->iface_connections, block->name); if (exported) { - nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (exported), - ignore_cb, - NULL); + nm_sysconfig_connection_delete (NM_SYSCONFIG_CONNECTION (exported), + ignore_cb, + NULL); g_hash_table_remove (priv->iface_connections, block->name); } @@ -397,9 +397,9 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) setting = NM_SETTING (nm_connection_get_setting (NM_CONNECTION (exported), NM_TYPE_SETTING_CONNECTION)); g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL); - nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (exported), - ignore_cb, - NULL); + nm_sysconfig_connection_commit_changes (NM_SYSCONFIG_CONNECTION (exported), + ignore_cb, + NULL); PLUGIN_PRINT("SCPlugin-Ifupdown", "autoconnect"); } diff --git a/system-settings/plugins/keyfile/nm-keyfile-connection.c b/system-settings/plugins/keyfile/nm-keyfile-connection.c index b5e5b5c14..9594d64f8 100644 --- a/system-settings/plugins/keyfile/nm-keyfile-connection.c +++ b/system-settings/plugins/keyfile/nm-keyfile-connection.c @@ -24,20 +24,13 @@ #include #include #include -#include #include "nm-dbus-glib-types.h" #include "nm-keyfile-connection.h" #include "reader.h" #include "writer.h" -static NMSettingsConnectionInterface *parent_settings_connection_iface; - -static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); - -G_DEFINE_TYPE_EXTENDED (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SYSCONFIG_CONNECTION, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, - settings_connection_interface_init)) +G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SYSCONFIG_CONNECTION) #define NM_KEYFILE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionPrivate)) @@ -70,10 +63,10 @@ nm_keyfile_connection_get_filename (NMKeyfileConnection *self) return NM_KEYFILE_CONNECTION_GET_PRIVATE (self)->filename; } -static gboolean -update (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceUpdateFunc callback, - gpointer user_data) +static void +commit_changes (NMSysconfigConnection *connection, + NMSysconfigConnectionCommitFunc callback, + gpointer user_data) { NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection); char *filename = NULL; @@ -82,7 +75,7 @@ update (NMSettingsConnectionInterface *connection, if (!write_connection (NM_CONNECTION (connection), KEYFILE_DIR, 0, 0, &filename, &error)) { callback (connection, error, user_data); g_clear_error (&error); - return FALSE; + return; } if (g_strcmp0 (priv->filename, filename)) { @@ -92,31 +85,27 @@ update (NMSettingsConnectionInterface *connection, } else g_free (filename); - return parent_settings_connection_iface->update (connection, callback, user_data); + NM_SYSCONFIG_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection, + callback, + user_data); } -static gboolean -do_delete (NMSettingsConnectionInterface *connection, - NMSettingsConnectionInterfaceDeleteFunc callback, - gpointer user_data) +static void +do_delete (NMSysconfigConnection *connection, + NMSysconfigConnectionDeleteFunc callback, + gpointer user_data) { NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection); g_unlink (priv->filename); - return parent_settings_connection_iface->delete (connection, callback, user_data); + NM_SYSCONFIG_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->delete (connection, + callback, + user_data); } /* GObject */ -static void -settings_connection_interface_init (NMSettingsConnectionInterface *iface) -{ - parent_settings_connection_iface = g_type_interface_peek_parent (iface); - iface->update = update; - iface->delete = do_delete; -} - static void nm_keyfile_connection_init (NMKeyfileConnection *connection) { @@ -221,6 +210,7 @@ static void nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class) { GObjectClass *object_class = G_OBJECT_CLASS (keyfile_connection_class); + NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (keyfile_connection_class); g_type_class_add_private (keyfile_connection_class, sizeof (NMKeyfileConnectionPrivate)); @@ -229,6 +219,8 @@ nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_c object_class->set_property = set_property; object_class->get_property = get_property; object_class->finalize = finalize; + sysconfig_class->commit_changes = commit_changes; + sysconfig_class->delete = do_delete; /* Properties */ g_object_class_install_property diff --git a/system-settings/plugins/keyfile/plugin.c b/system-settings/plugins/keyfile/plugin.c index 5b82b5b6f..19cadc48d 100644 --- a/system-settings/plugins/keyfile/plugin.c +++ b/system-settings/plugins/keyfile/plugin.c @@ -125,7 +125,7 @@ find_by_uuid (gpointer key, gpointer data, gpointer user_data) } static void -update_connection_settings_commit_cb (NMSettingsConnectionInterface *orig, GError *error, gpointer user_data) { +update_connection_settings_commit_cb (NMSysconfigConnection *orig, GError *error, gpointer user_data) { if (error) { g_warning ("%s: '%s' / '%s' invalid: %d", __func__,