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
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
||||
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
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-utils.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include "nm-settings.h"
|
||||
|
||||
|
||||
@@ -87,85 +88,111 @@ nm_settings_class_init (NMSettingsClass *settings_class)
|
||||
}
|
||||
|
||||
void
|
||||
nm_settings_signal_new_connection (NMSettings *settings, NMConnectionSettings *connection)
|
||||
nm_settings_signal_new_connection (NMSettings *settings, NMExportedConnection *connection)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTINGS (settings));
|
||||
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
|
||||
g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
|
||||
|
||||
g_signal_emit (settings, settings_signals[S_NEW_CONNECTION], 0, connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* NMConnectionSettings implementation
|
||||
* NMExportedConnection implementation
|
||||
*/
|
||||
|
||||
static gboolean impl_connection_settings_get_id (NMConnectionSettings *connection,
|
||||
static gboolean impl_exported_connection_get_id (NMExportedConnection *connection,
|
||||
gchar **id,
|
||||
GError **error);
|
||||
static gboolean impl_connection_settings_get_settings (NMConnectionSettings *connection,
|
||||
static gboolean impl_exported_connection_get_settings (NMExportedConnection *connection,
|
||||
GHashTable **settings,
|
||||
GError **error);
|
||||
static void impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
||||
static void impl_exported_connection_get_secrets (NMExportedConnection *connection,
|
||||
const gchar *setting_name,
|
||||
const gchar **hints,
|
||||
gboolean request_new,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
#include "nm-settings-connection-glue.h"
|
||||
#include "nm-exported-connection-glue.h"
|
||||
|
||||
#define CONNECTION_SETTINGS_CLASS(o) (NM_CONNECTION_SETTINGS_CLASS (G_OBJECT_GET_CLASS (o)))
|
||||
#define EXPORTED_CONNECTION_CLASS(o) (NM_EXPORTED_CONNECTION_CLASS (G_OBJECT_GET_CLASS (o)))
|
||||
|
||||
G_DEFINE_TYPE (NMConnectionSettings, nm_connection_settings, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (NMExportedConnection, nm_exported_connection, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
CS_UPDATED,
|
||||
CS_REMOVED,
|
||||
EC_UPDATED,
|
||||
EC_REMOVED,
|
||||
|
||||
CS_LAST_SIGNAL
|
||||
EC_LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint connection_signals[CS_LAST_SIGNAL] = { 0 };
|
||||
static guint connection_signals[EC_LAST_SIGNAL] = { 0 };
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CONNECTION,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
NMConnection *wrapped;
|
||||
} NMExportedConnectionPrivate;
|
||||
|
||||
#define NM_EXPORTED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
||||
NM_TYPE_EXPORTED_CONNECTION, \
|
||||
NMExportedConnectionPrivate))
|
||||
|
||||
|
||||
static gboolean
|
||||
impl_connection_settings_get_id (NMConnectionSettings *connection,
|
||||
impl_exported_connection_get_id (NMExportedConnection *connection,
|
||||
gchar **id,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), FALSE);
|
||||
NMExportedConnectionPrivate *priv;
|
||||
|
||||
if (!CONNECTION_SETTINGS_CLASS (connection)->get_id) {
|
||||
g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), FALSE);
|
||||
|
||||
priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection);
|
||||
if (!EXPORTED_CONNECTION_CLASS (connection)->get_id) {
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (priv->wrapped, NM_TYPE_SETTING_CONNECTION));
|
||||
if (!s_con || !s_con->id) {
|
||||
g_set_error (error, NM_SETTINGS_ERROR, 1,
|
||||
"%s.%d - Missing implementation for ConnectionSettings::get_id.",
|
||||
"%s.%d - Invalid connection.",
|
||||
__FILE__, __LINE__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*id = CONNECTION_SETTINGS_CLASS (connection)->get_id (connection);
|
||||
*id = g_strdup (s_con->id);
|
||||
} else {
|
||||
*id = EXPORTED_CONNECTION_CLASS (connection)->get_id (connection);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_connection_settings_get_settings (NMConnectionSettings *connection,
|
||||
impl_exported_connection_get_settings (NMExportedConnection *connection,
|
||||
GHashTable **settings,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), FALSE);
|
||||
NMExportedConnectionPrivate *priv;
|
||||
|
||||
if (!CONNECTION_SETTINGS_CLASS (connection)->get_settings) {
|
||||
g_set_error (error, NM_SETTINGS_ERROR, 1,
|
||||
"%s.%d - Missing implementation for ConnectionSettings::get_settings.",
|
||||
__FILE__, __LINE__);
|
||||
return FALSE;
|
||||
}
|
||||
g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), FALSE);
|
||||
|
||||
*settings = CONNECTION_SETTINGS_CLASS (connection)->get_settings (connection);
|
||||
priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
if (!EXPORTED_CONNECTION_CLASS (connection)->get_settings)
|
||||
*settings = nm_connection_to_hash (priv->wrapped);
|
||||
else
|
||||
*settings = EXPORTED_CONNECTION_CLASS (connection)->get_settings (connection);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
||||
impl_exported_connection_get_secrets (NMExportedConnection *connection,
|
||||
const gchar *setting_name,
|
||||
const gchar **hints,
|
||||
gboolean request_new,
|
||||
@@ -173,7 +200,7 @@ impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!NM_IS_CONNECTION_SETTINGS (connection)) {
|
||||
if (!NM_IS_EXPORTED_CONNECTION (connection)) {
|
||||
g_set_error (&error, NM_SETTINGS_ERROR, 1,
|
||||
"%s.%d - Invalid connection in ConnectionSettings::get_secrets.",
|
||||
__FILE__, __LINE__);
|
||||
@@ -182,7 +209,7 @@ impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CONNECTION_SETTINGS_CLASS (connection)->get_secrets) {
|
||||
if (!EXPORTED_CONNECTION_CLASS (connection)->get_secrets) {
|
||||
g_set_error (&error, NM_SETTINGS_ERROR, 1,
|
||||
"%s.%d - Missing implementation for ConnectionSettings::get_secrets.",
|
||||
__FILE__, __LINE__);
|
||||
@@ -191,109 +218,161 @@ impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
||||
return;
|
||||
}
|
||||
|
||||
CONNECTION_SETTINGS_CLASS (connection)->get_secrets (connection, setting_name, hints, request_new, context);
|
||||
EXPORTED_CONNECTION_CLASS (connection)->get_secrets (connection, setting_name, hints, request_new, context);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_connection_settings_init (NMConnectionSettings *connection)
|
||||
nm_exported_connection_init (NMExportedConnection *connection)
|
||||
{
|
||||
static guint32 cs_counter = 0;
|
||||
|
||||
connection->dbus_path = g_strdup_printf ("%s/%u",
|
||||
NM_DBUS_PATH_SETTINGS,
|
||||
cs_counter++);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_connection_settings_dispose (GObject *object)
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMConnectionSettings * self = NM_CONNECTION_SETTINGS (object);
|
||||
NMExportedConnectionPrivate *priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (object);
|
||||
|
||||
if (self->dbus_path) {
|
||||
g_free (self->dbus_path);
|
||||
self->dbus_path = NULL;
|
||||
switch (prop_id) {
|
||||
case PROP_CONNECTION:
|
||||
if (priv->wrapped)
|
||||
g_object_unref (priv->wrapped);
|
||||
priv->wrapped = g_value_get_object (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)
|
||||
{
|
||||
NMExportedConnection *exported = NM_EXPORTED_CONNECTION (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_object (value, nm_exported_connection_get_connection (exported));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_exported_connection_dispose (GObject *object)
|
||||
{
|
||||
NMExportedConnectionPrivate *priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (object);
|
||||
|
||||
if (priv->wrapped) {
|
||||
g_object_unref (priv->wrapped);
|
||||
priv->wrapped = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (nm_connection_settings_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_connection_settings_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (nm_connection_settings_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (nm_exported_connection_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
#define DBUS_TYPE_G_STRING_VARIANT_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
|
||||
#define DBUS_TYPE_G_DICT_OF_DICTS (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE))
|
||||
|
||||
static void
|
||||
nm_connection_settings_class_init (NMConnectionSettingsClass *connection_settings_class)
|
||||
nm_exported_connection_class_init (NMExportedConnectionClass *exported_connection_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (connection_settings_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (exported_connection_class);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (NMExportedConnectionPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = nm_connection_settings_finalize;
|
||||
object_class->dispose = nm_connection_settings_dispose;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = nm_exported_connection_dispose;
|
||||
|
||||
connection_settings_class->get_id = NULL;
|
||||
connection_settings_class->get_settings = NULL;
|
||||
connection_settings_class->get_secrets = NULL;
|
||||
exported_connection_class->get_id = NULL;
|
||||
exported_connection_class->get_settings = NULL;
|
||||
exported_connection_class->get_secrets = NULL;
|
||||
|
||||
/* Properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CONNECTION,
|
||||
g_param_spec_object (NM_EXPORTED_CONNECTION_CONNECTION,
|
||||
"Connection",
|
||||
"Wrapped connection",
|
||||
NM_TYPE_CONNECTION,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/* signals */
|
||||
connection_signals[CS_UPDATED] =
|
||||
connection_signals[EC_UPDATED] =
|
||||
g_signal_new ("updated",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMConnectionSettingsClass, updated),
|
||||
G_STRUCT_OFFSET (NMExportedConnectionClass, updated),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__POINTER,
|
||||
G_TYPE_NONE, 1,
|
||||
DBUS_TYPE_G_DICT_OF_DICTS);
|
||||
connection_signals[CS_REMOVED] =
|
||||
|
||||
connection_signals[EC_REMOVED] =
|
||||
g_signal_new ("removed",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMConnectionSettingsClass, removed),
|
||||
G_STRUCT_OFFSET (NMExportedConnectionClass, removed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (connection_settings_class),
|
||||
&dbus_glib_nm_connection_settings_object_info);
|
||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (exported_connection_class),
|
||||
&dbus_glib_nm_exported_connection_object_info);
|
||||
}
|
||||
|
||||
NMConnection *
|
||||
nm_exported_connection_get_connection (NMExportedConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), NULL);
|
||||
|
||||
return NM_EXPORTED_CONNECTION_GET_PRIVATE (connection)->wrapped;
|
||||
}
|
||||
|
||||
void
|
||||
nm_connection_settings_register_object (NMConnectionSettings *connection,
|
||||
nm_exported_connection_register_object (NMExportedConnection *connection,
|
||||
NMConnectionScope scope,
|
||||
DBusGConnection *dbus_connection)
|
||||
{
|
||||
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
|
||||
NMExportedConnectionPrivate *priv;
|
||||
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
||||
static guint32 ec_counter = 0;
|
||||
char *path;
|
||||
|
||||
g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
|
||||
g_return_if_fail (dbus_connection != NULL);
|
||||
|
||||
priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
g_static_mutex_lock (&mutex);
|
||||
path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++);
|
||||
g_static_mutex_unlock (&mutex);
|
||||
|
||||
nm_connection_set_path (priv->wrapped, path);
|
||||
nm_connection_set_scope (priv->wrapped, scope);
|
||||
|
||||
dbus_g_connection_register_g_object (dbus_connection,
|
||||
connection->dbus_path,
|
||||
path,
|
||||
G_OBJECT (connection));
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), NULL);
|
||||
|
||||
return connection->dbus_path;
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
void
|
||||
nm_connection_settings_signal_updated (NMConnectionSettings *connection, GHashTable *settings)
|
||||
nm_exported_connection_signal_updated (NMExportedConnection *connection, GHashTable *settings)
|
||||
{
|
||||
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
|
||||
g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
|
||||
|
||||
g_signal_emit (connection, connection_signals[CS_UPDATED], 0, settings);
|
||||
g_signal_emit (connection, connection_signals[EC_UPDATED], 0, settings);
|
||||
}
|
||||
|
||||
void
|
||||
nm_connection_settings_signal_removed (NMConnectionSettings *connection)
|
||||
nm_exported_connection_signal_removed (NMExportedConnection *connection)
|
||||
{
|
||||
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
|
||||
g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
|
||||
|
||||
g_signal_emit (connection, connection_signals[CS_REMOVED], 0);
|
||||
g_signal_emit (connection, connection_signals[EC_REMOVED], 0);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
#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_connection_settings_get_type (void);
|
||||
void
|
||||
nm_connection_settings_register_object (NMConnectionSettings *connection,
|
||||
GType nm_exported_connection_get_type (void);
|
||||
|
||||
void nm_exported_connection_register_object (NMExportedConnection *connection,
|
||||
NMConnectionScope scope,
|
||||
DBusGConnection *dbus_connection);
|
||||
const char *nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection);
|
||||
|
||||
NMConnection *nm_exported_connection_get_connection (NMExportedConnection *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;
|
||||
|
124
src/nm-manager.c
124
src/nm-manager.c
@@ -41,19 +41,19 @@ static gboolean impl_manager_legacy_state (NMManager *manager, guint32 *state, G
|
||||
|
||||
#include "nm-manager-glue.h"
|
||||
|
||||
static void nm_manager_connections_destroy (NMManager *manager, NMConnectionType type);
|
||||
static void nm_manager_connections_destroy (NMManager *manager, NMConnectionScope scope);
|
||||
static void manager_set_wireless_enabled (NMManager *manager, gboolean enabled);
|
||||
|
||||
static void connection_added_default_handler (NMManager *manager,
|
||||
NMConnection *connection,
|
||||
NMConnectionType connection_type);
|
||||
NMConnectionScope scope);
|
||||
|
||||
#define SSD_POKE_INTERVAL 120000
|
||||
|
||||
typedef struct {
|
||||
DBusGMethodInvocation *context;
|
||||
NMDevice *device;
|
||||
NMConnectionType connection_type;
|
||||
NMConnectionScope scope;
|
||||
char *connection_path;
|
||||
char *specific_object_path;
|
||||
guint timeout_id;
|
||||
@@ -249,11 +249,11 @@ finalize (GObject *object)
|
||||
while (g_slist_length (priv->devices))
|
||||
nm_manager_remove_device (manager, NM_DEVICE (priv->devices->data), TRUE);
|
||||
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_USER);
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_USER);
|
||||
g_hash_table_destroy (priv->user_connections);
|
||||
priv->user_connections = NULL;
|
||||
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_SYSTEM);
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||
g_hash_table_destroy (priv->system_connections);
|
||||
priv->system_connections = NULL;
|
||||
|
||||
@@ -431,17 +431,17 @@ nm_manager_class_init (NMManagerClass *manager_class)
|
||||
#define DBUS_TYPE_G_STRING_VARIANT_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
|
||||
#define DBUS_TYPE_G_DICT_OF_DICTS (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE))
|
||||
|
||||
static NMConnectionType
|
||||
static NMConnectionScope
|
||||
get_type_for_proxy (DBusGProxy *proxy)
|
||||
{
|
||||
const char *bus_name = dbus_g_proxy_get_bus_name (proxy);
|
||||
|
||||
if (strcmp (bus_name, NM_DBUS_SERVICE_USER_SETTINGS) == 0)
|
||||
return NM_CONNECTION_TYPE_USER;
|
||||
return NM_CONNECTION_SCOPE_USER;
|
||||
else if (strcmp (bus_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0)
|
||||
return NM_CONNECTION_TYPE_SYSTEM;
|
||||
return NM_CONNECTION_SCOPE_SYSTEM;
|
||||
|
||||
return NM_CONNECTION_TYPE_UNKNOWN;
|
||||
return NM_CONNECTION_SCOPE_UNKNOWN;
|
||||
}
|
||||
|
||||
typedef struct GetSettingsInfo {
|
||||
@@ -493,7 +493,7 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
||||
GError *err = NULL;
|
||||
GHashTable *settings = NULL;
|
||||
NMConnection *connection;
|
||||
NMConnectionType type;
|
||||
NMConnectionScope scope;
|
||||
NMManager *manager;
|
||||
|
||||
g_return_if_fail (info != NULL);
|
||||
@@ -527,14 +527,14 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
|
||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
type = get_type_for_proxy (proxy);
|
||||
switch (type) {
|
||||
case NM_CONNECTION_TYPE_USER:
|
||||
scope = get_type_for_proxy (proxy);
|
||||
switch (scope) {
|
||||
case NM_CONNECTION_SCOPE_USER:
|
||||
g_hash_table_insert (priv->user_connections,
|
||||
g_strdup (path),
|
||||
connection);
|
||||
break;
|
||||
case NM_CONNECTION_TYPE_SYSTEM:
|
||||
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||
g_hash_table_insert (priv->system_connections,
|
||||
g_strdup (path),
|
||||
connection);
|
||||
@@ -547,13 +547,13 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
||||
|
||||
g_object_set_data (G_OBJECT (connection),
|
||||
NM_MANAGER_CONNECTION_TYPE_TAG,
|
||||
GUINT_TO_POINTER (type));
|
||||
GUINT_TO_POINTER (scope));
|
||||
|
||||
/* If the connection-added signal is supposed to be batched, don't
|
||||
* emit the single connection-added here.
|
||||
*/
|
||||
if (!info->calls)
|
||||
g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, type);
|
||||
g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, scope);
|
||||
} else {
|
||||
// FIXME: merge settings? or just replace?
|
||||
nm_warning ("%s (#%d): implement merge settings", __func__, __LINE__);
|
||||
@@ -580,11 +580,11 @@ get_connection_for_proxy (NMManager *manager,
|
||||
*out_path = path;
|
||||
|
||||
switch (get_type_for_proxy (proxy)) {
|
||||
case NM_CONNECTION_TYPE_USER:
|
||||
case NM_CONNECTION_SCOPE_USER:
|
||||
*out_hash = priv->user_connections;
|
||||
connection = g_hash_table_lookup (priv->user_connections, path);
|
||||
break;
|
||||
case NM_CONNECTION_TYPE_SYSTEM:
|
||||
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||
*out_hash = priv->system_connections;
|
||||
connection = g_hash_table_lookup (priv->system_connections, path);
|
||||
break;
|
||||
@@ -602,7 +602,7 @@ remove_connection (NMManager *manager,
|
||||
GHashTable *hash,
|
||||
const char *path)
|
||||
{
|
||||
NMConnectionType type;
|
||||
NMConnectionScope scope;
|
||||
|
||||
/* Destroys the connection, then associated DBusGProxy due to the
|
||||
* weak reference notify function placed on the connection when it
|
||||
@@ -610,8 +610,8 @@ remove_connection (NMManager *manager,
|
||||
*/
|
||||
g_object_ref (connection);
|
||||
g_hash_table_remove (hash, path);
|
||||
type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
||||
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, type);
|
||||
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
||||
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
|
||||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
@@ -652,11 +652,11 @@ connection_updated_cb (DBusGProxy *proxy, GHashTable *settings, gpointer user_da
|
||||
|
||||
valid = nm_connection_replace_settings (old_connection, settings);
|
||||
if (valid) {
|
||||
NMConnectionType type;
|
||||
NMConnectionScope scope;
|
||||
|
||||
type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (old_connection),
|
||||
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (old_connection),
|
||||
NM_MANAGER_CONNECTION_TYPE_TAG));
|
||||
g_signal_emit (manager, signals[CONNECTION_UPDATED], 0, old_connection, type);
|
||||
g_signal_emit (manager, signals[CONNECTION_UPDATED], 0, old_connection, scope);
|
||||
} else {
|
||||
remove_connection (manager, old_connection, hash, path);
|
||||
}
|
||||
@@ -771,7 +771,7 @@ new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data)
|
||||
|
||||
static void
|
||||
query_connections (NMManager *manager,
|
||||
NMConnectionType type)
|
||||
NMConnectionScope scope)
|
||||
{
|
||||
NMManagerPrivate *priv;
|
||||
DBusGProxyCall *call;
|
||||
@@ -781,14 +781,14 @@ query_connections (NMManager *manager,
|
||||
g_return_if_fail (NM_IS_MANAGER (manager));
|
||||
|
||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
if (type == NM_CONNECTION_TYPE_USER) {
|
||||
if (scope == NM_CONNECTION_SCOPE_USER) {
|
||||
proxy = &priv->user_proxy;
|
||||
service = NM_DBUS_SERVICE_USER_SETTINGS;
|
||||
} else if (type == NM_CONNECTION_TYPE_SYSTEM) {
|
||||
} else if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
|
||||
proxy = &priv->system_proxy;
|
||||
service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
|
||||
} else {
|
||||
nm_warning ("Unknown NMConnectionType %d", type);
|
||||
nm_warning ("Unknown NMConnectionScope %d", scope);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -839,10 +839,10 @@ nm_manager_name_owner_changed (NMDBusManager *mgr,
|
||||
if (strcmp (name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) {
|
||||
if (!old_owner_good && new_owner_good) {
|
||||
/* User Settings service appeared, update stuff */
|
||||
query_connections (manager, NM_CONNECTION_TYPE_USER);
|
||||
query_connections (manager, NM_CONNECTION_SCOPE_USER);
|
||||
} else {
|
||||
/* User Settings service disappeared, throw them away (?) */
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_USER);
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_USER);
|
||||
}
|
||||
} else if (strcmp (name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0) {
|
||||
if (!old_owner_good && new_owner_good) {
|
||||
@@ -852,10 +852,10 @@ nm_manager_name_owner_changed (NMDBusManager *mgr,
|
||||
}
|
||||
|
||||
/* System Settings service appeared, update stuff */
|
||||
query_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
|
||||
query_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||
} else {
|
||||
/* System Settings service disappeared, throw them away (?) */
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_SYSTEM);
|
||||
nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||
|
||||
if (priv->poke_id)
|
||||
g_source_remove (priv->poke_id);
|
||||
@@ -905,7 +905,7 @@ initial_get_connections (gpointer user_data)
|
||||
|
||||
if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (),
|
||||
NM_DBUS_SERVICE_SYSTEM_SETTINGS)) {
|
||||
query_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
|
||||
query_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||
} else {
|
||||
/* Try to activate the system settings daemon */
|
||||
priv->poke_id = g_idle_add (poke_system_settings_daemon_cb, (gpointer) manager);
|
||||
@@ -913,7 +913,7 @@ initial_get_connections (gpointer user_data)
|
||||
|
||||
if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (),
|
||||
NM_DBUS_SERVICE_USER_SETTINGS))
|
||||
query_connections (manager, NM_CONNECTION_TYPE_USER);
|
||||
query_connections (manager, NM_CONNECTION_SCOPE_USER);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -947,19 +947,19 @@ emit_removed (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
NMManager *manager = NM_MANAGER (user_data);
|
||||
NMConnection *connection = NM_CONNECTION (value);
|
||||
NMConnectionType type;
|
||||
NMConnectionScope scope;
|
||||
|
||||
type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
||||
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, type);
|
||||
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
||||
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_manager_connections_destroy (NMManager *manager,
|
||||
NMConnectionType type)
|
||||
NMConnectionScope scope)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
|
||||
if (type == NM_CONNECTION_TYPE_USER) {
|
||||
if (scope == NM_CONNECTION_SCOPE_USER) {
|
||||
if (priv->user_connections) {
|
||||
g_hash_table_foreach (priv->user_connections, emit_removed, manager);
|
||||
g_hash_table_remove_all (priv->user_connections);
|
||||
@@ -969,7 +969,7 @@ nm_manager_connections_destroy (NMManager *manager,
|
||||
g_object_unref (priv->user_proxy);
|
||||
priv->user_proxy = NULL;
|
||||
}
|
||||
} else if (type == NM_CONNECTION_TYPE_SYSTEM) {
|
||||
} else if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
|
||||
if (priv->system_connections) {
|
||||
g_hash_table_foreach (priv->system_connections, emit_removed, manager);
|
||||
g_hash_table_remove_all (priv->system_connections);
|
||||
@@ -980,7 +980,7 @@ nm_manager_connections_destroy (NMManager *manager,
|
||||
priv->system_proxy = NULL;
|
||||
}
|
||||
} else {
|
||||
nm_warning ("Unknown NMConnectionType %d", type);
|
||||
nm_warning ("Unknown NMConnectionScope %d", scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1051,8 +1051,8 @@ manager_hidden_ap_found (NMDeviceInterface *device,
|
||||
|
||||
/* Look for this AP's BSSID in the seen-bssids list of a connection,
|
||||
* and if a match is found, copy over the SSID */
|
||||
connections = nm_manager_get_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
|
||||
connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_TYPE_USER));
|
||||
connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||
connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_USER));
|
||||
|
||||
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
|
||||
NMConnection *connection = NM_CONNECTION (iter->data);
|
||||
@@ -1234,7 +1234,7 @@ check_connection_allowed (NMManager *manager,
|
||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||
g_return_val_if_fail (s_con != NULL, FALSE);
|
||||
|
||||
system_connections = nm_manager_get_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
|
||||
system_connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||
for (iter = system_connections; iter; iter = g_slist_next (iter)) {
|
||||
NMConnection *system_connection = NM_CONNECTION (iter->data);
|
||||
|
||||
@@ -1357,7 +1357,7 @@ deactivate_old_device (NMManager *manager)
|
||||
static void
|
||||
connection_added_default_handler (NMManager *manager,
|
||||
NMConnection *connection,
|
||||
NMConnectionType connection_type)
|
||||
NMConnectionScope scope)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
PendingConnectionInfo *info = priv->pending_connection_info;
|
||||
@@ -1368,7 +1368,7 @@ connection_added_default_handler (NMManager *manager,
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
if (connection_type != info->connection_type)
|
||||
if (scope != info->scope)
|
||||
return;
|
||||
|
||||
path = nm_manager_get_connection_dbus_path (manager, connection);
|
||||
@@ -1410,7 +1410,7 @@ impl_manager_activate_device (NMManager *manager,
|
||||
DBusGMethodInvocation *context)
|
||||
{
|
||||
NMDevice *device;
|
||||
NMConnectionType connection_type;
|
||||
NMConnectionScope scope;
|
||||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
char *real_sop = NULL;
|
||||
@@ -1426,9 +1426,9 @@ impl_manager_activate_device (NMManager *manager,
|
||||
nm_info ("User request for activation of %s.", nm_device_get_iface (device));
|
||||
|
||||
if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
|
||||
connection_type = NM_CONNECTION_TYPE_USER;
|
||||
scope = NM_CONNECTION_SCOPE_USER;
|
||||
else if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
|
||||
connection_type = NM_CONNECTION_TYPE_SYSTEM;
|
||||
scope = NM_CONNECTION_SCOPE_SYSTEM;
|
||||
else {
|
||||
g_set_error (&error,
|
||||
NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_SERVICE,
|
||||
@@ -1440,7 +1440,7 @@ impl_manager_activate_device (NMManager *manager,
|
||||
if (specific_object_path && strcmp (specific_object_path, "/"))
|
||||
real_sop = g_strdup (specific_object_path);
|
||||
|
||||
connection = nm_manager_get_connection_by_object_path (manager, connection_type, connection_path);
|
||||
connection = nm_manager_get_connection_by_object_path (manager, scope, connection_path);
|
||||
if (connection) {
|
||||
gboolean success;
|
||||
|
||||
@@ -1471,7 +1471,7 @@ impl_manager_activate_device (NMManager *manager,
|
||||
info = g_slice_new0 (PendingConnectionInfo);
|
||||
info->context = context;
|
||||
info->device = g_object_ref (device);
|
||||
info->connection_type = connection_type;
|
||||
info->scope = scope;
|
||||
info->connection_path = g_strdup (connection_path);
|
||||
info->specific_object_path = g_strdup (real_sop);
|
||||
info->timeout_id = g_timeout_add (5000, wait_for_connection_expired, manager);
|
||||
@@ -1513,11 +1513,11 @@ add_one_connection_element (NMManager *manager,
|
||||
type_ptr = g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG);
|
||||
g_return_val_if_fail (type_ptr != NULL, NULL);
|
||||
|
||||
switch ((NMConnectionType) GPOINTER_TO_UINT (type_ptr)) {
|
||||
case NM_CONNECTION_TYPE_USER:
|
||||
switch ((NMConnectionScope) GPOINTER_TO_UINT (type_ptr)) {
|
||||
case NM_CONNECTION_SCOPE_USER:
|
||||
service_name = NM_DBUS_SERVICE_USER_SETTINGS;
|
||||
break;
|
||||
case NM_CONNECTION_TYPE_SYSTEM:
|
||||
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||
service_name = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
|
||||
break;
|
||||
default:
|
||||
@@ -1755,7 +1755,7 @@ connections_to_slist (gpointer key, gpointer value, gpointer user_data)
|
||||
*/
|
||||
GSList *
|
||||
nm_manager_get_connections (NMManager *manager,
|
||||
NMConnectionType type)
|
||||
NMConnectionScope scope)
|
||||
{
|
||||
NMManagerPrivate *priv;
|
||||
GSList *list = NULL;
|
||||
@@ -1763,18 +1763,18 @@ nm_manager_get_connections (NMManager *manager,
|
||||
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
|
||||
|
||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
if (type == NM_CONNECTION_TYPE_USER)
|
||||
if (scope == NM_CONNECTION_SCOPE_USER)
|
||||
g_hash_table_foreach (priv->user_connections, connections_to_slist, &list);
|
||||
else if (type == NM_CONNECTION_TYPE_SYSTEM)
|
||||
else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
|
||||
g_hash_table_foreach (priv->system_connections, connections_to_slist, &list);
|
||||
else
|
||||
nm_warning ("Unknown NMConnectionType %d", type);
|
||||
nm_warning ("Unknown NMConnectionScope %d", scope);
|
||||
return list;
|
||||
}
|
||||
|
||||
NMConnection *
|
||||
nm_manager_get_connection_by_object_path (NMManager *manager,
|
||||
NMConnectionType type,
|
||||
NMConnectionScope scope,
|
||||
const char *path)
|
||||
{
|
||||
NMManagerPrivate *priv;
|
||||
@@ -1784,12 +1784,12 @@ nm_manager_get_connection_by_object_path (NMManager *manager,
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
|
||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
if (type == NM_CONNECTION_TYPE_USER)
|
||||
if (scope == NM_CONNECTION_SCOPE_USER)
|
||||
connection = (NMConnection *) g_hash_table_lookup (priv->user_connections, path);
|
||||
else if (type == NM_CONNECTION_TYPE_SYSTEM)
|
||||
else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
|
||||
connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path);
|
||||
else
|
||||
nm_warning ("Unknown NMConnectionType %d", type);
|
||||
nm_warning ("Unknown NMConnectionScope %d", scope);
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (exported),
|
||||
NM_CONNECTION_SCOPE_SYSTEM,
|
||||
g_conn);
|
||||
|
||||
return settings;
|
||||
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;
|
||||
|
||||
if (item->connection == connection) {
|
||||
wrapped = nm_exported_connection_get_connection (exported);
|
||||
|
||||
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;
|
||||
|
||||
if (item->connection == connection) {
|
||||
wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (item));
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#define NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS (nm_sysconfig_connection_settings_get_type ())
|
||||
#define NM_SYSCONFIG_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettings))
|
||||
#define NM_SYSCONFIG_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettingsClass))
|
||||
#define NM_IS_SYSCONFIG_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS))
|
||||
#define NM_IS_SYSCONFIG_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS))
|
||||
#define NM_SYSCONFIG_CONNECTION_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettingsClass))
|
||||
#define NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION (nm_sysconfig_exported_connection_get_type ())
|
||||
#define NM_SYSCONFIG_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnection))
|
||||
#define NM_SYSCONFIG_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnectionClass))
|
||||
#define NM_IS_SYSCONFIG_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION))
|
||||
#define NM_IS_SYSCONFIG_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION))
|
||||
#define NM_SYSCONFIG_EXPORTED_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnectionClass))
|
||||
|
||||
struct _NMSysconfigConnectionSettings
|
||||
struct _NMSysconfigExportedConnection
|
||||
{
|
||||
NMConnectionSettings parent_instance;
|
||||
|
||||
char *id;
|
||||
NMConnection *connection;
|
||||
NMExportedConnection parent_instance;
|
||||
};
|
||||
|
||||
struct _NMSysconfigConnectionSettingsClass
|
||||
struct _NMSysconfigExportedConnectionClass
|
||||
{
|
||||
NMConnectionSettingsClass parent_class;
|
||||
NMExportedConnectionClass parent_class;
|
||||
};
|
||||
|
||||
GType nm_sysconfig_connection_settings_get_type (void);
|
||||
NMSysconfigConnectionSettings *nm_sysconfig_connection_settings_new (NMConnection *connection,
|
||||
GType nm_sysconfig_exported_connection_get_type (void);
|
||||
NMSysconfigExportedConnection *nm_sysconfig_exported_connection_new (NMConnection *connection,
|
||||
DBusGConnection *g_conn);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user