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>
|
2008-02-15 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/nm-device-802-11-wireless.c
|
* src/nm-device-802-11-wireless.c
|
||||||
|
@@ -7,7 +7,7 @@ EXTRA_DIST = \
|
|||||||
nm-manager.xml \
|
nm-manager.xml \
|
||||||
nm-manager-client.xml \
|
nm-manager-client.xml \
|
||||||
nm-settings.xml \
|
nm-settings.xml \
|
||||||
nm-settings-connection.xml \
|
nm-exported-connection.xml \
|
||||||
nm-vpn-manager.xml \
|
nm-vpn-manager.xml \
|
||||||
nm-vpn-plugin.xml \
|
nm-vpn-plugin.xml \
|
||||||
nm-vpn-connection.xml
|
nm-vpn-connection.xml
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
<interface name="org.freedesktop.NetworkManagerSettings.Connection">
|
<interface name="org.freedesktop.NetworkManagerSettings.Connection">
|
||||||
|
|
||||||
<method name="GetID">
|
<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"/>
|
<arg name="id" type="s" direction="out"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<method name="GetSettings">
|
<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"/>
|
<arg name="settings" type="a{sa{sv}}" direction="out"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets">
|
<interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets">
|
||||||
|
|
||||||
<method name="GetSecrets">
|
<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=""/>
|
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||||
<arg name="setting_name" type="s" direction="in"/>
|
<arg name="setting_name" type="s" direction="in"/>
|
||||||
<!-- Array of strings of key names in the Setting for which NM thinks
|
<!-- 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-device-802-11-wireless-bindings.h \
|
||||||
nm-marshal.h \
|
nm-marshal.h \
|
||||||
nm-marshal.c \
|
nm-marshal.c \
|
||||||
nm-settings-connection-glue.h \
|
nm-exported-connection-glue.h \
|
||||||
nm-settings-glue.h \
|
nm-settings-glue.h \
|
||||||
nm-vpn-manager-bindings.h \
|
nm-vpn-manager-bindings.h \
|
||||||
nm-vpn-connection-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
|
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
|
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
|
nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-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
|
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
|
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
|
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 <NetworkManager.h>
|
||||||
#include <nm-utils.h>
|
#include <nm-utils.h>
|
||||||
|
#include <nm-setting-connection.h>
|
||||||
#include "nm-settings.h"
|
#include "nm-settings.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -87,85 +88,111 @@ nm_settings_class_init (NMSettingsClass *settings_class)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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_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);
|
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,
|
gchar **id,
|
||||||
GError **error);
|
GError **error);
|
||||||
static gboolean impl_connection_settings_get_settings (NMConnectionSettings *connection,
|
static gboolean impl_exported_connection_get_settings (NMExportedConnection *connection,
|
||||||
GHashTable **settings,
|
GHashTable **settings,
|
||||||
GError **error);
|
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 *setting_name,
|
||||||
const gchar **hints,
|
const gchar **hints,
|
||||||
gboolean request_new,
|
gboolean request_new,
|
||||||
DBusGMethodInvocation *context);
|
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 {
|
enum {
|
||||||
CS_UPDATED,
|
EC_UPDATED,
|
||||||
CS_REMOVED,
|
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
|
static gboolean
|
||||||
impl_connection_settings_get_id (NMConnectionSettings *connection,
|
impl_exported_connection_get_id (NMExportedConnection *connection,
|
||||||
gchar **id,
|
gchar **id,
|
||||||
GError **error)
|
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);
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, 1,
|
|
||||||
"%s.%d - Missing implementation for ConnectionSettings::get_id.",
|
priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection);
|
||||||
__FILE__, __LINE__);
|
if (!EXPORTED_CONNECTION_CLASS (connection)->get_id) {
|
||||||
return FALSE;
|
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 - Invalid connection.",
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*id = g_strdup (s_con->id);
|
||||||
|
} else {
|
||||||
|
*id = EXPORTED_CONNECTION_CLASS (connection)->get_id (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
*id = CONNECTION_SETTINGS_CLASS (connection)->get_id (connection);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
impl_connection_settings_get_settings (NMConnectionSettings *connection,
|
impl_exported_connection_get_settings (NMExportedConnection *connection,
|
||||||
GHashTable **settings,
|
GHashTable **settings,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), FALSE);
|
NMExportedConnectionPrivate *priv;
|
||||||
|
|
||||||
if (!CONNECTION_SETTINGS_CLASS (connection)->get_settings) {
|
g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), FALSE);
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, 1,
|
|
||||||
"%s.%d - Missing implementation for ConnectionSettings::get_settings.",
|
|
||||||
__FILE__, __LINE__);
|
|
||||||
return 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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
impl_exported_connection_get_secrets (NMExportedConnection *connection,
|
||||||
const gchar *setting_name,
|
const gchar *setting_name,
|
||||||
const gchar **hints,
|
const gchar **hints,
|
||||||
gboolean request_new,
|
gboolean request_new,
|
||||||
@@ -173,7 +200,7 @@ impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!NM_IS_CONNECTION_SETTINGS (connection)) {
|
if (!NM_IS_EXPORTED_CONNECTION (connection)) {
|
||||||
g_set_error (&error, NM_SETTINGS_ERROR, 1,
|
g_set_error (&error, NM_SETTINGS_ERROR, 1,
|
||||||
"%s.%d - Invalid connection in ConnectionSettings::get_secrets.",
|
"%s.%d - Invalid connection in ConnectionSettings::get_secrets.",
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
@@ -182,7 +209,7 @@ impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CONNECTION_SETTINGS_CLASS (connection)->get_secrets) {
|
if (!EXPORTED_CONNECTION_CLASS (connection)->get_secrets) {
|
||||||
g_set_error (&error, NM_SETTINGS_ERROR, 1,
|
g_set_error (&error, NM_SETTINGS_ERROR, 1,
|
||||||
"%s.%d - Missing implementation for ConnectionSettings::get_secrets.",
|
"%s.%d - Missing implementation for ConnectionSettings::get_secrets.",
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
@@ -191,109 +218,161 @@ impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
|||||||
return;
|
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
|
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
|
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) {
|
switch (prop_id) {
|
||||||
g_free (self->dbus_path);
|
case PROP_CONNECTION:
|
||||||
self->dbus_path = NULL;
|
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);
|
G_OBJECT_CLASS (nm_exported_connection_parent_class)->dispose (object);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
nm_connection_settings_finalize (GObject *object)
|
|
||||||
{
|
|
||||||
G_OBJECT_CLASS (nm_connection_settings_parent_class)->finalize (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DBUS_TYPE_G_STRING_VARIANT_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
|
#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))
|
#define DBUS_TYPE_G_DICT_OF_DICTS (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE))
|
||||||
|
|
||||||
static void
|
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 */
|
/* virtual methods */
|
||||||
object_class->finalize = nm_connection_settings_finalize;
|
object_class->set_property = set_property;
|
||||||
object_class->dispose = nm_connection_settings_dispose;
|
object_class->get_property = get_property;
|
||||||
|
object_class->dispose = nm_exported_connection_dispose;
|
||||||
|
|
||||||
connection_settings_class->get_id = NULL;
|
exported_connection_class->get_id = NULL;
|
||||||
connection_settings_class->get_settings = NULL;
|
exported_connection_class->get_settings = NULL;
|
||||||
connection_settings_class->get_secrets = 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 */
|
/* signals */
|
||||||
connection_signals[CS_UPDATED] =
|
connection_signals[EC_UPDATED] =
|
||||||
g_signal_new ("updated",
|
g_signal_new ("updated",
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (NMConnectionSettingsClass, updated),
|
G_STRUCT_OFFSET (NMExportedConnectionClass, updated),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__POINTER,
|
g_cclosure_marshal_VOID__POINTER,
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
DBUS_TYPE_G_DICT_OF_DICTS);
|
DBUS_TYPE_G_DICT_OF_DICTS);
|
||||||
connection_signals[CS_REMOVED] =
|
|
||||||
|
connection_signals[EC_REMOVED] =
|
||||||
g_signal_new ("removed",
|
g_signal_new ("removed",
|
||||||
G_OBJECT_CLASS_TYPE (object_class),
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (NMConnectionSettingsClass, removed),
|
G_STRUCT_OFFSET (NMExportedConnectionClass, removed),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__VOID,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (connection_settings_class),
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (exported_connection_class),
|
||||||
&dbus_glib_nm_connection_settings_object_info);
|
&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
|
void
|
||||||
nm_connection_settings_register_object (NMConnectionSettings *connection,
|
nm_exported_connection_register_object (NMExportedConnection *connection,
|
||||||
|
NMConnectionScope scope,
|
||||||
DBusGConnection *dbus_connection)
|
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);
|
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,
|
dbus_g_connection_register_g_object (dbus_connection,
|
||||||
connection->dbus_path,
|
path,
|
||||||
G_OBJECT (connection));
|
G_OBJECT (connection));
|
||||||
}
|
g_free (path);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nm_connection_settings_signal_updated (NMConnectionSettings *connection, GHashTable *settings)
|
|
||||||
{
|
|
||||||
g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
|
|
||||||
|
|
||||||
g_signal_emit (connection, connection_signals[CS_UPDATED], 0, settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_connection_settings_signal_removed (NMConnectionSettings *connection)
|
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_REMOVED], 0);
|
g_signal_emit (connection, connection_signals[EC_UPDATED], 0, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_exported_connection_signal_removed (NMExportedConnection *connection)
|
||||||
|
{
|
||||||
|
g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
|
||||||
|
|
||||||
|
g_signal_emit (connection, connection_signals[EC_REMOVED], 0);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#ifndef NM_SETTINGS_H
|
#ifndef __NM_SETTINGS_H__
|
||||||
#define NM_SETTINGS_H 1
|
#define __NM_SETTINGS_H__
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
@@ -10,46 +10,48 @@ G_BEGIN_DECLS
|
|||||||
#define NM_SETTINGS_ERROR nm_settings_error_quark ()
|
#define NM_SETTINGS_ERROR nm_settings_error_quark ()
|
||||||
GQuark nm_settings_error_quark (void);
|
GQuark nm_settings_error_quark (void);
|
||||||
|
|
||||||
#define NM_TYPE_CONNECTION_SETTINGS (nm_connection_settings_get_type ())
|
#define NM_TYPE_EXPORTED_CONNECTION (nm_exported_connection_get_type ())
|
||||||
#define NM_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettings))
|
#define NM_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnection))
|
||||||
#define NM_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettingsClass))
|
#define NM_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
|
||||||
#define NM_IS_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_SETTINGS))
|
#define NM_IS_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
|
||||||
#define NM_IS_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CONNECTION_SETTINGS))
|
#define NM_IS_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
|
||||||
#define NM_CONNECTION_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettingsClass))
|
#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 {
|
typedef struct {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
} NMExportedConnection;
|
||||||
/* private */
|
|
||||||
char * dbus_path;
|
|
||||||
} NMConnectionSettings;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
/* virtual methods */
|
/* virtual methods */
|
||||||
gchar * (* get_id) (NMConnectionSettings *connection);
|
gchar * (* get_id) (NMExportedConnection *connection);
|
||||||
GHashTable * (* get_settings) (NMConnectionSettings *connection);
|
GHashTable * (* get_settings) (NMExportedConnection *connection);
|
||||||
void (* get_secrets) (NMConnectionSettings *connection,
|
void (* get_secrets) (NMExportedConnection *connection,
|
||||||
const gchar *setting_name,
|
const gchar *setting_name,
|
||||||
const gchar **hints,
|
const gchar **hints,
|
||||||
gboolean request_new,
|
gboolean request_new,
|
||||||
DBusGMethodInvocation *context);
|
DBusGMethodInvocation *context);
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (* updated) (NMConnectionSettings *connection, GHashTable *settings);
|
void (* updated) (NMExportedConnection *connection, GHashTable *settings);
|
||||||
void (* removed) (NMConnectionSettings *connection);
|
void (* removed) (NMExportedConnection *connection);
|
||||||
} NMConnectionSettingsClass;
|
} NMExportedConnectionClass;
|
||||||
|
|
||||||
GType nm_connection_settings_get_type (void);
|
GType nm_exported_connection_get_type (void);
|
||||||
void
|
|
||||||
nm_connection_settings_register_object (NMConnectionSettings *connection,
|
void nm_exported_connection_register_object (NMExportedConnection *connection,
|
||||||
DBusGConnection *dbus_connection);
|
NMConnectionScope scope,
|
||||||
const char *nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection);
|
DBusGConnection *dbus_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_TYPE_SETTINGS (nm_settings_get_type ())
|
||||||
#define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings))
|
#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);
|
GPtrArray * (* list_connections) (NMSettings *settings);
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (* new_connection) (NMSettings *settings, NMConnectionSettings *connection);
|
void (* new_connection) (NMSettings *settings, NMExportedConnection *connection);
|
||||||
} NMSettingsClass;
|
} NMSettingsClass;
|
||||||
|
|
||||||
GType nm_settings_get_type (void);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
@@ -21,12 +21,26 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GHashTable *settings;
|
GHashTable *settings;
|
||||||
|
|
||||||
|
/* Type of the connection (system or user) */
|
||||||
|
NMConnectionScope scope;
|
||||||
|
|
||||||
|
/* D-Bus path of the connection, if any */
|
||||||
|
char *path;
|
||||||
} NMConnectionPrivate;
|
} NMConnectionPrivate;
|
||||||
|
|
||||||
#define NM_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONNECTION, 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)
|
G_DEFINE_TYPE (NMConnection, nm_connection, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_SCOPE,
|
||||||
|
PROP_PATH,
|
||||||
|
|
||||||
|
LAST_PROP
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SECRETS_UPDATED,
|
SECRETS_UPDATED,
|
||||||
|
|
||||||
@@ -471,6 +485,48 @@ nm_connection_dump (NMConnection *connection)
|
|||||||
g_hash_table_foreach (NM_CONNECTION_GET_PRIVATE (connection)->settings, dump_setting, NULL);
|
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 *
|
NMConnection *
|
||||||
nm_connection_new (void)
|
nm_connection_new (void)
|
||||||
{
|
{
|
||||||
@@ -522,9 +578,50 @@ finalize (GObject *object)
|
|||||||
g_hash_table_destroy (priv->settings);
|
g_hash_table_destroy (priv->settings);
|
||||||
priv->settings = NULL;
|
priv->settings = NULL;
|
||||||
|
|
||||||
|
g_free (priv->path);
|
||||||
|
priv->path = NULL;
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_connection_parent_class)->finalize (object);
|
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
|
static void
|
||||||
nm_connection_class_init (NMConnectionClass *klass)
|
nm_connection_class_init (NMConnectionClass *klass)
|
||||||
{
|
{
|
||||||
@@ -533,8 +630,29 @@ nm_connection_class_init (NMConnectionClass *klass)
|
|||||||
g_type_class_add_private (klass, sizeof (NMConnectionPrivate));
|
g_type_class_add_private (klass, sizeof (NMConnectionPrivate));
|
||||||
|
|
||||||
/* virtual methods */
|
/* virtual methods */
|
||||||
|
object_class->set_property = set_property;
|
||||||
|
object_class->get_property = get_property;
|
||||||
object_class->finalize = finalize;
|
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 */
|
||||||
signals[SECRETS_UPDATED] =
|
signals[SECRETS_UPDATED] =
|
||||||
g_signal_new ("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_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))
|
#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 {
|
typedef struct {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
} NMConnection;
|
} NMConnection;
|
||||||
@@ -57,6 +66,16 @@ void nm_connection_update_secrets (NMConnection *connection,
|
|||||||
const char *setting_name,
|
const char *setting_name,
|
||||||
GHashTable *secrets);
|
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,
|
void nm_connection_for_each_setting_value (NMConnection *connection,
|
||||||
NMSettingValueIterFn func,
|
NMSettingValueIterFn func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
@@ -97,8 +97,8 @@ nm_policy_auto_get_best_device (NMPolicy *policy,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* System connections first, then user connections */
|
/* System connections first, then user connections */
|
||||||
connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_SYSTEM);
|
connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||||
connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_USER));
|
connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_USER));
|
||||||
|
|
||||||
/* Remove connections that are in the invalid list. */
|
/* Remove connections that are in the invalid list. */
|
||||||
elt = connections;
|
elt = connections;
|
||||||
@@ -321,12 +321,12 @@ nm_policy_device_change_check (gpointer user_data)
|
|||||||
* don't switch.
|
* don't switch.
|
||||||
*/
|
*/
|
||||||
if ( old_connection
|
if ( old_connection
|
||||||
&& (nm_manager_get_connection_type (old_connection) == NM_CONNECTION_TYPE_SYSTEM)
|
&& (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_SYSTEM)
|
||||||
&& (nm_manager_get_connection_type (connection) == NM_CONNECTION_TYPE_USER))
|
&& (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_USER))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if ( (nm_manager_get_connection_type (connection) == NM_CONNECTION_TYPE_SYSTEM)
|
if ( (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM)
|
||||||
&& (nm_manager_get_connection_type (old_connection) == NM_CONNECTION_TYPE_USER)) {
|
&& (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_USER)) {
|
||||||
do_switch = TRUE;
|
do_switch = TRUE;
|
||||||
nm_info ("SWITCH: found system connection '%s (%s)', overrides"
|
nm_info ("SWITCH: found system connection '%s (%s)', overrides"
|
||||||
" current connection '%s (%s)'.",
|
" current connection '%s (%s)'.",
|
||||||
@@ -524,7 +524,7 @@ device_removed (NMManager *manager, NMDevice *device, gpointer user_data)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
connections_added (NMManager *manager,
|
connections_added (NMManager *manager,
|
||||||
NMConnectionType connection_type,
|
NMConnectionScope scope,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
NMPolicy *policy = (NMPolicy *) user_data;
|
NMPolicy *policy = (NMPolicy *) user_data;
|
||||||
@@ -535,7 +535,7 @@ connections_added (NMManager *manager,
|
|||||||
static void
|
static void
|
||||||
connection_added (NMManager *manager,
|
connection_added (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type,
|
NMConnectionScope scope,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
NMPolicy *policy = (NMPolicy *) user_data;
|
NMPolicy *policy = (NMPolicy *) user_data;
|
||||||
@@ -546,7 +546,7 @@ connection_added (NMManager *manager,
|
|||||||
static void
|
static void
|
||||||
connection_updated (NMManager *manager,
|
connection_updated (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type,
|
NMConnectionScope scope,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
NMPolicy *policy = (NMPolicy *) user_data;
|
NMPolicy *policy = (NMPolicy *) user_data;
|
||||||
@@ -560,7 +560,7 @@ connection_updated (NMManager *manager,
|
|||||||
static void
|
static void
|
||||||
connection_removed (NMManager *manager,
|
connection_removed (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type,
|
NMConnectionScope scope,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
NMPolicy *policy = (NMPolicy *) 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"
|
#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 manager_set_wireless_enabled (NMManager *manager, gboolean enabled);
|
||||||
|
|
||||||
static void connection_added_default_handler (NMManager *manager,
|
static void connection_added_default_handler (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type);
|
NMConnectionScope scope);
|
||||||
|
|
||||||
#define SSD_POKE_INTERVAL 120000
|
#define SSD_POKE_INTERVAL 120000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DBusGMethodInvocation *context;
|
DBusGMethodInvocation *context;
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
NMConnectionType connection_type;
|
NMConnectionScope scope;
|
||||||
char *connection_path;
|
char *connection_path;
|
||||||
char *specific_object_path;
|
char *specific_object_path;
|
||||||
guint timeout_id;
|
guint timeout_id;
|
||||||
@@ -249,11 +249,11 @@ finalize (GObject *object)
|
|||||||
while (g_slist_length (priv->devices))
|
while (g_slist_length (priv->devices))
|
||||||
nm_manager_remove_device (manager, NM_DEVICE (priv->devices->data), TRUE);
|
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);
|
g_hash_table_destroy (priv->user_connections);
|
||||||
priv->user_connections = NULL;
|
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);
|
g_hash_table_destroy (priv->system_connections);
|
||||||
priv->system_connections = NULL;
|
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_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))
|
#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)
|
get_type_for_proxy (DBusGProxy *proxy)
|
||||||
{
|
{
|
||||||
const char *bus_name = dbus_g_proxy_get_bus_name (proxy);
|
const char *bus_name = dbus_g_proxy_get_bus_name (proxy);
|
||||||
|
|
||||||
if (strcmp (bus_name, NM_DBUS_SERVICE_USER_SETTINGS) == 0)
|
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)
|
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 {
|
typedef struct GetSettingsInfo {
|
||||||
@@ -493,7 +493,7 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
|||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GHashTable *settings = NULL;
|
GHashTable *settings = NULL;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMConnectionType type;
|
NMConnectionScope scope;
|
||||||
NMManager *manager;
|
NMManager *manager;
|
||||||
|
|
||||||
g_return_if_fail (info != NULL);
|
g_return_if_fail (info != NULL);
|
||||||
@@ -527,14 +527,14 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
|||||||
(GDestroyNotify) g_object_unref);
|
(GDestroyNotify) g_object_unref);
|
||||||
|
|
||||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||||
type = get_type_for_proxy (proxy);
|
scope = get_type_for_proxy (proxy);
|
||||||
switch (type) {
|
switch (scope) {
|
||||||
case NM_CONNECTION_TYPE_USER:
|
case NM_CONNECTION_SCOPE_USER:
|
||||||
g_hash_table_insert (priv->user_connections,
|
g_hash_table_insert (priv->user_connections,
|
||||||
g_strdup (path),
|
g_strdup (path),
|
||||||
connection);
|
connection);
|
||||||
break;
|
break;
|
||||||
case NM_CONNECTION_TYPE_SYSTEM:
|
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||||
g_hash_table_insert (priv->system_connections,
|
g_hash_table_insert (priv->system_connections,
|
||||||
g_strdup (path),
|
g_strdup (path),
|
||||||
connection);
|
connection);
|
||||||
@@ -547,13 +547,13 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
|||||||
|
|
||||||
g_object_set_data (G_OBJECT (connection),
|
g_object_set_data (G_OBJECT (connection),
|
||||||
NM_MANAGER_CONNECTION_TYPE_TAG,
|
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
|
/* If the connection-added signal is supposed to be batched, don't
|
||||||
* emit the single connection-added here.
|
* emit the single connection-added here.
|
||||||
*/
|
*/
|
||||||
if (!info->calls)
|
if (!info->calls)
|
||||||
g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, type);
|
g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, scope);
|
||||||
} else {
|
} else {
|
||||||
// FIXME: merge settings? or just replace?
|
// FIXME: merge settings? or just replace?
|
||||||
nm_warning ("%s (#%d): implement merge settings", __func__, __LINE__);
|
nm_warning ("%s (#%d): implement merge settings", __func__, __LINE__);
|
||||||
@@ -580,11 +580,11 @@ get_connection_for_proxy (NMManager *manager,
|
|||||||
*out_path = path;
|
*out_path = path;
|
||||||
|
|
||||||
switch (get_type_for_proxy (proxy)) {
|
switch (get_type_for_proxy (proxy)) {
|
||||||
case NM_CONNECTION_TYPE_USER:
|
case NM_CONNECTION_SCOPE_USER:
|
||||||
*out_hash = priv->user_connections;
|
*out_hash = priv->user_connections;
|
||||||
connection = g_hash_table_lookup (priv->user_connections, path);
|
connection = g_hash_table_lookup (priv->user_connections, path);
|
||||||
break;
|
break;
|
||||||
case NM_CONNECTION_TYPE_SYSTEM:
|
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||||
*out_hash = priv->system_connections;
|
*out_hash = priv->system_connections;
|
||||||
connection = g_hash_table_lookup (priv->system_connections, path);
|
connection = g_hash_table_lookup (priv->system_connections, path);
|
||||||
break;
|
break;
|
||||||
@@ -602,7 +602,7 @@ remove_connection (NMManager *manager,
|
|||||||
GHashTable *hash,
|
GHashTable *hash,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
NMConnectionType type;
|
NMConnectionScope scope;
|
||||||
|
|
||||||
/* Destroys the connection, then associated DBusGProxy due to the
|
/* Destroys the connection, then associated DBusGProxy due to the
|
||||||
* weak reference notify function placed on the connection when it
|
* weak reference notify function placed on the connection when it
|
||||||
@@ -610,8 +610,8 @@ remove_connection (NMManager *manager,
|
|||||||
*/
|
*/
|
||||||
g_object_ref (connection);
|
g_object_ref (connection);
|
||||||
g_hash_table_remove (hash, path);
|
g_hash_table_remove (hash, path);
|
||||||
type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
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, type);
|
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
|
||||||
g_object_unref (connection);
|
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);
|
valid = nm_connection_replace_settings (old_connection, settings);
|
||||||
if (valid) {
|
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));
|
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 {
|
} else {
|
||||||
remove_connection (manager, old_connection, hash, path);
|
remove_connection (manager, old_connection, hash, path);
|
||||||
}
|
}
|
||||||
@@ -771,7 +771,7 @@ new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
query_connections (NMManager *manager,
|
query_connections (NMManager *manager,
|
||||||
NMConnectionType type)
|
NMConnectionScope scope)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv;
|
NMManagerPrivate *priv;
|
||||||
DBusGProxyCall *call;
|
DBusGProxyCall *call;
|
||||||
@@ -781,14 +781,14 @@ query_connections (NMManager *manager,
|
|||||||
g_return_if_fail (NM_IS_MANAGER (manager));
|
g_return_if_fail (NM_IS_MANAGER (manager));
|
||||||
|
|
||||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||||
if (type == NM_CONNECTION_TYPE_USER) {
|
if (scope == NM_CONNECTION_SCOPE_USER) {
|
||||||
proxy = &priv->user_proxy;
|
proxy = &priv->user_proxy;
|
||||||
service = NM_DBUS_SERVICE_USER_SETTINGS;
|
service = NM_DBUS_SERVICE_USER_SETTINGS;
|
||||||
} else if (type == NM_CONNECTION_TYPE_SYSTEM) {
|
} else if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
|
||||||
proxy = &priv->system_proxy;
|
proxy = &priv->system_proxy;
|
||||||
service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
|
service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
|
||||||
} else {
|
} else {
|
||||||
nm_warning ("Unknown NMConnectionType %d", type);
|
nm_warning ("Unknown NMConnectionScope %d", scope);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,10 +839,10 @@ nm_manager_name_owner_changed (NMDBusManager *mgr,
|
|||||||
if (strcmp (name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) {
|
if (strcmp (name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) {
|
||||||
if (!old_owner_good && new_owner_good) {
|
if (!old_owner_good && new_owner_good) {
|
||||||
/* User Settings service appeared, update stuff */
|
/* User Settings service appeared, update stuff */
|
||||||
query_connections (manager, NM_CONNECTION_TYPE_USER);
|
query_connections (manager, NM_CONNECTION_SCOPE_USER);
|
||||||
} else {
|
} else {
|
||||||
/* User Settings service disappeared, throw them away (?) */
|
/* 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) {
|
} else if (strcmp (name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0) {
|
||||||
if (!old_owner_good && new_owner_good) {
|
if (!old_owner_good && new_owner_good) {
|
||||||
@@ -852,10 +852,10 @@ nm_manager_name_owner_changed (NMDBusManager *mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* System Settings service appeared, update stuff */
|
/* System Settings service appeared, update stuff */
|
||||||
query_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
|
query_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||||
} else {
|
} else {
|
||||||
/* System Settings service disappeared, throw them away (?) */
|
/* 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)
|
if (priv->poke_id)
|
||||||
g_source_remove (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 (),
|
if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (),
|
||||||
NM_DBUS_SERVICE_SYSTEM_SETTINGS)) {
|
NM_DBUS_SERVICE_SYSTEM_SETTINGS)) {
|
||||||
query_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
|
query_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||||
} else {
|
} else {
|
||||||
/* Try to activate the system settings daemon */
|
/* Try to activate the system settings daemon */
|
||||||
priv->poke_id = g_idle_add (poke_system_settings_daemon_cb, (gpointer) manager);
|
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 (),
|
if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (),
|
||||||
NM_DBUS_SERVICE_USER_SETTINGS))
|
NM_DBUS_SERVICE_USER_SETTINGS))
|
||||||
query_connections (manager, NM_CONNECTION_TYPE_USER);
|
query_connections (manager, NM_CONNECTION_SCOPE_USER);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -947,19 +947,19 @@ emit_removed (gpointer key, gpointer value, gpointer user_data)
|
|||||||
{
|
{
|
||||||
NMManager *manager = NM_MANAGER (user_data);
|
NMManager *manager = NM_MANAGER (user_data);
|
||||||
NMConnection *connection = NM_CONNECTION (value);
|
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));
|
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, type);
|
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_manager_connections_destroy (NMManager *manager,
|
nm_manager_connections_destroy (NMManager *manager,
|
||||||
NMConnectionType type)
|
NMConnectionScope scope)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||||
|
|
||||||
if (type == NM_CONNECTION_TYPE_USER) {
|
if (scope == NM_CONNECTION_SCOPE_USER) {
|
||||||
if (priv->user_connections) {
|
if (priv->user_connections) {
|
||||||
g_hash_table_foreach (priv->user_connections, emit_removed, manager);
|
g_hash_table_foreach (priv->user_connections, emit_removed, manager);
|
||||||
g_hash_table_remove_all (priv->user_connections);
|
g_hash_table_remove_all (priv->user_connections);
|
||||||
@@ -969,7 +969,7 @@ nm_manager_connections_destroy (NMManager *manager,
|
|||||||
g_object_unref (priv->user_proxy);
|
g_object_unref (priv->user_proxy);
|
||||||
priv->user_proxy = NULL;
|
priv->user_proxy = NULL;
|
||||||
}
|
}
|
||||||
} else if (type == NM_CONNECTION_TYPE_SYSTEM) {
|
} else if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
|
||||||
if (priv->system_connections) {
|
if (priv->system_connections) {
|
||||||
g_hash_table_foreach (priv->system_connections, emit_removed, manager);
|
g_hash_table_foreach (priv->system_connections, emit_removed, manager);
|
||||||
g_hash_table_remove_all (priv->system_connections);
|
g_hash_table_remove_all (priv->system_connections);
|
||||||
@@ -980,7 +980,7 @@ nm_manager_connections_destroy (NMManager *manager,
|
|||||||
priv->system_proxy = NULL;
|
priv->system_proxy = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} 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,
|
/* Look for this AP's BSSID in the seen-bssids list of a connection,
|
||||||
* and if a match is found, copy over the SSID */
|
* and if a match is found, copy over the SSID */
|
||||||
connections = nm_manager_get_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
|
connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
|
||||||
connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_TYPE_USER));
|
connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_USER));
|
||||||
|
|
||||||
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
|
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
|
||||||
NMConnection *connection = NM_CONNECTION (iter->data);
|
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));
|
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||||
g_return_val_if_fail (s_con != NULL, FALSE);
|
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)) {
|
for (iter = system_connections; iter; iter = g_slist_next (iter)) {
|
||||||
NMConnection *system_connection = NM_CONNECTION (iter->data);
|
NMConnection *system_connection = NM_CONNECTION (iter->data);
|
||||||
|
|
||||||
@@ -1357,7 +1357,7 @@ deactivate_old_device (NMManager *manager)
|
|||||||
static void
|
static void
|
||||||
connection_added_default_handler (NMManager *manager,
|
connection_added_default_handler (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type)
|
NMConnectionScope scope)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||||
PendingConnectionInfo *info = priv->pending_connection_info;
|
PendingConnectionInfo *info = priv->pending_connection_info;
|
||||||
@@ -1368,7 +1368,7 @@ connection_added_default_handler (NMManager *manager,
|
|||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (connection_type != info->connection_type)
|
if (scope != info->scope)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path = nm_manager_get_connection_dbus_path (manager, connection);
|
path = nm_manager_get_connection_dbus_path (manager, connection);
|
||||||
@@ -1410,7 +1410,7 @@ impl_manager_activate_device (NMManager *manager,
|
|||||||
DBusGMethodInvocation *context)
|
DBusGMethodInvocation *context)
|
||||||
{
|
{
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
NMConnectionType connection_type;
|
NMConnectionScope scope;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
char *real_sop = 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));
|
nm_info ("User request for activation of %s.", nm_device_get_iface (device));
|
||||||
|
|
||||||
if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
|
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))
|
else if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
|
||||||
connection_type = NM_CONNECTION_TYPE_SYSTEM;
|
scope = NM_CONNECTION_SCOPE_SYSTEM;
|
||||||
else {
|
else {
|
||||||
g_set_error (&error,
|
g_set_error (&error,
|
||||||
NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_SERVICE,
|
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, "/"))
|
if (specific_object_path && strcmp (specific_object_path, "/"))
|
||||||
real_sop = g_strdup (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) {
|
if (connection) {
|
||||||
gboolean success;
|
gboolean success;
|
||||||
|
|
||||||
@@ -1471,7 +1471,7 @@ impl_manager_activate_device (NMManager *manager,
|
|||||||
info = g_slice_new0 (PendingConnectionInfo);
|
info = g_slice_new0 (PendingConnectionInfo);
|
||||||
info->context = context;
|
info->context = context;
|
||||||
info->device = g_object_ref (device);
|
info->device = g_object_ref (device);
|
||||||
info->connection_type = connection_type;
|
info->scope = scope;
|
||||||
info->connection_path = g_strdup (connection_path);
|
info->connection_path = g_strdup (connection_path);
|
||||||
info->specific_object_path = g_strdup (real_sop);
|
info->specific_object_path = g_strdup (real_sop);
|
||||||
info->timeout_id = g_timeout_add (5000, wait_for_connection_expired, manager);
|
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);
|
type_ptr = g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG);
|
||||||
g_return_val_if_fail (type_ptr != NULL, NULL);
|
g_return_val_if_fail (type_ptr != NULL, NULL);
|
||||||
|
|
||||||
switch ((NMConnectionType) GPOINTER_TO_UINT (type_ptr)) {
|
switch ((NMConnectionScope) GPOINTER_TO_UINT (type_ptr)) {
|
||||||
case NM_CONNECTION_TYPE_USER:
|
case NM_CONNECTION_SCOPE_USER:
|
||||||
service_name = NM_DBUS_SERVICE_USER_SETTINGS;
|
service_name = NM_DBUS_SERVICE_USER_SETTINGS;
|
||||||
break;
|
break;
|
||||||
case NM_CONNECTION_TYPE_SYSTEM:
|
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||||
service_name = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
|
service_name = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1755,7 +1755,7 @@ connections_to_slist (gpointer key, gpointer value, gpointer user_data)
|
|||||||
*/
|
*/
|
||||||
GSList *
|
GSList *
|
||||||
nm_manager_get_connections (NMManager *manager,
|
nm_manager_get_connections (NMManager *manager,
|
||||||
NMConnectionType type)
|
NMConnectionScope scope)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv;
|
NMManagerPrivate *priv;
|
||||||
GSList *list = NULL;
|
GSList *list = NULL;
|
||||||
@@ -1763,18 +1763,18 @@ nm_manager_get_connections (NMManager *manager,
|
|||||||
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
|
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
|
||||||
|
|
||||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
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);
|
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);
|
g_hash_table_foreach (priv->system_connections, connections_to_slist, &list);
|
||||||
else
|
else
|
||||||
nm_warning ("Unknown NMConnectionType %d", type);
|
nm_warning ("Unknown NMConnectionScope %d", scope);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
NMConnection *
|
NMConnection *
|
||||||
nm_manager_get_connection_by_object_path (NMManager *manager,
|
nm_manager_get_connection_by_object_path (NMManager *manager,
|
||||||
NMConnectionType type,
|
NMConnectionScope scope,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv;
|
NMManagerPrivate *priv;
|
||||||
@@ -1784,12 +1784,12 @@ nm_manager_get_connection_by_object_path (NMManager *manager,
|
|||||||
g_return_val_if_fail (path != NULL, NULL);
|
g_return_val_if_fail (path != NULL, NULL);
|
||||||
|
|
||||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
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);
|
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);
|
connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path);
|
||||||
else
|
else
|
||||||
nm_warning ("Unknown NMConnectionType %d", type);
|
nm_warning ("Unknown NMConnectionScope %d", scope);
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,12 +22,6 @@
|
|||||||
#define NM_MANAGER_CONNECTION_TYPE_TAG "service-type"
|
#define NM_MANAGER_CONNECTION_TYPE_TAG "service-type"
|
||||||
#define NM_MANAGER_CONNECTION_SECRETS_PROXY_TAG "dbus-secrets-proxy"
|
#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 {
|
typedef struct {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
} NMManager;
|
} NMManager;
|
||||||
@@ -41,19 +35,19 @@ typedef struct {
|
|||||||
void (*state_change) (NMManager *manager, guint state);
|
void (*state_change) (NMManager *manager, guint state);
|
||||||
void (*properties_changed) (NMManager *manager, GHashTable *properties);
|
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,
|
void (*connection_added) (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type);
|
NMConnectionScope scope);
|
||||||
|
|
||||||
void (*connection_updated) (NMManager *manager,
|
void (*connection_updated) (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type);
|
NMConnectionScope scope);
|
||||||
|
|
||||||
void (*connection_removed) (NMManager *manager,
|
void (*connection_removed) (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMConnectionType connection_type);
|
NMConnectionScope scope);
|
||||||
} NMManagerClass;
|
} NMManagerClass;
|
||||||
|
|
||||||
GType nm_manager_get_type (void);
|
GType nm_manager_get_type (void);
|
||||||
@@ -90,23 +84,23 @@ void nm_manager_sleep (NMManager *manager, gboolean sleep);
|
|||||||
|
|
||||||
/* Connections */
|
/* 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,
|
NMConnection * nm_manager_get_connection_by_object_path (NMManager *manager,
|
||||||
NMConnectionType type,
|
NMConnectionScope scope,
|
||||||
const char *path);
|
const char *path);
|
||||||
|
|
||||||
static inline NMConnectionType
|
static inline NMConnectionScope
|
||||||
nm_manager_get_connection_type (NMConnection *connection)
|
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));
|
scope = 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)
|
if (scope != NM_CONNECTION_SCOPE_USER && scope != NM_CONNECTION_SCOPE_SYSTEM)
|
||||||
type = NM_CONNECTION_TYPE_UNKNOWN;
|
scope = NM_CONNECTION_SCOPE_UNKNOWN;
|
||||||
return type;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* NM_MANAGER_H */
|
#endif /* NM_MANAGER_H */
|
||||||
|
@@ -145,11 +145,11 @@ impl_vpn_manager_connect (NMVPNManager *manager,
|
|||||||
|
|
||||||
if (!strcmp (connection_type, NM_DBUS_SERVICE_USER_SETTINGS))
|
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,
|
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);
|
connection_path);
|
||||||
else if (!strcmp (connection_type, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
|
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,
|
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);
|
connection_path);
|
||||||
if (connection == NULL) {
|
if (connection == NULL) {
|
||||||
*err = new_vpn_error ("%s.%d: VPN connection could not be found.",
|
*err = new_vpn_error ("%s.%d: VPN connection could not be found.",
|
||||||
|
@@ -30,34 +30,17 @@
|
|||||||
#include "nm-system-config-interface.h"
|
#include "nm-system-config-interface.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
static gchar *connection_settings_get_id (NMConnectionSettings *connection);
|
static void exported_connection_get_secrets (NMExportedConnection *connection,
|
||||||
static void connection_settings_get_secrets (NMConnectionSettings *connection,
|
|
||||||
const gchar *setting_name,
|
const gchar *setting_name,
|
||||||
const gchar **hints,
|
const gchar **hints,
|
||||||
gboolean request_new,
|
gboolean request_new,
|
||||||
DBusGMethodInvocation *context);
|
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 *
|
static GValue *
|
||||||
string_to_gvalue (const char *str)
|
string_to_gvalue (const char *str)
|
||||||
{
|
{
|
||||||
@@ -108,19 +91,21 @@ add_one_secret_to_hash (NMSetting *setting,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connection_settings_get_secrets (NMConnectionSettings *sys_connection,
|
exported_connection_get_secrets (NMExportedConnection *sys_connection,
|
||||||
const gchar *setting_name,
|
const gchar *setting_name,
|
||||||
const gchar **hints,
|
const gchar **hints,
|
||||||
gboolean request_new,
|
gboolean request_new,
|
||||||
DBusGMethodInvocation *context)
|
DBusGMethodInvocation *context)
|
||||||
{
|
{
|
||||||
NMConnection *connection = NM_SYSCONFIG_CONNECTION_SETTINGS (sys_connection)->connection;
|
NMConnection *connection;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
NMSetting *setting;
|
NMSetting *setting;
|
||||||
NMSystemConfigInterface *plugin;
|
NMSystemConfigInterface *plugin;
|
||||||
struct AddSecretsData sdata;
|
struct AddSecretsData sdata;
|
||||||
|
|
||||||
|
connection = nm_exported_connection_get_connection (sys_connection);
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_CONNECTION (connection));
|
g_return_if_fail (NM_IS_CONNECTION (connection));
|
||||||
g_return_if_fail (setting_name != NULL);
|
g_return_if_fail (setting_name != NULL);
|
||||||
|
|
||||||
@@ -182,45 +167,43 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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
|
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);
|
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_secrets = exported_connection_get_secrets;
|
||||||
connection->get_settings = connection_settings_get_settings;
|
|
||||||
connection->get_secrets = connection_settings_get_secrets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_sysconfig_connection_settings_init (NMSysconfigConnectionSettings *sysconfig_connection_settings)
|
nm_sysconfig_exported_connection_init (NMSysconfigExportedConnection *sysconfig_exported_connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NMSysconfigConnectionSettings *
|
NMSysconfigExportedConnection *
|
||||||
nm_sysconfig_connection_settings_new (NMConnection *connection,
|
nm_sysconfig_exported_connection_new (NMConnection *connection,
|
||||||
DBusGConnection *g_conn)
|
DBusGConnection *g_conn)
|
||||||
{
|
{
|
||||||
NMSysconfigConnectionSettings *settings;
|
NMSysconfigExportedConnection *exported;
|
||||||
NMSettingConnection *s_con;
|
|
||||||
|
|
||||||
settings = g_object_new (nm_sysconfig_connection_settings_get_type(), NULL);
|
exported = g_object_new (NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION,
|
||||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
NM_EXPORTED_CONNECTION_CONNECTION, connection,
|
||||||
settings->id = g_strdup (s_con->id);
|
NULL);
|
||||||
settings->connection = connection;
|
|
||||||
|
|
||||||
nm_connection_settings_register_object (NM_CONNECTION_SETTINGS (settings), g_conn);
|
nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (exported),
|
||||||
|
NM_CONNECTION_SCOPE_SYSTEM,
|
||||||
return settings;
|
g_conn);
|
||||||
|
|
||||||
|
return exported;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -242,10 +225,12 @@ nm_sysconfig_settings_list_connections (NMSettings *settings)
|
|||||||
|
|
||||||
connections = g_ptr_array_new ();
|
connections = g_ptr_array_new ();
|
||||||
for (iter = sysconfig_settings->connections; iter; iter = g_slist_next (iter)) {
|
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;
|
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)
|
if (path)
|
||||||
g_ptr_array_add (connections, path);
|
g_ptr_array_add (connections, path);
|
||||||
}
|
}
|
||||||
@@ -299,12 +284,12 @@ nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
|
|||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
DBusGConnection *g_connection)
|
DBusGConnection *g_connection)
|
||||||
{
|
{
|
||||||
NMSysconfigConnectionSettings *exported;
|
NMSysconfigExportedConnection *exported;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
|
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
|
||||||
g_return_if_fail (NM_IS_CONNECTION (connection));
|
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) {
|
if (!exported) {
|
||||||
g_warning ("%s: couldn't export the connection!", __func__);
|
g_warning ("%s: couldn't export the connection!", __func__);
|
||||||
return;
|
return;
|
||||||
@@ -313,7 +298,7 @@ nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
|
|||||||
settings->connections = g_slist_append (settings->connections, exported);
|
settings->connections = g_slist_append (settings->connections, exported);
|
||||||
|
|
||||||
nm_settings_signal_new_connection (NM_SETTINGS (settings),
|
nm_settings_signal_new_connection (NM_SETTINGS (settings),
|
||||||
NM_CONNECTION_SETTINGS (exported));
|
NM_EXPORTED_CONNECTION (exported));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -326,11 +311,15 @@ remove_connection (NMSysconfigSettings *settings,
|
|||||||
g_return_if_fail (NM_IS_CONNECTION (connection));
|
g_return_if_fail (NM_IS_CONNECTION (connection));
|
||||||
|
|
||||||
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
|
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);
|
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_object_unref (item);
|
||||||
g_slist_free (iter);
|
g_slist_free (iter);
|
||||||
break;
|
break;
|
||||||
@@ -351,15 +340,18 @@ nm_sysconfig_settings_update_connection (NMSysconfigSettings *settings,
|
|||||||
{
|
{
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
NMSysconfigConnectionSettings *found = NULL;
|
NMSysconfigExportedConnection *found = NULL;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
|
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
|
||||||
g_return_if_fail (NM_IS_CONNECTION (connection));
|
g_return_if_fail (NM_IS_CONNECTION (connection));
|
||||||
|
|
||||||
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
|
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;
|
found = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -377,7 +369,7 @@ nm_sysconfig_settings_update_connection (NMSysconfigSettings *settings,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hash = nm_connection_to_hash (connection);
|
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);
|
g_hash_table_destroy (hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,35 +27,32 @@
|
|||||||
|
|
||||||
#define NM_SS_PLUGIN_TAG "nm-ss-plugin"
|
#define NM_SS_PLUGIN_TAG "nm-ss-plugin"
|
||||||
|
|
||||||
typedef struct _NMSysconfigConnectionSettings NMSysconfigConnectionSettings;
|
typedef struct _NMSysconfigExportedConnection NMSysconfigExportedConnection;
|
||||||
typedef struct _NMSysconfigConnectionSettingsClass NMSysconfigConnectionSettingsClass;
|
typedef struct _NMSysconfigExportedConnectionClass NMSysconfigExportedConnectionClass;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NMSysconfigConnectionSettings
|
* NMSysconfigExportedConnection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS (nm_sysconfig_connection_settings_get_type ())
|
#define NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION (nm_sysconfig_exported_connection_get_type ())
|
||||||
#define NM_SYSCONFIG_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettings))
|
#define NM_SYSCONFIG_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnection))
|
||||||
#define NM_SYSCONFIG_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettingsClass))
|
#define NM_SYSCONFIG_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnectionClass))
|
||||||
#define NM_IS_SYSCONFIG_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS))
|
#define NM_IS_SYSCONFIG_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION))
|
||||||
#define NM_IS_SYSCONFIG_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS))
|
#define NM_IS_SYSCONFIG_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION))
|
||||||
#define NM_SYSCONFIG_CONNECTION_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettingsClass))
|
#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;
|
NMExportedConnection parent_instance;
|
||||||
|
|
||||||
char *id;
|
|
||||||
NMConnection *connection;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _NMSysconfigConnectionSettingsClass
|
struct _NMSysconfigExportedConnectionClass
|
||||||
{
|
{
|
||||||
NMConnectionSettingsClass parent_class;
|
NMExportedConnectionClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType nm_sysconfig_connection_settings_get_type (void);
|
GType nm_sysconfig_exported_connection_get_type (void);
|
||||||
NMSysconfigConnectionSettings *nm_sysconfig_connection_settings_new (NMConnection *connection,
|
NMSysconfigExportedConnection *nm_sysconfig_exported_connection_new (NMConnection *connection,
|
||||||
DBusGConnection *g_conn);
|
DBusGConnection *g_conn);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user