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.
This commit is contained in:
Daniel Gnoutcheff
2010-08-05 18:25:15 -04:00
parent bbd4c23213
commit 7f8dc06dff
22 changed files with 463 additions and 589 deletions

View File

@@ -33,7 +33,6 @@
#include <nm-setting-pppoe.h>
#include <nm-setting-wireless-security.h>
#include <nm-setting-8021x.h>
#include <nm-settings-connection-interface.h>
#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

View File

@@ -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",

View File

@@ -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,

View File

@@ -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");
}

View File

@@ -24,20 +24,13 @@
#include <NetworkManager.h>
#include <nm-setting-connection.h>
#include <nm-utils.h>
#include <nm-settings-connection-interface.h>
#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

View File

@@ -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__,