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

@@ -45,7 +45,6 @@
#include <nm-device-bt.h> #include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h> //#include <nm-device-olpc-mesh.h>
#include <nm-remote-settings.h> #include <nm-remote-settings.h>
#include <nm-settings-connection-interface.h>
#include <nm-vpn-connection.h> #include <nm-vpn-connection.h>
#include "utils.h" #include "utils.h"

View File

@@ -35,7 +35,6 @@
#include <nm-client.h> #include <nm-client.h>
#include <nm-setting-connection.h> #include <nm-setting-connection.h>
#include <nm-remote-settings.h> #include <nm-remote-settings.h>
#include <nm-settings-connection-interface.h>
#include "nmcli.h" #include "nmcli.h"
#include "utils.h" #include "utils.h"

View File

@@ -31,8 +31,6 @@
<xi:include href="xml/nm-object.xml"/> <xi:include href="xml/nm-object.xml"/>
<xi:include href="xml/nm-remote-connection.xml"/> <xi:include href="xml/nm-remote-connection.xml"/>
<xi:include href="xml/nm-remote-settings.xml"/> <xi:include href="xml/nm-remote-settings.xml"/>
<xi:include href="xml/nm-settings-connection-interface.xml"/>
<xi:include href="xml/nm-settings-service.xml"/>
<xi:include href="xml/nm-types.xml"/> <xi:include href="xml/nm-types.xml"/>
<xi:include href="xml/nm-vpn-connection.xml"/> <xi:include href="xml/nm-vpn-connection.xml"/>
<xi:include href="xml/nm-vpn-plugin.xml"/> <xi:include href="xml/nm-vpn-plugin.xml"/>

View File

@@ -76,8 +76,7 @@ libnminclude_HEADERS = \
nm-ip6-config.h \ nm-ip6-config.h \
nm-dhcp6-config.h \ nm-dhcp6-config.h \
nm-remote-connection.h \ nm-remote-connection.h \
nm-remote-settings.h \ nm-remote-settings.h
nm-settings-connection-interface.h
libnm_glib_la_SOURCES = \ libnm_glib_la_SOURCES = \
nm-object.c \ nm-object.c \
@@ -106,8 +105,7 @@ libnm_glib_la_SOURCES = \
nm-dhcp6-config.c \ nm-dhcp6-config.c \
nm-remote-connection.c \ nm-remote-connection.c \
nm-remote-connection-private.h \ nm-remote-connection-private.h \
nm-remote-settings.c \ nm-remote-settings.c
nm-settings-connection-interface.c
libnm_glib_la_LIBADD = \ libnm_glib_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \ $(top_builddir)/libnm-util/libnm-util.la \

View File

@@ -116,6 +116,9 @@ global:
nm_object_get_connection; nm_object_get_connection;
nm_object_get_path; nm_object_get_path;
nm_object_get_type; 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_get_type;
nm_remote_connection_new; nm_remote_connection_new;
nm_remote_settings_add_connection; nm_remote_settings_add_connection;
@@ -128,11 +131,6 @@ global:
nm_serial_device_get_bytes_received; nm_serial_device_get_bytes_received;
nm_serial_device_get_bytes_sent; nm_serial_device_get_bytes_sent;
nm_serial_device_get_type; 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_error_quark;
nm_settings_get_type; nm_settings_get_type;
nm_settings_list_connections; nm_settings_list_connections;

View File

