Commit fd0ab916 authored by Dan Williams's avatar Dan Williams

2008-02-20 Dan Williams <dcbw@redhat.com>

	* Global rename of NMConnectionSettings -> NMExportedConnection to cut down
		on confusing names

	* Add 'path' and 'scope' properties to NMConnection since both NM and the
		applet were having to hack this in anyway.  Remove the 'path' stuff from
		NMExportedConnection

	* Internally rename NMConnectionType -> NMConnectionScope

	* Provide default implementations of the 'get_id' and 'get_settings' methods
		of NMExportedConnection



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3334 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent ba4da641
2008-02-20 Dan Williams <dcbw@redhat.com>
* Global rename of NMConnectionSettings -> NMExportedConnection to cut down
on confusing names
* Add 'path' and 'scope' properties to NMConnection since both NM and the
applet were having to hack this in anyway. Remove the 'path' stuff from
NMExportedConnection
* Internally rename NMConnectionType -> NMConnectionScope
* Provide default implementations of the 'get_id' and 'get_settings' methods
of NMExportedConnection
2008-02-15 Dan Williams <dcbw@redhat.com>
* src/nm-device-802-11-wireless.c
......
......@@ -7,7 +7,7 @@ EXTRA_DIST = \
nm-manager.xml \
nm-manager-client.xml \
nm-settings.xml \
nm-settings-connection.xml \
nm-exported-connection.xml \
nm-vpn-manager.xml \
nm-vpn-plugin.xml \
nm-vpn-connection.xml
......
......@@ -5,12 +5,12 @@
<interface name="org.freedesktop.NetworkManagerSettings.Connection">
<method name="GetID">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_id"/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_id"/>
<arg name="id" type="s" direction="out"/>
</method>
<method name="GetSettings">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_settings"/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_settings"/>
<arg name="settings" type="a{sa{sv}}" direction="out"/>
</method>
......@@ -27,7 +27,7 @@
<interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets">
<method name="GetSecrets">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_secrets"/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_secrets"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="setting_name" type="s" direction="in"/>
<!-- Array of strings of key names in the Setting for which NM thinks
......
......@@ -8,7 +8,7 @@ BUILT_SOURCES = \
nm-device-802-11-wireless-bindings.h \
nm-marshal.h \
nm-marshal.c \
nm-settings-connection-glue.h \
nm-exported-connection-glue.h \
nm-settings-glue.h \
nm-vpn-manager-bindings.h \
nm-vpn-connection-bindings.h \
......@@ -111,8 +111,8 @@ nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml
nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml
dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=nm-settings-glue.h $(top_srcdir)/introspection/nm-settings.xml
nm-settings-connection-glue.h: $(top_srcdir)/introspection/nm-settings-connection.xml
dbus-binding-tool --prefix=nm_connection_settings --mode=glib-server --output=nm-settings-connection-glue.h $(top_srcdir)/introspection/nm-settings-connection.xml
nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml
dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=nm-exported-connection-glue.h $(top_srcdir)/introspection/nm-exported-connection.xml
nm-vpn-manager-bindings.h: $(top_srcdir)/introspection/nm-vpn-manager.xml
dbus-binding-tool --prefix=nm_vpn_manager --mode=glib-client --output=nm-vpn-manager-bindings.h $(top_srcdir)/introspection/nm-vpn-manager.xml
......
This diff is collapsed.
#ifndef NM_SETTINGS_H
#define NM_SETTINGS_H 1
#ifndef __NM_SETTINGS_H__
#define __NM_SETTINGS_H__
#include <glib-object.h>
#include <dbus/dbus-glib.h>
......@@ -10,46 +10,48 @@ G_BEGIN_DECLS
#define NM_SETTINGS_ERROR nm_settings_error_quark ()
GQuark nm_settings_error_quark (void);
#define NM_TYPE_CONNECTION_SETTINGS (nm_connection_settings_get_type ())
#define NM_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettings))
#define NM_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettingsClass))
#define NM_IS_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_SETTINGS))
#define NM_IS_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CONNECTION_SETTINGS))
#define NM_CONNECTION_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettingsClass))
#define NM_TYPE_EXPORTED_CONNECTION (nm_exported_connection_get_type ())
#define NM_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnection))
#define NM_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
#define NM_IS_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
#define NM_IS_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
#define NM_EXPORTED_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
#define NM_EXPORTED_CONNECTION_CONNECTION "connection"
typedef struct {
GObject parent;
/* private */
char * dbus_path;
} NMConnectionSettings;
} NMExportedConnection;
typedef struct {
GObjectClass parent_class;
/* virtual methods */
gchar * (* get_id) (NMConnectionSettings *connection);
GHashTable * (* get_settings) (NMConnectionSettings *connection);
void (* get_secrets) (NMConnectionSettings *connection,
gchar * (* get_id) (NMExportedConnection *connection);
GHashTable * (* get_settings) (NMExportedConnection *connection);
void (* get_secrets) (NMExportedConnection *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context);
/* signals */
void (* updated) (NMConnectionSettings *connection, GHashTable *settings);
void (* removed) (NMConnectionSettings *connection);
} NMConnectionSettingsClass;
void (* updated) (NMExportedConnection *connection, GHashTable *settings);
void (* removed) (NMExportedConnection *connection);
} NMExportedConnectionClass;
GType nm_exported_connection_get_type (void);
void nm_exported_connection_register_object (NMExportedConnection *connection,
NMConnectionScope scope,
DBusGConnection *dbus_connection);
NMConnection *nm_exported_connection_get_connection (NMExportedConnection *connection);
GType nm_connection_settings_get_type (void);
void
nm_connection_settings_register_object (NMConnectionSettings *connection,
DBusGConnection *dbus_connection);
const char *nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection);
void nm_exported_connection_signal_updated (NMExportedConnection *connection, GHashTable *settings);
void nm_exported_connection_signal_removed (NMExportedConnection *connection);
void nm_connection_settings_signal_updated (NMConnectionSettings *connection, GHashTable *settings);
void nm_connection_settings_signal_removed (NMConnectionSettings *connection);
#define NM_TYPE_SETTINGS (nm_settings_get_type ())
#define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings))
......@@ -69,12 +71,12 @@ typedef struct {
GPtrArray * (* list_connections) (NMSettings *settings);
/* signals */
void (* new_connection) (NMSettings *settings, NMConnectionSettings *connection);
void (* new_connection) (NMSettings *settings, NMExportedConnection *connection);
} NMSettingsClass;
GType nm_settings_get_type (void);
void nm_settings_signal_new_connection (NMSettings *settings, NMConnectionSettings *connection);
void nm_settings_signal_new_connection (NMSettings *settings, NMExportedConnection *connection);
G_END_DECLS
......
......@@ -21,12 +21,26 @@
typedef struct {
GHashTable *settings;
/* Type of the connection (system or user) */
NMConnectionScope scope;
/* D-Bus path of the connection, if any */
char *path;
} NMConnectionPrivate;
#define NM_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONNECTION, NMConnectionPrivate))
G_DEFINE_TYPE (NMConnection, nm_connection, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_SCOPE,
PROP_PATH,
LAST_PROP
};
enum {
SECRETS_UPDATED,
......@@ -471,6 +485,48 @@ nm_connection_dump (NMConnection *connection)
g_hash_table_foreach (NM_CONNECTION_GET_PRIVATE (connection)->settings, dump_setting, NULL);
}
void
nm_connection_set_scope (NMConnection *connection, NMConnectionScope scope)
{
g_return_if_fail (NM_IS_CONNECTION (connection));
NM_CONNECTION_GET_PRIVATE (connection)->scope = scope;
}
NMConnectionScope
nm_connection_get_scope (NMConnection *connection)
{
g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN);
return NM_CONNECTION_GET_PRIVATE (connection)->scope;
}
void
nm_connection_set_path (NMConnection *connection, const char *path)
{
NMConnectionPrivate *priv;
g_return_if_fail (NM_IS_CONNECTION (connection));
priv = NM_CONNECTION_GET_PRIVATE (connection);
if (priv->path) {
g_free (priv->path);
priv->path = NULL;
}
if (path)
priv->path = g_strdup (path);
}
const char *
nm_connection_get_path (NMConnection *connection)
{
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
return NM_CONNECTION_GET_PRIVATE (connection)->path;
}
NMConnection *
nm_connection_new (void)
{
......@@ -522,9 +578,50 @@ finalize (GObject *object)
g_hash_table_destroy (priv->settings);
priv->settings = NULL;
g_free (priv->path);
priv->path = NULL;
G_OBJECT_CLASS (nm_connection_parent_class)->finalize (object);
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMConnection *connection = NM_CONNECTION (object);
switch (prop_id) {
case PROP_SCOPE:
nm_connection_set_scope (connection, g_value_get_uint (value));
break;
case PROP_PATH:
nm_connection_set_path (connection, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMConnection *connection = NM_CONNECTION (object);
switch (prop_id) {
case PROP_SCOPE:
g_value_set_uint (value, nm_connection_get_scope (connection));
break;
case PROP_PATH:
g_value_set_string (value, nm_connection_get_path (connection));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_connection_class_init (NMConnectionClass *klass)
{
......@@ -533,8 +630,29 @@ nm_connection_class_init (NMConnectionClass *klass)
g_type_class_add_private (klass, sizeof (NMConnectionPrivate));
/* virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
/* Properties */
g_object_class_install_property
(object_class, PROP_SCOPE,
g_param_spec_uint (NM_CONNECTION_SCOPE,
"Scope",
"Scope",
NM_CONNECTION_SCOPE_UNKNOWN,
NM_CONNECTION_SCOPE_USER,
NM_CONNECTION_SCOPE_UNKNOWN,
G_PARAM_READWRITE));
g_object_class_install_property
(object_class, PROP_PATH,
g_param_spec_string (NM_CONNECTION_PATH,
"Path",
"Path",
NULL,
G_PARAM_READWRITE));
/* Signals */
signals[SECRETS_UPDATED] =
g_signal_new ("secrets-updated",
......
......@@ -16,6 +16,15 @@ G_BEGIN_DECLS
#define NM_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CONNECTION))
#define NM_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
typedef enum {
NM_CONNECTION_SCOPE_UNKNOWN = 0,
NM_CONNECTION_SCOPE_SYSTEM,
NM_CONNECTION_SCOPE_USER,
} NMConnectionScope;
#define NM_CONNECTION_SCOPE "scope"
#define NM_CONNECTION_PATH "path"
typedef struct {
GObject parent;
} NMConnection;
......@@ -57,6 +66,16 @@ void nm_connection_update_secrets (NMConnection *connection,
const char *setting_name,
GHashTable *secrets);
void nm_connection_set_scope (NMConnection *connection,
NMConnectionScope scope);
NMConnectionScope nm_connection_get_scope (NMConnection *connection);
void nm_connection_set_path (NMConnection *connection,
const char *path);
const char * nm_connection_get_path (NMConnection *connection);
void nm_connection_for_each_setting_value (NMConnection *connection,
NMSettingValueIterFn func,
gpointer user_data);
......
......@@ -97,8 +97,8 @@ nm_policy_auto_get_best_device (NMPolicy *policy,
return NULL;
/* System connections first, then user connections */
connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_SYSTEM);
connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_USER));
connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_SYSTEM);
connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_USER));
/* Remove connections that are in the invalid list. */
elt = connections;
......@@ -321,12 +321,12 @@ nm_policy_device_change_check (gpointer user_data)
* don't switch.
*/
if ( old_connection
&& (nm_manager_get_connection_type (old_connection) == NM_CONNECTION_TYPE_SYSTEM)
&& (nm_manager_get_connection_type (connection) == NM_CONNECTION_TYPE_USER))
&& (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_SYSTEM)
&& (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_USER))
goto out;
if ( (nm_manager_get_connection_type (connection) == NM_CONNECTION_TYPE_SYSTEM)
&& (nm_manager_get_connection_type (old_connection) == NM_CONNECTION_TYPE_USER)) {
if ( (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM)
&& (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_USER)) {
do_switch = TRUE;
nm_info ("SWITCH: found system connection '%s (%s)', overrides"
" current connection '%s (%s)'.",
......@@ -524,7 +524,7 @@ device_removed (NMManager *manager, NMDevice *device, gpointer user_data)
static void
connections_added (NMManager *manager,
NMConnectionType connection_type,
NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
......@@ -535,7 +535,7 @@ connections_added (NMManager *manager,
static void
connection_added (NMManager *manager,
NMConnection *connection,
NMConnectionType connection_type,
NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
......@@ -546,7 +546,7 @@ connection_added (NMManager *manager,
static void
connection_updated (NMManager *manager,
NMConnection *connection,
NMConnectionType connection_type,
NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
......@@ -560,7 +560,7 @@ connection_updated (NMManager *manager,
static void
connection_removed (NMManager *manager,
NMConnection *connection,
NMConnectionType connection_type,
NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
......
This diff is collapsed.
......@@ -22,12 +22,6 @@
#define NM_MANAGER_CONNECTION_TYPE_TAG "service-type"
#define NM_MANAGER_CONNECTION_SECRETS_PROXY_TAG "dbus-secrets-proxy"
typedef enum {
NM_CONNECTION_TYPE_UNKNOWN = 0,
NM_CONNECTION_TYPE_SYSTEM,
NM_CONNECTION_TYPE_USER,
} NMConnectionType;
typedef struct {
GObject parent;
} NMManager;
......@@ -41,19 +35,19 @@ typedef struct {
void (*state_change) (NMManager *manager, guint state);
void (*properties_changed) (NMManager *manager, GHashTable *properties);
void (*connections_added) (NMManager *manager, NMConnectionType type);
void (*connections_added) (NMManager *manager, NMConnectionScope scope);
void (*connection_added) (NMManager *manager,
NMConnection *connection,
NMConnectionType connection_type);
NMConnectionScope scope);
void (*connection_updated) (NMManager *manager,
NMConnection *connection,
NMConnectionType connection_type);
NMConnectionScope scope);
void (*connection_removed) (NMManager *manager,
NMConnection *connection,
NMConnectionType connection_type);
NMConnectionScope scope);
} NMManagerClass;
GType nm_manager_get_type (void);
......@@ -90,23 +84,23 @@ void nm_manager_sleep (NMManager *manager, gboolean sleep);
/* Connections */
GSList *nm_manager_get_connections (NMManager *manager, NMConnectionType type);
GSList *nm_manager_get_connections (NMManager *manager, NMConnectionScope scope);
NMConnection * nm_manager_get_connection_by_object_path (NMManager *manager,
NMConnectionType type,
NMConnectionScope scope,
const char *path);
static inline NMConnectionType
nm_manager_get_connection_type (NMConnection *connection)
static inline NMConnectionScope
nm_manager_get_connection_scope (NMConnection *connection)
{
NMConnectionType type;
NMConnectionScope scope;
g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_TYPE_UNKNOWN);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN);
type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
if (type != NM_CONNECTION_TYPE_USER && type != NM_CONNECTION_TYPE_SYSTEM)
type = NM_CONNECTION_TYPE_UNKNOWN;
return type;
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
if (scope != NM_CONNECTION_SCOPE_USER && scope != NM_CONNECTION_SCOPE_SYSTEM)
scope = NM_CONNECTION_SCOPE_UNKNOWN;
return scope;
}
#endif /* NM_MANAGER_H */
......@@ -145,11 +145,11 @@ impl_vpn_manager_connect (NMVPNManager *manager,
if (!strcmp (connection_type, NM_DBUS_SERVICE_USER_SETTINGS))
connection = nm_manager_get_connection_by_object_path (NM_VPN_MANAGER_GET_PRIVATE (manager)->nm_manager,
NM_CONNECTION_TYPE_USER,
NM_CONNECTION_SCOPE_USER,
connection_path);
else if (!strcmp (connection_type, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
connection = nm_manager_get_connection_by_object_path (NM_VPN_MANAGER_GET_PRIVATE (manager)->nm_manager,
NM_CONNECTION_TYPE_SYSTEM,
NM_CONNECTION_SCOPE_SYSTEM,
connection_path);
if (connection == NULL) {
*err = new_vpn_error ("%s.%d: VPN connection could not be found.",
......
......@@ -30,34 +30,17 @@
#include "nm-system-config-interface.h"
#include "nm-utils.h"
static gchar *connection_settings_get_id (NMConnectionSettings *connection);
static void connection_settings_get_secrets (NMConnectionSettings *connection,
static void exported_connection_get_secrets (NMExportedConnection *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context);
G_DEFINE_TYPE (NMSysconfigConnectionSettings, nm_sysconfig_connection_settings, NM_TYPE_CONNECTION_SETTINGS);
G_DEFINE_TYPE (NMSysconfigExportedConnection, nm_sysconfig_exported_connection, NM_TYPE_EXPORTED_CONNECTION);
/*
* NMSysconfigConnectionSettings
* NMSysconfigExportedConnection
*/
static gchar *
connection_settings_get_id (NMConnectionSettings *connection)
{
NMSysconfigConnectionSettings *c = NM_SYSCONFIG_CONNECTION_SETTINGS (connection);
return g_strdup (c->id);
}
static GHashTable *
connection_settings_get_settings (NMConnectionSettings *connection)
{
NMSysconfigConnectionSettings *c = NM_SYSCONFIG_CONNECTION_SETTINGS (connection);
return nm_connection_to_hash (c->connection);
}
static GValue *
string_to_gvalue (const char *str)
{
......@@ -108,19 +91,21 @@ add_one_secret_to_hash (NMSetting *setting,
}
static void
connection_settings_get_secrets (NMConnectionSettings *sys_connection,
exported_connection_get_secrets (NMExportedConnection *sys_connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context)
{
NMConnection *connection = NM_SYSCONFIG_CONNECTION_SETTINGS (sys_connection)->connection;
NMConnection *connection;
GError *error = NULL;
NMSettingConnection *s_con;
NMSetting *setting;
NMSystemConfigInterface *plugin;
struct AddSecretsData sdata;
connection = nm_exported_connection_get_connection (sys_connection);
g_return_if_fail (NM_IS_CONNECTION (connection));
g_return_if_fail (setting_name != NULL);
......@@ -182,45 +167,43 @@ error:
}
static void
nm_sysconfig_connection_settings_finalize (GObject *object)
nm_sysconfig_exported_connection_finalize (GObject *object)
{
G_OBJECT_CLASS (nm_sysconfig_connection_settings_parent_class)->finalize (object);
G_OBJECT_CLASS (nm_sysconfig_exported_connection_parent_class)->finalize (object);
}
static void
nm_sysconfig_connection_settings_class_init (NMSysconfigConnectionSettingsClass *class)
nm_sysconfig_exported_connection_class_init (NMSysconfigExportedConnectionClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
NMConnectionSettingsClass *connection = NM_CONNECTION_SETTINGS_CLASS (class);
NMExportedConnectionClass *connection = NM_EXPORTED_CONNECTION_CLASS (class);
object_class->finalize = nm_sysconfig_connection_settings_finalize;
object_class->finalize = nm_sysconfig_exported_connection_finalize;
connection->get_id = connection_settings_get_id;
connection->get_settings = connection_settings_get_settings;
connection->get_secrets = connection_settings_get_secrets;
connection->get_secrets = exported_connection_get_secrets;
}
static void
nm_sysconfig_connection_settings_init (NMSysconfigConnectionSettings *sysconfig_connection_settings)
nm_sysconfig_exported_connection_init (NMSysconfigExportedConnection *sysconfig_exported_connection)
{
}
NMSysconfigConnectionSettings *
nm_sysconfig_connection_settings_new (NMConnection *connection,
NMSysconfigExportedConnection *
nm_sysconfig_exported_connection_new (NMConnection *connection,
DBusGConnection *g_conn)
{
NMSysconfigConnectionSettings *settings;
NMSettingConnection *s_con;
NMSysconfigExportedConnection *exported;
settings = g_object_new (nm_sysconfig_connection_settings_get_type(), NULL);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
settings->id = g_strdup (s_con->id);
settings->connection = connection;
exported = g_object_new (NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION,
NM_EXPORTED_CONNECTION_CONNECTION, connection,
NULL);
nm_connection_settings_register_object (NM_CONNECTION_SETTINGS (settings), g_conn);
return settings;
nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (exported),
NM_CONNECTION_SCOPE_SYSTEM,
g_conn);
return exported;
}
/*
......@@ -242,10 +225,12 @@ nm_sysconfig_settings_list_connections (NMSettings *settings)
connections = g_ptr_array_new ();
for (iter = sysconfig_settings->connections; iter; iter = g_slist_next (iter)) {
NMConnectionSettings *connection = NM_CONNECTION_SETTINGS (iter->data);
NMExportedConnection *exported = NM_EXPORTED_CONNECTION (iter->data);
NMConnection *connection;
char *path;
path = g_strdup (nm_connection_settings_get_dbus_object_path (connection));
connection = nm_exported_connection_get_connection (exported);
path = g_strdup (nm_connection_get_path (connection));
if (path)
g_ptr_array_add (connections, path);
}
......@@ -299,12 +284,12 @@ nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
NMConnection *connection,
DBusGConnection *g_connection)
{
NMSysconfigConnectionSettings *exported;
NMSysconfigExportedConnection *exported;
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_CONNECTION (connection));
exported = nm_sysconfig_connection_settings_new (connection, g_connection);
exported = nm_sysconfig_exported_connection_new (connection, g_connection);
if (!exported) {
g_warning ("%s: couldn't export the connection!", __func__);
return;
......@@ -313,7 +298,7 @@ nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
settings->connections = g_slist_append (settings->connections, exported);
nm_settings_signal_new_connection (NM_SETTINGS (settings),
NM_CONNECTION_SETTINGS (exported));
NM_EXPORTED_CONNECTION (exported));
}
static void
......@@ -326,11 +311,15 @@ remove_connection (NMSysconfigSettings *settings,
g_return_if_fail (NM_IS_CONNECTION (connection));
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
NMSysconfigConnectionSettings *item = NM_SYSCONFIG_CONNECTION_SETTINGS (iter->data);
NMSysconfigExportedConnection *item = NM_SYSCONFIG_EXPORTED_CONNECTION (iter->data);
NMExportedConnection *exported = NM_EXPORTED_CONNECTION (item);
NMConnection *wrapped;
wrapped = nm_exported_connection_get_connection (exported);
if (item->connection == connection) {
if (wrapped == connection) {
settings->connections = g_slist_remove (settings->connections, iter);
nm_connection_settings_signal_removed (NM_CONNECTION_SETTINGS (item));
nm_exported_connection_signal_removed (exported);
g_object_unref (item);
g_slist_free (iter);
break;
......@@ -351,15 +340,18 @@ nm_sysconfig_settings_update_connection (NMSysconfigSettings *settings,
{
GHashTable *hash;
GSList *iter;
NMSysconfigConnectionSettings *found = NULL;
NMSysconfigExportedConnection *found = NULL;
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_CONNECTION (connection));
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
NMSysconfigConnectionSettings *item = NM_SYSCONFIG_CONNECTION_SETTINGS (iter->data);
NMSysconfigExportedConnection *item = NM_SYSCONFIG_EXPORTED_CONNECTION (iter->data);
NMConnection *wrapped;
wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (item));
if (item->connection == connection) {
if (wrapped == connection) {
found = item;
break;
}
......@@ -377,7 +369,7 @@ nm_sysconfig_settings_update_connection (NMSysconfigSettings *settings,
}
hash = nm_connection_to_hash (connection);
nm_connection_settings_signal_updated (NM_CONNECTION_SETTINGS (found), hash);
nm_exported_connection_signal_updated (NM_EXPORTED_CONNECTION (found), hash);
g_hash_table_destroy (hash);
}
......@@ -27,35 +27,32 @@
#define NM_SS_PLUGIN_TAG "nm-ss-plugin"
typedef struct _NMSysconfigConnectionSettings NMSysconfigConnectionSettings;
typedef struct _NMSysconfigConnectionSettingsClass NMSysconfigConnectionSettingsClass;
typedef struct _NMSysconfigExportedConnection NMSysconfigExportedConnection;
typedef struct _NMSysconfigExportedConnectionClass NMSysconfigExportedConnectionClass;
/*
* NMSysconfigConnectionSettings
* NMSysconfigExportedConnection