@@ -30,14 +30,10 @@
#include "nm-remote-connection-private.h" #include "nm-remote-connection-private.h"
#include "nm-dbus-glib-types.h" #include "nm-dbus-glib-types.h"
#include "nm-sysconfig-connection-bindings.h" #include "nm-sysconfig-connection-bindings.h"
#include "nm-settings-connection-interface.h"
#define NM_REMOTE_CONNECTION_BUS "bus" #define NM_REMOTE_CONNECTION_BUS "bus"
static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); G_DEFINE_TYPE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION)
G_DEFINE_TYPE_EXTENDED (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, settings_connection_interface_init))
enum { enum {
PROP_0, PROP_0,
@@ -47,6 +43,14 @@ enum {
LAST_PROP LAST_PROP
}; };
enum {
UPDATED,
REMOVED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct { typedef struct {
NMRemoteConnection *self; NMRemoteConnection *self;
@@ -88,22 +92,36 @@ static void
update_cb (DBusGProxy *proxy, GError *error, gpointer user_data) update_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
{ {
RemoteCall *call = 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); remote_call_complete (call->self, call);
} }
static gboolean /**
update (NMSettingsConnectionInterface *connection, * nm_remote_connection_commit_changes:
NMSettingsConnectionInterfaceUpdateFunc callback, * @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) gpointer user_data)
{ {
NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); NMRemoteConnectionPrivate *priv;
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
GHashTable *settings = NULL; GHashTable *settings = NULL;
RemoteCall *call; 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 = g_malloc0 (sizeof (RemoteCall));
call->self = self; call->self = self;
call->callback = (GFunc) callback; call->callback = (GFunc) callback;
@@ -120,29 +138,40 @@ update (NMSettingsConnectionInterface *connection,
priv->calls = g_slist_append (priv->calls, call); priv->calls = g_slist_append (priv->calls, call);
g_hash_table_destroy (settings); g_hash_table_destroy (settings);
return TRUE;
} }
static void static void
delete_cb (DBusGProxy *proxy, GError *error, gpointer user_data) delete_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
{ {
RemoteCall *call = 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); remote_call_complete (call->self, call);
} }
static gboolean /**
do_delete (NMSettingsConnectionInterface *connection, * nm_remote_connection_delete:
NMSettingsConnectionInterfaceDeleteFunc callback, * @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) gpointer user_data)
{ {
NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); NMRemoteConnectionPrivate *priv;
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
RemoteCall *call; 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 = g_malloc0 (sizeof (RemoteCall));
call->self = self; call->self = self;
call->callback = (GFunc) callback; call->callback = (GFunc) callback;
@@ -154,32 +183,47 @@ do_delete (NMSettingsConnectionInterface *connection,
call); call);
g_assert (call->call); g_assert (call->call);
priv->calls = g_slist_append (priv->calls, call); priv->calls = g_slist_append (priv->calls, call);
return TRUE;
} }
static void static void
get_secrets_cb (DBusGProxy *proxy, GHashTable *secrets, GError *error, gpointer user_data) get_secrets_cb (DBusGProxy *proxy, GHashTable *secrets, GError *error, gpointer user_data)
{ {
RemoteCall *call = 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); remote_call_complete (call->self, call);
} }
static gboolean /**
get_secrets (NMSettingsConnectionInterface *connection, * 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 *setting_name,
const char **hints, const char **hints,
gboolean request_new, gboolean request_new,
NMSettingsConnectionInterfaceGetSecretsFunc callback, NMRemoteConnectionGetSecretsFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection); NMRemoteConnectionPrivate *priv;
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
RemoteCall *call; 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 = g_malloc0 (sizeof (RemoteCall));
call->self = self; call->self = self;
call->callback = (GFunc) callback; call->callback = (GFunc) callback;
@@ -194,8 +238,6 @@ get_secrets (NMSettingsConnectionInterface *connection,
call); call);
g_assert (call->call); g_assert (call->call);
priv->calls = g_slist_append (priv->calls, 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 /* Emit update irregardless to let listeners figure out what to do with
* the connection; whether to delete / ignore it or not. * 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; return TRUE;
} }
@@ -257,20 +299,11 @@ updated_cb (DBusGProxy *proxy, GHashTable *settings, gpointer user_data)
static void static void
removed_cb (DBusGProxy *proxy, gpointer user_data) 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: * nm_remote_connection_new:
* @bus: a valid and connected D-Bus connection * @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_ERROR,
NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN, NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN,
G_PARAM_READABLE)); 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);
}

View File

@@ -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_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_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 { typedef struct {
NMConnection parent; NMConnection parent;
} NMRemoteConnection; } NMRemoteConnection;
@@ -45,6 +48,12 @@ typedef struct {
typedef struct { typedef struct {
NMConnectionClass parent_class; NMConnectionClass parent_class;
/* Signals */
void (*updated) (NMRemoteConnection *connection,
GHashTable *new_settings);
void (*removed) (NMRemoteConnection *connection);
/* Padding for future expansion */ /* Padding for future expansion */
void (*_reserved1) (void); void (*_reserved1) (void);
void (*_reserved2) (void); void (*_reserved2) (void);
@@ -54,10 +63,38 @@ typedef struct {
void (*_reserved6) (void); void (*_reserved6) (void);
} NMRemoteConnectionClass; } 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); GType nm_remote_connection_get_type (void);
NMRemoteConnection *nm_remote_connection_new (DBusGConnection *bus, NMRemoteConnection *nm_remote_connection_new (DBusGConnection *bus,
const char *path); 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 G_END_DECLS
#endif /* __NM_REMOTE_CONNECTION__ */ #endif /* __NM_REMOTE_CONNECTION__ */

View File

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

View File

@@ -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 <glib-object.h>
#include <dbus/dbus-glib.h>
#include <nm-connection.h>
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__ */

View File

@@ -757,13 +757,13 @@ remove_connection (NMManager *manager,
/*******************************************************************/ /*******************************************************************/
static void static void
system_connection_updated_cb (NMSettingsConnectionInterface *connection, system_connection_updated_cb (NMSysconfigConnection *connection,
gpointer unused, gpointer unused,
NMManager *manager) NMManager *manager)
{ {
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
const char *path; const char *path;
NMSettingsConnectionInterface *existing; NMSysconfigConnection *existing;
GError *error = NULL; GError *error = NULL;
path = nm_connection_get_path (NM_CONNECTION (connection)); path = nm_connection_get_path (NM_CONNECTION (connection));
@@ -792,7 +792,7 @@ system_connection_updated_cb (NMSettingsConnectionInterface *connection,
} }
static void static void
system_connection_removed_cb (NMSettingsConnectionInterface *connection, system_connection_removed_cb (NMSysconfigConnection *connection,
NMManager *manager) NMManager *manager)
{ {
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
@@ -807,16 +807,16 @@ system_connection_removed_cb (NMSettingsConnectionInterface *connection,
static void static void
system_internal_new_connection (NMManager *manager, system_internal_new_connection (NMManager *manager,
NMSettingsConnectionInterface *connection) NMSysconfigConnection *connection)
{ {
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
const char *path; const char *path;
g_return_if_fail (connection != NULL); 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_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); G_CALLBACK (system_connection_removed_cb), manager);
path = nm_connection_get_path (NM_CONNECTION (connection)); path = nm_connection_get_path (NM_CONNECTION (connection));
@@ -826,7 +826,7 @@ system_internal_new_connection (NMManager *manager,
static void static void
system_new_connection_cb (NMSysconfigSettings *settings, system_new_connection_cb (NMSysconfigSettings *settings,
NMSettingsConnectionInterface *connection, NMSysconfigConnection *connection,
NMManager *manager) NMManager *manager)
{ {
system_internal_new_connection (manager, connection); 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); system_connections = nm_sysconfig_settings_list_connections (priv->sys_settings);
for (iter = system_connections; iter; iter = g_slist_next (iter)) 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); g_slist_free (system_connections);
} }
@@ -1838,7 +1838,7 @@ provider_cancel_secrets (NMSecretsProviderInterface *provider, gpointer user_dat
} }
static void static void
system_get_secrets_reply_cb (NMSettingsConnectionInterface *connection, system_get_secrets_reply_cb (NMSysconfigConnection *connection,
GHashTable *secrets, GHashTable *secrets,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
@@ -1886,7 +1886,7 @@ system_get_secrets_idle_cb (gpointer user_data)
hints[0] = info->hint1; hints[0] = info->hint1;
hints[1] = info->hint2; hints[1] = info->hint2;
nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (connection), nm_sysconfig_connection_get_secrets (connection,
info->setting_name, info->setting_name,
hints, hints,
info->request_new, info->request_new,

View File

@@ -31,15 +31,8 @@
#include "nm-dbus-glib-types.h" #include "nm-dbus-glib-types.h"
#include "nm-marshal.h" #include "nm-marshal.h"
#include "nm-default-wired-connection.h" #include "nm-default-wired-connection.h"
#include "nm-settings-connection-interface.h"
static NMSettingsConnectionInterface *parent_settings_connection_iface; G_DEFINE_TYPE (NMDefaultWiredConnection, nm_default_wired_connection, NM_TYPE_SYSCONFIG_CONNECTION)
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))
#define NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEFAULT_WIRED_CONNECTION, NMDefaultWiredConnectionPrivate)) #define NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEFAULT_WIRED_CONNECTION, NMDefaultWiredConnectionPrivate))
@@ -91,9 +84,9 @@ nm_default_wired_connection_get_device (NMDefaultWiredConnection *wired)
return NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (wired)->device; return NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (wired)->device;
} }
static gboolean static void
update (NMSettingsConnectionInterface *connection, commit_changes (NMSysconfigConnection *connection,
NMSettingsConnectionInterfaceUpdateFunc callback, NMSysconfigConnectionCommitFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection); NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
@@ -105,31 +98,24 @@ update (NMSettingsConnectionInterface *connection,
g_signal_emit (self, signals[TRY_UPDATE], 0); g_signal_emit (self, signals[TRY_UPDATE], 0);
callback (connection, NULL, user_data); callback (connection, NULL, user_data);
g_object_unref (connection); g_object_unref (connection);
return TRUE;
} }
static gboolean static void
do_delete (NMSettingsConnectionInterface *connection, do_delete (NMSysconfigConnection *connection,
NMSettingsConnectionInterfaceDeleteFunc callback, NMSysconfigConnectionDeleteFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection); NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
NMDefaultWiredConnectionPrivate *priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (connection); NMDefaultWiredConnectionPrivate *priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (connection);
g_signal_emit (self, signals[DELETED], 0, priv->mac); 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 static void
nm_default_wired_connection_init (NMDefaultWiredConnection *self) nm_default_wired_connection_init (NMDefaultWiredConnection *self)
{ {
@@ -250,6 +236,7 @@ static void
nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass) nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (klass);
g_type_class_add_private (klass, sizeof (NMDefaultWiredConnectionPrivate)); 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->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
sysconfig_class->commit_changes = commit_changes;
sysconfig_class->delete = do_delete;
/* Properties */ /* Properties */
g_object_class_install_property g_object_class_install_property

View File

@@ -26,7 +26,6 @@
#include "nm-sysconfig-connection.h" #include "nm-sysconfig-connection.h"
#include "nm-system-config-error.h" #include "nm-system-config-error.h"
#include "nm-dbus-glib-types.h" #include "nm-dbus-glib-types.h"
#include "nm-settings-connection-interface.h"
#include "nm-polkit-helpers.h" #include "nm-polkit-helpers.h"
#include "nm-logging.h" #include "nm-logging.h"
@@ -49,16 +48,20 @@ static void impl_sysconfig_connection_get_secrets (NMSysconfigConnection *connec
#include "nm-sysconfig-connection-glue.h" #include "nm-sysconfig-connection-glue.h"
static void settings_connection_interface_init (NMSettingsConnectionInterface *klass); G_DEFINE_TYPE (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_CONNECTION)
G_DEFINE_TYPE_EXTENDED (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_CONNECTION, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
settings_connection_interface_init))
#define NM_SYSCONFIG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ #define NM_SYSCONFIG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
NM_TYPE_SYSCONFIG_CONNECTION, \ NM_TYPE_SYSCONFIG_CONNECTION, \
NMSysconfigConnectionPrivate)) NMSysconfigConnectionPrivate))
enum {
UPDATED,
REMOVED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct { typedef struct {
PolkitAuthority *authority; PolkitAuthority *authority;
GSList *pk_calls; GSList *pk_calls;
@@ -102,7 +105,7 @@ nm_sysconfig_connection_replace_settings (NMSysconfigConnection *self,
} }
static void static void
ignore_cb (NMSettingsConnectionInterface *connection, ignore_cb (NMSysconfigConnection *connection,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
{ {
@@ -116,7 +119,7 @@ ignore_cb (NMSettingsConnectionInterface *connection,
void void
nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self, nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self,
NMConnection *new, NMConnection *new,
NMSettingsConnectionInterfaceUpdateFunc callback, NMSysconfigConnectionCommitFunc callback,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; GError *error = NULL;
@@ -133,43 +136,127 @@ nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self,
if (nm_connection_compare (NM_CONNECTION (self), if (nm_connection_compare (NM_CONNECTION (self),
NM_CONNECTION (new), NM_CONNECTION (new),
NM_SETTING_COMPARE_FLAG_EXACT)) { NM_SETTING_COMPARE_FLAG_EXACT)) {
callback (NM_SETTINGS_CONNECTION_INTERFACE (self), NULL, user_data); callback (self, NULL, user_data);
return; return;
} }
if (nm_sysconfig_connection_replace_settings (self, new, &error)) { if (nm_sysconfig_connection_replace_settings (self, new, &error)) {
nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (self), nm_sysconfig_connection_commit_changes (self, callback, user_data);
callback, user_data);
} else { } else {
callback (NM_SETTINGS_CONNECTION_INTERFACE (self), error, user_data); callback (self, error, user_data);
g_clear_error (&error); 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 static void
update (NMSettingsConnectionInterface *connection, emit_updated (NMSysconfigConnection *connection)
NMSettingsConnectionInterfaceUpdateFunc callback,
gpointer user_data)
{ {
g_object_ref (connection); NMConnection *tmp;
nm_settings_connection_interface_emit_updated (connection); GHashTable *settings;
callback (connection, NULL, user_data);
g_object_unref (connection); tmp = nm_connection_duplicate (NM_CONNECTION (connection));
return TRUE; 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 static void
do_delete (NMSettingsConnectionInterface *connection, commit_changes (NMSysconfigConnection *connection,
NMSettingsConnectionInterfaceDeleteFunc callback, NMSysconfigConnectionCommitFunc callback,
gpointer user_data) gpointer user_data)
{ {
g_object_ref (connection); g_object_ref (connection);
g_signal_emit_by_name (connection, "removed"); 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 (connection, signals[REMOVED], 0);
callback (connection, NULL, user_data); callback (connection, NULL, user_data);
g_object_unref (connection); g_object_unref (connection);
return TRUE;
} }
static GValue * static GValue *
@@ -246,16 +333,15 @@ destroy_gvalue (gpointer data)
g_slice_free (GValue, value); g_slice_free (GValue, value);
} }
static gboolean static void
get_secrets (NMSettingsConnectionInterface *connection, get_secrets (NMSysconfigConnection *connection,
const char *setting_name, const char *setting_name,
const char **hints, const char **hints,
gboolean request_new, gboolean request_new,
NMSettingsConnectionInterfaceGetSecretsFunc callback, NMSysconfigConnectionGetSecretsFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (connection); NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (connection);
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
GHashTable *settings = NULL; GHashTable *settings = NULL;
GHashTable *secrets = NULL; GHashTable *secrets = NULL;
NMSetting *setting; NMSetting *setting;
@@ -273,7 +359,7 @@ get_secrets (NMSettingsConnectionInterface *connection,
__FILE__, __LINE__); __FILE__, __LINE__);
(*callback) (connection, NULL, error, user_data); (*callback) (connection, NULL, error, user_data);
g_error_free (error); g_error_free (error);
return TRUE; return;
} }
setting = nm_connection_get_setting_by_name (priv->secrets, setting_name); setting = nm_connection_get_setting_by_name (priv->secrets, setting_name);
@@ -284,7 +370,7 @@ get_secrets (NMSettingsConnectionInterface *connection,
__FILE__, __LINE__, setting_name); __FILE__, __LINE__, setting_name);
(*callback) (connection, NULL, error, user_data); (*callback) (connection, NULL, error, user_data);
g_error_free (error); g_error_free (error);
return TRUE; return;
} }
/* Returned secrets are a{sa{sv}}; this is the outer a{s...} hash that /* 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); g_hash_table_insert (settings, g_strdup (setting_name), secrets);
callback (connection, settings, NULL, user_data); callback (connection, settings, NULL, user_data);
g_hash_table_destroy (settings); g_hash_table_destroy (settings);
return TRUE;
} }
/**************************************************************/ /**************************************************************/
@@ -420,7 +505,7 @@ polkit_call_free (PolkitCall *call)
} }
static void static void
con_update_cb (NMSettingsConnectionInterface *connection, con_update_cb (NMSysconfigConnection *connection,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
{ {
@@ -533,7 +618,7 @@ impl_sysconfig_connection_update (NMSysconfigConnection *self,
} }
static void static void
con_delete_cb (NMSettingsConnectionInterface *connection, con_delete_cb (NMSysconfigConnection *connection,
GError *error, GError *error,
gpointer user_data) 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 */ /* Caller is authenticated, now we can finally try to delete */
nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (self), nm_sysconfig_connection_delete (self, con_delete_cb, call);
con_delete_cb,
call);
out: out:
g_object_unref (pk_result); g_object_unref (pk_result);
@@ -630,7 +713,7 @@ impl_sysconfig_connection_delete (NMSysconfigConnection *self,
} }
static void static void
con_secrets_cb (NMSettingsConnectionInterface *connection, con_secrets_cb (NMSysconfigConnection *connection,
GHashTable *secrets, GHashTable *secrets,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
@@ -692,7 +775,7 @@ pk_secrets_cb (GObject *object, GAsyncResult *result, gpointer user_data)
} }
/* Caller is authenticated, now we can finally try to update */ /* Caller is authenticated, now we can finally try to update */
nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (self), nm_sysconfig_connection_get_secrets (self,
call->setting_name, call->setting_name,
(const char **) call->hints, (const char **) call->hints,
call->request_new, call->request_new,
@@ -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 static void
nm_sysconfig_connection_init (NMSysconfigConnection *self) nm_sysconfig_connection_init (NMSysconfigConnection *self)
{ {
@@ -779,6 +854,28 @@ nm_sysconfig_connection_class_init (NMSysconfigConnectionClass *class)
/* Virtual methods */ /* Virtual methods */
object_class->dispose = dispose; 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_g_object_type_install_info (G_TYPE_FROM_CLASS (class),
&dbus_glib_nm_sysconfig_connection_object_info); &dbus_glib_nm_sysconfig_connection_object_info);

View File

@@ -22,7 +22,6 @@
#define NM_SYSCONFIG_CONNECTION_H #define NM_SYSCONFIG_CONNECTION_H
#include <nm-connection.h> #include <nm-connection.h>
#include <nm-settings-connection-interface.h>
#include <dbus/dbus-glib.h> #include <dbus/dbus-glib.h>
G_BEGIN_DECLS 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_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)) #define NM_SYSCONFIG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION, NMSysconfigConnectionClass))
typedef struct { #define NM_SYSCONFIG_CONNECTION_UPDATED "updated"
NMConnection parent; #define NM_SYSCONFIG_CONNECTION_REMOVED "removed"
} NMSysconfigConnection;
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; 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); 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, gboolean nm_sysconfig_connection_replace_settings (NMSysconfigConnection *self,
NMConnection *new_settings, NMConnection *new_settings,
GError **error); GError **error);
void nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self, void nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self,
NMConnection *new_settings, NMConnection *new_settings,
NMSettingsConnectionInterfaceUpdateFunc callback, NMSysconfigConnectionCommitFunc callback,
gpointer user_data); 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 G_END_DECLS

View File

@@ -76,7 +76,7 @@ EXPORT(nm_sysconfig_connection_replace_and_commit)
/* END LINKER CRACKROCK */ /* END LINKER CRACKROCK */
static void claim_connection (NMSysconfigSettings *self, static void claim_connection (NMSysconfigSettings *self,
NMSettingsConnectionInterface *connection, NMSysconfigConnection *connection,
gboolean do_export); gboolean do_export);
static gboolean impl_settings_list_connections (NMSysconfigSettings *self, static gboolean impl_settings_list_connections (NMSysconfigSettings *self,
@@ -160,7 +160,7 @@ load_connections (NMSysconfigSettings *self)
// priority plugin. // priority plugin.
for (elt = plugin_connections; elt; elt = g_slist_next (elt)) 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); g_slist_free (plugin_connections);
} }
@@ -342,7 +342,7 @@ nm_sysconfig_settings_get_hostname (NMSysconfigSettings *self)
static void static void
plugin_connection_added (NMSystemConfigInterface *config, plugin_connection_added (NMSystemConfigInterface *config,
NMSettingsConnectionInterface *connection, NMSysconfigConnection *connection,
gpointer user_data) gpointer user_data)
{ {
claim_connection (NM_SYSCONFIG_SETTINGS (user_data), connection, TRUE); claim_connection (NM_SYSCONFIG_SETTINGS (user_data), connection, TRUE);
@@ -531,7 +531,7 @@ load_plugins (NMSysconfigSettings *self, const char *plugins, GError **error)
} }
static void static void
connection_removed (NMSettingsConnectionInterface *connection, connection_removed (NMSysconfigConnection *connection,
gpointer user_data) gpointer user_data)
{ {
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (user_data); NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (user_data);
@@ -541,14 +541,14 @@ connection_removed (NMSettingsConnectionInterface *connection,
static void static void
export_connection (NMSysconfigSettings *self, export_connection (NMSysconfigSettings *self,
NMSettingsConnectionInterface *connection) NMSysconfigConnection *connection)
{ {
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self); NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
static guint32 ec_counter = 0; static guint32 ec_counter = 0;
char *path; char *path;
g_return_if_fail (connection != NULL); 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); g_return_if_fail (priv->bus != NULL);
/* Don't allow exporting twice */ /* Don't allow exporting twice */
@@ -563,13 +563,13 @@ export_connection (NMSysconfigSettings *self,
static void static void
claim_connection (NMSysconfigSettings *self, claim_connection (NMSysconfigSettings *self,
NMSettingsConnectionInterface *connection, NMSysconfigConnection *connection,
gboolean do_export) gboolean do_export)
{ {
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self); NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (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)) if (g_hash_table_lookup (priv->connections, connection))
/* A plugin is lying to us. */ /* 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_hash_table_insert (priv->connections, g_object_ref (connection), GINT_TO_POINTER (1));
g_signal_connect (connection, g_signal_connect (connection,
NM_SETTINGS_CONNECTION_INTERFACE_REMOVED, NM_SYSCONFIG_CONNECTION_REMOVED,
G_CALLBACK (connection_removed), G_CALLBACK (connection_removed),
self); self);
@@ -589,16 +589,13 @@ claim_connection (NMSysconfigSettings *self,
static void static void
remove_connection (NMSysconfigSettings *self, remove_connection (NMSysconfigSettings *self,
NMSettingsConnectionInterface *connection, NMSysconfigConnection *connection,
gboolean do_signal) gboolean do_signal)
{ {
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self); 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)) { 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); g_hash_table_remove (priv->connections, connection);
} }
} }
@@ -1234,7 +1231,7 @@ cleanup:
} }
static void static void
delete_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer user_data) delete_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data)
{ {
} }
@@ -1256,9 +1253,9 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
id = nm_setting_connection_get_id (s_con); id = nm_setting_connection_get_id (s_con);
g_assert (id); 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)) { if (add_new_connection (self, NM_CONNECTION (wired), &error)) {
nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (wired), nm_sysconfig_connection_delete (NM_SYSCONFIG_CONNECTION (wired),
delete_cb, delete_cb,
NULL); NULL);
@@ -1278,7 +1275,7 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
* but add it back to the system settings service. Connection is already * 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. * 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; 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, "try-update", (GCallback) default_wired_try_update, self);
g_signal_connect (wired, "deleted", (GCallback) default_wired_deleted, 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_unref (wired);
g_object_set_data (G_OBJECT (device), DEFAULT_WIRED_TAG, 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); connection = (NMDefaultWiredConnection *) g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_TAG);
if (connection) if (connection)
remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (connection), TRUE); remove_connection (self, NM_SYSCONFIG_CONNECTION (connection), TRUE);
} }
static void static void

View File

@@ -73,7 +73,7 @@ interface_init (gpointer g_iface)
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT, g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
NM_TYPE_SETTINGS_CONNECTION_INTERFACE); NM_TYPE_SYSCONFIG_CONNECTION);
g_signal_new (NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED, g_signal_new (NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED,
iface_type, iface_type,

View File

@@ -25,7 +25,7 @@
#include <glib.h> #include <glib.h>
#include <glib-object.h> #include <glib-object.h>
#include <nm-connection.h> #include <nm-connection.h>
#include <nm-settings-connection-interface.h> #include <nm-sysconfig-connection.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@@ -90,9 +90,9 @@ struct _NMSystemConfigInterface {
/* Called when the plugin is loaded to initialize it */ /* Called when the plugin is loaded to initialize it */
void (*init) (NMSystemConfigInterface *config); void (*init) (NMSystemConfigInterface *config);
/* Returns a GSList of objects that implement NMSettingsConnectionInterface /* Returns a GSList of NMSysconfigConnection objects that represent
* that represent connections the plugin knows about. The returned list * connections the plugin knows about. The returned list is freed by the
* is freed by the system settings service. * system settings service.
*/ */
GSList * (*get_connections) (NMSystemConfigInterface *config); GSList * (*get_connections) (NMSystemConfigInterface *config);
@@ -127,7 +127,7 @@ struct _NMSystemConfigInterface {
/* Emitted when a new connection has been found by the plugin */ /* Emitted when a new connection has been found by the plugin */
void (*connection_added) (NMSystemConfigInterface *config, void (*connection_added) (NMSystemConfigInterface *config,
NMSettingsConnectionInterface *connection); NMSysconfigConnection *connection);
/* Emitted when the list of unmanaged device specifications changes */ /* Emitted when the list of unmanaged device specifications changes */
void (*unmanaged_specs_changed) (NMSystemConfigInterface *config); void (*unmanaged_specs_changed) (NMSystemConfigInterface *config);

View File

@@ -33,7 +33,6 @@
#include <nm-setting-pppoe.h> #include <nm-setting-pppoe.h>
#include <nm-setting-wireless-security.h> #include <nm-setting-wireless-security.h>
#include <nm-setting-8021x.h> #include <nm-setting-8021x.h>
#include <nm-settings-connection-interface.h>
#include "common.h" #include "common.h"
#include "nm-ifcfg-connection.h" #include "nm-ifcfg-connection.h"
@@ -41,13 +40,7 @@
#include "writer.h" #include "writer.h"
#include "nm-inotify-helper.h" #include "nm-inotify-helper.h"
static NMSettingsConnectionInterface *parent_settings_connection_iface; G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SYSCONFIG_CONNECTION)
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))
#define NM_IFCFG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionPrivate)) #define NM_IFCFG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionPrivate))
@@ -171,9 +164,9 @@ nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self)
return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged; return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged;
} }
static gboolean static void
update (NMSettingsConnectionInterface *connection, commit_changes (NMSysconfigConnection *connection,
NMSettingsConnectionInterfaceUpdateFunc callback, NMSysconfigConnectionCommitFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection);
@@ -205,18 +198,18 @@ update (NMSettingsConnectionInterface *connection,
&error)) { &error)) {
callback (connection, error, user_data); callback (connection, error, user_data);
g_error_free (error); g_error_free (error);
return FALSE; return;
} }
out: out:
if (reread) if (reread)
g_object_unref (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 static void
do_delete (NMSettingsConnectionInterface *connection, do_delete (NMSysconfigConnection *connection,
NMSettingsConnectionInterfaceDeleteFunc callback, NMSysconfigConnectionDeleteFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection); NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection);
@@ -230,19 +223,11 @@ do_delete (NMSettingsConnectionInterface *connection,
if (priv->route6file) if (priv->route6file)
g_unlink (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 */ /* 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 static void
nm_ifcfg_connection_init (NMIfcfgConnection *connection) nm_ifcfg_connection_init (NMIfcfgConnection *connection)
{ {
@@ -331,6 +316,7 @@ static void
nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class) nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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)); 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->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
sysconfig_class->delete = do_delete;
sysconfig_class->commit_changes = commit_changes;
/* Properties */ /* Properties */
g_object_class_install_property 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 /* Callback for nm_sysconfig_connection_replace_and_commit. Report any errors
* encountered when commiting connection settings updates. */ * encountered when commiting connection settings updates. */
static void static void
commit_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer unused) commit_cb (NMSysconfigConnection *connection, GError *error, gpointer unused)
{ {
if (error) { if (error) {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error updating: %s", PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error updating: %s",

View File

@@ -32,13 +32,7 @@
#include "nm-ifupdown-connection.h" #include "nm-ifupdown-connection.h"
#include "parser.h" #include "parser.h"
static NMSettingsConnectionInterface *parent_settings_connection_iface; G_DEFINE_TYPE (NMIfupdownConnection, nm_ifupdown_connection, NM_TYPE_SYSCONFIG_CONNECTION)
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))
#define NM_IFUPDOWN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionPrivate)) #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); NULL);
} }
static gboolean static void
get_secrets (NMSettingsConnectionInterface *connection, get_secrets (NMSysconfigConnection *connection,
const gchar *setting_name, const gchar *setting_name,
const gchar **hints, const gchar **hints,
gboolean request_new, gboolean request_new,
NMSettingsConnectionInterfaceGetSecretsFunc callback, NMSysconfigConnectionGetSecretsFunc callback,
gpointer user_data) gpointer user_data)
{ {
GError *error = NULL; GError *error = NULL;
@@ -85,10 +79,10 @@ get_secrets (NMSettingsConnectionInterface *connection,
PLUGIN_PRINT ("SCPlugin-Ifupdown", "%s", error->message); PLUGIN_PRINT ("SCPlugin-Ifupdown", "%s", error->message);
callback (connection, NULL, error, user_data); callback (connection, NULL, error, user_data);
g_error_free (error); g_error_free (error);
return FALSE; return;
} }
return parent_settings_connection_iface->get_secrets (connection, NM_SYSCONFIG_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->get_secrets (connection,
setting_name, setting_name,
hints, hints,
request_new, request_new,
@@ -96,13 +90,6 @@ get_secrets (NMSettingsConnectionInterface *connection,
user_data); 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;
}
static void static void
nm_ifupdown_connection_init (NMIfupdownConnection *connection) nm_ifupdown_connection_init (NMIfupdownConnection *connection)
{ {
@@ -184,6 +171,7 @@ static void
nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class) nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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)); 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->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
connection_class->get_secrets = get_secrets;
/* Properties */ /* Properties */
g_object_class_install_property g_object_class_install_property
(object_class, PROP_IFBLOCK, (object_class, PROP_IFBLOCK,

View File

@@ -177,7 +177,7 @@ sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class)
} }
static void static void
ignore_cb (NMSettingsConnectionInterface *connection, ignore_cb (NMSysconfigConnection *connection,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
{ {
@@ -227,7 +227,7 @@ bind_device_to_connection (SCPluginIfupdown *self,
} }
g_byte_array_free (mac_address, TRUE); g_byte_array_free (mac_address, TRUE);
nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (exported), nm_sysconfig_connection_commit_changes (NM_SYSCONFIG_CONNECTION (exported),
ignore_cb, ignore_cb,
NULL); NULL);
} }
@@ -366,7 +366,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
/* Remove any connection for this block that was previously found */ /* Remove any connection for this block that was previously found */
exported = g_hash_table_lookup (priv->iface_connections, block->name); exported = g_hash_table_lookup (priv->iface_connections, block->name);
if (exported) { if (exported) {
nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (exported), nm_sysconfig_connection_delete (NM_SYSCONFIG_CONNECTION (exported),
ignore_cb, ignore_cb,
NULL); NULL);
g_hash_table_remove (priv->iface_connections, block->name); g_hash_table_remove (priv->iface_connections, block->name);
@@ -397,7 +397,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
setting = NM_SETTING (nm_connection_get_setting (NM_CONNECTION (exported), NM_TYPE_SETTING_CONNECTION)); setting = NM_SETTING (nm_connection_get_setting (NM_CONNECTION (exported), NM_TYPE_SETTING_CONNECTION));
g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL); g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (exported), nm_sysconfig_connection_commit_changes (NM_SYSCONFIG_CONNECTION (exported),
ignore_cb, ignore_cb,
NULL); NULL);

View File

@@ -24,20 +24,13 @@
#include <NetworkManager.h> #include <NetworkManager.h>
#include <nm-setting-connection.h> #include <nm-setting-connection.h>
#include <nm-utils.h> #include <nm-utils.h>
#include <nm-settings-connection-interface.h>
#include "nm-dbus-glib-types.h" #include "nm-dbus-glib-types.h"
#include "nm-keyfile-connection.h" #include "nm-keyfile-connection.h"
#include "reader.h" #include "reader.h"
#include "writer.h" #include "writer.h"
static NMSettingsConnectionInterface *parent_settings_connection_iface; G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SYSCONFIG_CONNECTION)
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))
#define NM_KEYFILE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionPrivate)) #define NM_KEYFILE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionPrivate))
@@ -70,9 +63,9 @@ nm_keyfile_connection_get_filename (NMKeyfileConnection *self)
return NM_KEYFILE_CONNECTION_GET_PRIVATE (self)->filename; return NM_KEYFILE_CONNECTION_GET_PRIVATE (self)->filename;
} }
static gboolean static void
update (NMSettingsConnectionInterface *connection, commit_changes (NMSysconfigConnection *connection,
NMSettingsConnectionInterfaceUpdateFunc callback, NMSysconfigConnectionCommitFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection); NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection);
@@ -82,7 +75,7 @@ update (NMSettingsConnectionInterface *connection,
if (!write_connection (NM_CONNECTION (connection), KEYFILE_DIR, 0, 0, &filename, &error)) { if (!write_connection (NM_CONNECTION (connection), KEYFILE_DIR, 0, 0, &filename, &error)) {
callback (connection, error, user_data); callback (connection, error, user_data);
g_clear_error (&error); g_clear_error (&error);
return FALSE; return;
} }
if (g_strcmp0 (priv->filename, filename)) { if (g_strcmp0 (priv->filename, filename)) {
@@ -92,31 +85,27 @@ update (NMSettingsConnectionInterface *connection,
} else } else
g_free (filename); 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 static void
do_delete (NMSettingsConnectionInterface *connection, do_delete (NMSysconfigConnection *connection,
NMSettingsConnectionInterfaceDeleteFunc callback, NMSysconfigConnectionDeleteFunc callback,
gpointer user_data) gpointer user_data)
{ {
NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection); NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection);
g_unlink (priv->filename); 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 */ /* 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 static void
nm_keyfile_connection_init (NMKeyfileConnection *connection) nm_keyfile_connection_init (NMKeyfileConnection *connection)
{ {
@@ -221,6 +210,7 @@ static void
nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class) nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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)); 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->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
sysconfig_class->commit_changes = commit_changes;
sysconfig_class->delete = do_delete;
/* Properties */ /* Properties */
g_object_class_install_property g_object_class_install_property

View File

@@ -125,7 +125,7 @@ find_by_uuid (gpointer key, gpointer data, gpointer user_data)
} }
static void 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) { if (error) {
g_warning ("%s: '%s' / '%s' invalid: %d", g_warning ("%s: '%s' / '%s' invalid: %d",
__func__, __func__,