Merged NM{Exported,Sysconfig}Connection
In continuation of the theme, the removal of user settings services means that the distinction between NMSysconfigConnection and NMExportedConnection is no longer needed. Merge NMExportedConnection into NMSysconfigConnection.
This commit is contained in:
@@ -45,8 +45,7 @@ IGNORE_HFILES= \
|
|||||||
nm-device-wifi-bindings.h \
|
nm-device-wifi-bindings.h \
|
||||||
nm-dhcp4-config-bindings.h \
|
nm-dhcp4-config-bindings.h \
|
||||||
nm-dhcp6-config-bindings.h \
|
nm-dhcp6-config-bindings.h \
|
||||||
nm-exported-connection-bindings.h \
|
nm-sysconfig-connection-glue.h \
|
||||||
nm-exported-connection-glue.h \
|
|
||||||
nm-ip4-config-bindings.h \
|
nm-ip4-config-bindings.h \
|
||||||
nm-ip6-config-bindings.h \
|
nm-ip6-config-bindings.h \
|
||||||
nm-settings-bindings.h \
|
nm-settings-bindings.h \
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
<xi:include href="xml/nm-ip6-config.xml"/>
|
<xi:include href="xml/nm-ip6-config.xml"/>
|
||||||
<xi:include href="xml/nm-dhcp4-config.xml"/>
|
<xi:include href="xml/nm-dhcp4-config.xml"/>
|
||||||
<xi:include href="xml/nm-dhcp6-config.xml"/>
|
<xi:include href="xml/nm-dhcp6-config.xml"/>
|
||||||
<xi:include href="xml/nm-exported-connection.xml"/>
|
<xi:include href="xml/nm-sysconfig-connection.xml"/>
|
||||||
<xi:include href="xml/nm-object.xml"/>
|
<xi:include href="xml/nm-object.xml"/>
|
||||||
<xi:include href="xml/nm-remote-connection.xml"/>
|
<xi:include href="xml/nm-remote-connection.xml"/>
|
||||||
<xi:include href="xml/nm-remote-settings.xml"/>
|
<xi:include href="xml/nm-remote-settings.xml"/>
|
||||||
|
@@ -18,7 +18,7 @@ EXTRA_DIST = \
|
|||||||
nm-manager-client.xml \
|
nm-manager-client.xml \
|
||||||
nm-settings.xml \
|
nm-settings.xml \
|
||||||
nm-settings-system.xml \
|
nm-settings-system.xml \
|
||||||
nm-exported-connection.xml \
|
nm-sysconfig-connection.xml \
|
||||||
nm-vpn-plugin.xml \
|
nm-vpn-plugin.xml \
|
||||||
nm-vpn-connection.xml \
|
nm-vpn-connection.xml \
|
||||||
nm-ppp-manager.xml \
|
nm-ppp-manager.xml \
|
||||||
|
@@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
|
|||||||
<xi:include href="nm-dhcp4-config.xml"/>
|
<xi:include href="nm-dhcp4-config.xml"/>
|
||||||
<xi:include href="nm-dhcp6-config.xml"/>
|
<xi:include href="nm-dhcp6-config.xml"/>
|
||||||
<xi:include href="nm-settings.xml"/>
|
<xi:include href="nm-settings.xml"/>
|
||||||
<xi:include href="nm-exported-connection.xml"/>
|
<xi:include href="nm-sysconfig-connection.xml"/>
|
||||||
<xi:include href="nm-active-connection.xml"/>
|
<xi:include href="nm-active-connection.xml"/>
|
||||||
<xi:include href="nm-vpn-connection.xml"/>
|
<xi:include href="nm-vpn-connection.xml"/>
|
||||||
<xi:include href="nm-vpn-plugin.xml"/>
|
<xi:include href="nm-vpn-plugin.xml"/>
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
Update the connection with new settings and properties, replacing all previous settings and properties.
|
Update the connection with new settings and properties, replacing all previous settings and properties.
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_update"/>
|
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_connection_update"/>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||||
<arg name="properties" type="a{sa{sv}}" direction="in">
|
<arg name="properties" type="a{sa{sv}}" direction="in">
|
||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
Delete the connection.
|
Delete the connection.
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_delete"/>
|
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_connection_delete"/>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
Get the settings maps describing this object.
|
Get the settings maps describing this object.
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_settings"/>
|
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_connection_get_settings"/>
|
||||||
<arg name="settings" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map">
|
<arg name="settings" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map">
|
||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
The nested settings maps describing this object.
|
The nested settings maps describing this object.
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<tp:docstring>
|
<tp:docstring>
|
||||||
Get the secrets encapsulated in this object.
|
Get the secrets encapsulated in this object.
|
||||||
</tp:docstring>
|
</tp:docstring>
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_secrets"/>
|
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_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">
|
||||||
<tp:docstring>
|
<tp:docstring>
|
@@ -10,8 +10,7 @@ BUILT_SOURCES = \
|
|||||||
nm-device-ethernet-bindings.h \
|
nm-device-ethernet-bindings.h \
|
||||||
nm-device-wifi-bindings.h \
|
nm-device-wifi-bindings.h \
|
||||||
nm-device-bt-bindings.h \
|
nm-device-bt-bindings.h \
|
||||||
nm-exported-connection-glue.h \
|
nm-sysconfig-connection-bindings.h \
|
||||||
nm-exported-connection-bindings.h \
|
|
||||||
nm-settings-bindings.h \
|
nm-settings-bindings.h \
|
||||||
nm-vpn-connection-bindings.h \
|
nm-vpn-connection-bindings.h \
|
||||||
nm-vpn-plugin-glue.h \
|
nm-vpn-plugin-glue.h \
|
||||||
@@ -79,8 +78,7 @@ libnminclude_HEADERS = \
|
|||||||
nm-remote-connection.h \
|
nm-remote-connection.h \
|
||||||
nm-settings-interface.h \
|
nm-settings-interface.h \
|
||||||
nm-remote-settings.h \
|
nm-remote-settings.h \
|
||||||
nm-settings-connection-interface.h \
|
nm-settings-connection-interface.h
|
||||||
nm-exported-connection.h
|
|
||||||
|
|
||||||
libnm_glib_la_SOURCES = \
|
libnm_glib_la_SOURCES = \
|
||||||
nm-object.c \
|
nm-object.c \
|
||||||
@@ -111,8 +109,7 @@ libnm_glib_la_SOURCES = \
|
|||||||
nm-remote-connection-private.h \
|
nm-remote-connection-private.h \
|
||||||
nm-settings-interface.c \
|
nm-settings-interface.c \
|
||||||
nm-remote-settings.c \
|
nm-remote-settings.c \
|
||||||
nm-settings-connection-interface.c \
|
nm-settings-connection-interface.c
|
||||||
nm-exported-connection.c
|
|
||||||
|
|
||||||
libnm_glib_la_LIBADD = \
|
libnm_glib_la_LIBADD = \
|
||||||
$(top_builddir)/libnm-util/libnm-util.la \
|
$(top_builddir)/libnm-util/libnm-util.la \
|
||||||
@@ -161,11 +158,8 @@ nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml
|
|||||||
nm-settings-bindings.h: $(top_srcdir)/introspection/nm-settings.xml
|
nm-settings-bindings.h: $(top_srcdir)/introspection/nm-settings.xml
|
||||||
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $<
|
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $<
|
||||||
|
|
||||||
nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml
|
nm-sysconfig-connection-bindings.h: $(top_srcdir)/introspection/nm-sysconfig-connection.xml
|
||||||
$(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=$@ $<
|
$(AM_V_GEN) dbus-binding-tool --prefix=nm_sysconfig_connection --mode=glib-client --output=$@ $<
|
||||||
|
|
||||||
nm-exported-connection-bindings.h: $(top_srcdir)/introspection/nm-exported-connection.xml
|
|
||||||
$(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-client --output=$@ $<
|
|
||||||
|
|
||||||
nm-vpn-connection-bindings.h: $(top_srcdir)/introspection/nm-vpn-connection.xml
|
nm-vpn-connection-bindings.h: $(top_srcdir)/introspection/nm-vpn-connection.xml
|
||||||
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-client --output=$@ $<
|
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-client --output=$@ $<
|
||||||
|
@@ -93,9 +93,6 @@ global:
|
|||||||
nm_dhcp4_config_get_options;
|
nm_dhcp4_config_get_options;
|
||||||
nm_dhcp4_config_get_type;
|
nm_dhcp4_config_get_type;
|
||||||
nm_dhcp4_config_new;
|
nm_dhcp4_config_new;
|
||||||
nm_exported_connection_export;
|
|
||||||
nm_exported_connection_get_type;
|
|
||||||
nm_exported_connection_new;
|
|
||||||
nm_gsm_device_get_type;
|
nm_gsm_device_get_type;
|
||||||
nm_gsm_device_new;
|
nm_gsm_device_new;
|
||||||
nm_ip4_config_get_addresses;
|
nm_ip4_config_get_addresses;
|
||||||
|
@@ -1,277 +0,0 @@
|
|||||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
||||||
/* NetworkManager system settings service
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* (C) Copyright 2008 Novell, Inc.
|
|
||||||
* (C) Copyright 2008 - 2009 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <NetworkManager.h>
|
|
||||||
#include <dbus/dbus-glib-lowlevel.h>
|
|
||||||
#include <nm-setting-connection.h>
|
|
||||||
|
|
||||||
#include "nm-exported-connection.h"
|
|
||||||
#include "nm-settings-interface.h"
|
|
||||||
#include "nm-settings-connection-interface.h"
|
|
||||||
|
|
||||||
static gboolean impl_exported_connection_get_settings (NMExportedConnection *connection,
|
|
||||||
GHashTable **settings,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
static void impl_exported_connection_update (NMExportedConnection *connection,
|
|
||||||
GHashTable *new_settings,
|
|
||||||
DBusGMethodInvocation *context);
|
|
||||||
|
|
||||||
static void impl_exported_connection_delete (NMExportedConnection *connection,
|
|
||||||
DBusGMethodInvocation *context);
|
|
||||||
|
|
||||||
static void impl_exported_connection_get_secrets (NMExportedConnection *connection,
|
|
||||||
const gchar *setting_name,
|
|
||||||
const gchar **hints,
|
|
||||||
gboolean request_new,
|
|
||||||
DBusGMethodInvocation *context);
|
|
||||||
|
|
||||||
#include "nm-exported-connection-glue.h"
|
|
||||||
|
|
||||||
static void settings_connection_interface_init (NMSettingsConnectionInterface *class);
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_EXTENDED (NMExportedConnection, nm_exported_connection, NM_TYPE_CONNECTION, 0,
|
|
||||||
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
|
|
||||||
settings_connection_interface_init))
|
|
||||||
|
|
||||||
#define NM_EXPORTED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
|
||||||
NM_TYPE_EXPORTED_CONNECTION, \
|
|
||||||
NMExportedConnectionPrivate))
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
gboolean foo;
|
|
||||||
} NMExportedConnectionPrivate;
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
static GHashTable *
|
|
||||||
real_get_settings (NMExportedConnection *self, GError **error)
|
|
||||||
{
|
|
||||||
NMConnection *no_secrets;
|
|
||||||
GHashTable *settings;
|
|
||||||
|
|
||||||
/* Secrets should *never* be returned by the GetSettings method, they
|
|
||||||
* get returned by the GetSecrets method which can be better
|
|
||||||
* protected against leakage of secrets to unprivileged callers.
|
|
||||||
*/
|
|
||||||
no_secrets = nm_connection_duplicate (NM_CONNECTION (self));
|
|
||||||
g_assert (no_secrets);
|
|
||||||
nm_connection_clear_secrets (no_secrets);
|
|
||||||
settings = nm_connection_to_hash (no_secrets);
|
|
||||||
g_assert (settings);
|
|
||||||
g_object_unref (no_secrets);
|
|
||||||
|
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
check_writable (NMConnection *connection, GError **error)
|
|
||||||
{
|
|
||||||
NMSettingConnection *s_con;
|
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
|
||||||
|
|
||||||
s_con = (NMSettingConnection *) nm_connection_get_setting (connection,
|
|
||||||
NM_TYPE_SETTING_CONNECTION);
|
|
||||||
if (!s_con) {
|
|
||||||
g_set_error_literal (error,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
|
|
||||||
"Connection did not have required 'connection' setting");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the connection is read-only, that has to be changed at the source of
|
|
||||||
* the problem (ex a system settings plugin that can't write connections out)
|
|
||||||
* instead of over D-Bus.
|
|
||||||
*/
|
|
||||||
if (nm_setting_connection_get_read_only (s_con)) {
|
|
||||||
g_set_error_literal (error,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION,
|
|
||||||
"Connection is read-only");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
impl_exported_connection_get_settings (NMExportedConnection *self,
|
|
||||||
GHashTable **settings,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
/* Must always be implemented */
|
|
||||||
g_assert (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_settings);
|
|
||||||
*settings = NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_settings (self, error);
|
|
||||||
return *settings ? TRUE : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
update (NMSettingsConnectionInterface *connection,
|
|
||||||
NMSettingsConnectionInterfaceUpdateFunc callback,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
g_object_ref (connection);
|
|
||||||
nm_settings_connection_interface_emit_updated (connection);
|
|
||||||
callback (connection, NULL, user_data);
|
|
||||||
g_object_unref (connection);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
impl_exported_connection_update (NMExportedConnection *self,
|
|
||||||
GHashTable *new_settings,
|
|
||||||
DBusGMethodInvocation *context)
|
|
||||||
{
|
|
||||||
NMConnection *tmp;
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
/* If the connection is read-only, that has to be changed at the source of
|
|
||||||
* the problem (ex a system settings plugin that can't write connections out)
|
|
||||||
* instead of over D-Bus.
|
|
||||||
*/
|
|
||||||
if (!check_writable (NM_CONNECTION (self), &error)) {
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
g_error_free (error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the settings are valid first */
|
|
||||||
tmp = nm_connection_new_from_hash (new_settings, &error);
|
|
||||||
if (!tmp) {
|
|
||||||
g_assert (error);
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
g_error_free (error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_object_unref (tmp);
|
|
||||||
|
|
||||||
if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->update)
|
|
||||||
NM_EXPORTED_CONNECTION_GET_CLASS (self)->update (self, new_settings, context);
|
|
||||||
else {
|
|
||||||
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"%s: %s:%d update() unimplemented", __func__, __FILE__, __LINE__);
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
do_delete (NMSettingsConnectionInterface *connection,
|
|
||||||
NMSettingsConnectionInterfaceDeleteFunc callback,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
g_object_ref (connection);
|
|
||||||
g_signal_emit_by_name (connection, "removed");
|
|
||||||
callback (connection, NULL, user_data);
|
|
||||||
g_object_unref (connection);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
impl_exported_connection_delete (NMExportedConnection *self,
|
|
||||||
DBusGMethodInvocation *context)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (!check_writable (NM_CONNECTION (self), &error)) {
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
g_error_free (error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->delete)
|
|
||||||
NM_EXPORTED_CONNECTION_GET_CLASS (self)->delete (self, context);
|
|
||||||
else {
|
|
||||||
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__);
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
impl_exported_connection_get_secrets (NMExportedConnection *self,
|
|
||||||
const gchar *setting_name,
|
|
||||||
const gchar **hints,
|
|
||||||
gboolean request_new,
|
|
||||||
DBusGMethodInvocation *context)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets)
|
|
||||||
NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets (self, setting_name, hints, request_new, context);
|
|
||||||
else {
|
|
||||||
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
|
|
||||||
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
|
||||||
"%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************/
|
|
||||||
|
|
||||||
static void
|
|
||||||
settings_connection_interface_init (NMSettingsConnectionInterface *iface)
|
|
||||||
{
|
|
||||||
iface->update = update;
|
|
||||||
iface->delete = do_delete;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* nm_exported_connection_new:
|
|
||||||
*
|
|
||||||
* Creates a new object representing the remote connection.
|
|
||||||
*
|
|
||||||
* Returns: the new exported connection object on success, or %NULL on failure
|
|
||||||
**/
|
|
||||||
NMExportedConnection *
|
|
||||||
nm_exported_connection_new ()
|
|
||||||
{
|
|
||||||
return (NMExportedConnection *) g_object_new (NM_TYPE_EXPORTED_CONNECTION,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
nm_exported_connection_init (NMExportedConnection *self)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
nm_exported_connection_class_init (NMExportedConnectionClass *class)
|
|
||||||
{
|
|
||||||
g_type_class_add_private (class, sizeof (NMExportedConnectionPrivate));
|
|
||||||
|
|
||||||
/* Virtual methods */
|
|
||||||
class->get_settings = real_get_settings;
|
|
||||||
|
|
||||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class),
|
|
||||||
&dbus_glib_nm_exported_connection_object_info);
|
|
||||||
}
|
|
@@ -1,75 +0,0 @@
|
|||||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
||||||
/* NetworkManager system settings service
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* (C) Copyright 2009 Red Hat, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NM_EXPORTED_CONNECTION_H
|
|
||||||
#define NM_EXPORTED_CONNECTION_H
|
|
||||||
|
|
||||||
#include <nm-connection.h>
|
|
||||||
#include <dbus/dbus-glib.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#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))
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
NMConnection parent;
|
|
||||||
} NMExportedConnection;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
NMConnectionClass parent;
|
|
||||||
|
|
||||||
GHashTable * (*get_settings) (NMExportedConnection *self,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
void (*update) (NMExportedConnection *self,
|
|
||||||
GHashTable *new_settings,
|
|
||||||
DBusGMethodInvocation *context);
|
|
||||||
|
|
||||||
void (*delete) (NMExportedConnection *self,
|
|
||||||
DBusGMethodInvocation *context);
|
|
||||||
|
|
||||||
void (*get_secrets) (NMExportedConnection *self,
|
|
||||||
const gchar *setting_name,
|
|
||||||
const gchar **hints,
|
|
||||||
gboolean request_new,
|
|
||||||
DBusGMethodInvocation *context);
|
|
||||||
|
|
||||||
/* Padding for future expansion */
|
|
||||||
void (*_reserved1) (void);
|
|
||||||
void (*_reserved2) (void);
|
|
||||||
void (*_reserved3) (void);
|
|
||||||
void (*_reserved4) (void);
|
|
||||||
void (*_reserved5) (void);
|
|
||||||
void (*_reserved6) (void);
|
|
||||||
} NMExportedConnectionClass;
|
|
||||||
|
|
||||||
GType nm_exported_connection_get_type (void);
|
|
||||||
|
|
||||||
NMExportedConnection *nm_exported_connection_new (void);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* NM_EXPORTED_CONNECTION_H */
|
|
@@ -29,7 +29,7 @@
|
|||||||
#include "nm-remote-connection.h"
|
#include "nm-remote-connection.h"
|
||||||
#include "nm-remote-connection-private.h"
|
#include "nm-remote-connection-private.h"
|
||||||
#include "nm-dbus-glib-types.h"
|
#include "nm-dbus-glib-types.h"
|
||||||
#include "nm-exported-connection-bindings.h"
|
#include "nm-sysconfig-connection-bindings.h"
|
||||||
#include "nm-settings-connection-interface.h"
|
#include "nm-settings-connection-interface.h"
|
||||||
|
|
||||||
#define NM_REMOTE_CONNECTION_BUS "bus"
|
#define NM_REMOTE_CONNECTION_BUS "bus"
|
||||||
|
@@ -9,7 +9,8 @@ INCLUDES = -I${top_srcdir} \
|
|||||||
noinst_LTLIBRARIES = libsystem-settings.la
|
noinst_LTLIBRARIES = libsystem-settings.la
|
||||||
|
|
||||||
BUILT_SOURCES = \
|
BUILT_SOURCES = \
|
||||||
nm-settings-glue.h
|
nm-settings-glue.h \
|
||||||
|
nm-sysconfig-connection-glue.h
|
||||||
|
|
||||||
libsystem_settings_la_SOURCES = \
|
libsystem_settings_la_SOURCES = \
|
||||||
nm-sysconfig-settings.c \
|
nm-sysconfig-settings.c \
|
||||||
@@ -57,6 +58,9 @@ libsystem_settings_la_LDFLAGS = -rdynamic
|
|||||||
nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml
|
nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml
|
||||||
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $<
|
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $<
|
||||||
|
|
||||||
|
nm-sysconfig-connection-glue.h: $(top_srcdir)/introspection/nm-sysconfig-connection.xml
|
||||||
|
$(AM_V_GEN) dbus-binding-tool --prefix=nm_sysconfig_connection --mode=glib-server --output=$@ $<
|
||||||
|
|
||||||
CLEANFILES = \
|
CLEANFILES = \
|
||||||
$(BUILT_SOURCES)
|
$(BUILT_SOURCES)
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <NetworkManager.h>
|
#include <NetworkManager.h>
|
||||||
#include <dbus/dbus-glib-lowlevel.h>
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
|
#include <nm-setting-connection.h>
|
||||||
|
|
||||||
#include "nm-sysconfig-connection.h"
|
#include "nm-sysconfig-connection.h"
|
||||||
#include "nm-system-config-error.h"
|
#include "nm-system-config-error.h"
|
||||||
@@ -30,10 +31,28 @@
|
|||||||
#include "nm-polkit-helpers.h"
|
#include "nm-polkit-helpers.h"
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
|
|
||||||
|
static gboolean impl_sysconfig_connection_get_settings (NMSysconfigConnection *connection,
|
||||||
|
GHashTable **settings,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
static void impl_sysconfig_connection_update (NMSysconfigConnection *connection,
|
||||||
|
GHashTable *new_settings,
|
||||||
|
DBusGMethodInvocation *context);
|
||||||
|
|
||||||
|
static void impl_sysconfig_connection_delete (NMSysconfigConnection *connection,
|
||||||
|
DBusGMethodInvocation *context);
|
||||||
|
|
||||||
|
static void impl_sysconfig_connection_get_secrets (NMSysconfigConnection *connection,
|
||||||
|
const gchar *setting_name,
|
||||||
|
const gchar **hints,
|
||||||
|
gboolean request_new,
|
||||||
|
DBusGMethodInvocation *context);
|
||||||
|
|
||||||
|
#include "nm-sysconfig-connection-glue.h"
|
||||||
|
|
||||||
static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
|
static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
|
||||||
|
|
||||||
G_DEFINE_TYPE_EXTENDED (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_EXPORTED_CONNECTION, 0,
|
G_DEFINE_TYPE_EXTENDED (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_CONNECTION, 0,
|
||||||
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
|
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
|
||||||
settings_connection_interface_init))
|
settings_connection_interface_init))
|
||||||
|
|
||||||
@@ -49,6 +68,27 @@ typedef struct {
|
|||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
|
static GHashTable *
|
||||||
|
get_settings (NMSysconfigConnection *self, GError **error)
|
||||||
|
{
|
||||||
|
NMConnection *no_secrets;
|
||||||
|
GHashTable *settings;
|
||||||
|
|
||||||
|
/* Secrets should *never* be returned by the GetSettings method, they
|
||||||
|
* get returned by the GetSecrets method which can be better
|
||||||
|
* protected against leakage of secrets to unprivileged callers.
|
||||||
|
*/
|
||||||
|
no_secrets = nm_connection_duplicate (NM_CONNECTION (self));
|
||||||
|
g_assert (no_secrets);
|
||||||
|
nm_connection_clear_secrets (no_secrets);
|
||||||
|
settings = nm_connection_to_hash (no_secrets);
|
||||||
|
g_assert (settings);
|
||||||
|
g_object_unref (no_secrets);
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ignore_cb (NMSettingsConnectionInterface *connection,
|
ignore_cb (NMSettingsConnectionInterface *connection,
|
||||||
GError *error,
|
GError *error,
|
||||||
@@ -102,6 +142,30 @@ nm_sysconfig_connection_update (NMSysconfigConnection *self,
|
|||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
update (NMSettingsConnectionInterface *connection,
|
||||||
|
NMSettingsConnectionInterfaceUpdateFunc callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_object_ref (connection);
|
||||||
|
nm_settings_connection_interface_emit_updated (connection);
|
||||||
|
callback (connection, NULL, user_data);
|
||||||
|
g_object_unref (connection);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
do_delete (NMSettingsConnectionInterface *connection,
|
||||||
|
NMSettingsConnectionInterfaceDeleteFunc callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_object_ref (connection);
|
||||||
|
g_signal_emit_by_name (connection, "removed");
|
||||||
|
callback (connection, NULL, user_data);
|
||||||
|
g_object_unref (connection);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static GValue *
|
static GValue *
|
||||||
string_to_gvalue (const char *str)
|
string_to_gvalue (const char *str)
|
||||||
{
|
{
|
||||||
@@ -235,6 +299,134 @@ get_secrets (NMSettingsConnectionInterface *connection,
|
|||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
check_writable (NMConnection *connection, GError **error)
|
||||||
|
{
|
||||||
|
NMSettingConnection *s_con;
|
||||||
|
|
||||||
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||||
|
|
||||||
|
s_con = (NMSettingConnection *) nm_connection_get_setting (connection,
|
||||||
|
NM_TYPE_SETTING_CONNECTION);
|
||||||
|
if (!s_con) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
NM_SETTINGS_INTERFACE_ERROR,
|
||||||
|
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
|
||||||
|
"Connection did not have required 'connection' setting");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the connection is read-only, that has to be changed at the source of
|
||||||
|
* the problem (ex a system settings plugin that can't write connections out)
|
||||||
|
* instead of over D-Bus.
|
||||||
|
*/
|
||||||
|
if (nm_setting_connection_get_read_only (s_con)) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
NM_SETTINGS_INTERFACE_ERROR,
|
||||||
|
NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION,
|
||||||
|
"Connection is read-only");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
impl_sysconfig_connection_get_settings (NMSysconfigConnection *self,
|
||||||
|
GHashTable **settings,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
/* Must always be implemented */
|
||||||
|
g_assert (NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->get_settings);
|
||||||
|
*settings = NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->get_settings (self, error);
|
||||||
|
return *settings ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
impl_sysconfig_connection_update (NMSysconfigConnection *self,
|
||||||
|
GHashTable *new_settings,
|
||||||
|
DBusGMethodInvocation *context)
|
||||||
|
{
|
||||||
|
NMConnection *tmp;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
/* If the connection is read-only, that has to be changed at the source of
|
||||||
|
* the problem (ex a system settings plugin that can't write connections out)
|
||||||
|
* instead of over D-Bus.
|
||||||
|
*/
|
||||||
|
if (!check_writable (NM_CONNECTION (self), &error)) {
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the settings are valid first */
|
||||||
|
tmp = nm_connection_new_from_hash (new_settings, &error);
|
||||||
|
if (!tmp) {
|
||||||
|
g_assert (error);
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_object_unref (tmp);
|
||||||
|
|
||||||
|
if (NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->update)
|
||||||
|
NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->update (self, new_settings, context);
|
||||||
|
else {
|
||||||
|
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
|
||||||
|
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
||||||
|
"%s: %s:%d update() unimplemented", __func__, __FILE__, __LINE__);
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
impl_sysconfig_connection_delete (NMSysconfigConnection *self,
|
||||||
|
DBusGMethodInvocation *context)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!check_writable (NM_CONNECTION (self), &error)) {
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->delete)
|
||||||
|
NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->delete (self, context);
|
||||||
|
else {
|
||||||
|
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
|
||||||
|
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
||||||
|
"%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__);
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
impl_sysconfig_connection_get_secrets (NMSysconfigConnection *self,
|
||||||
|
const gchar *setting_name,
|
||||||
|
const gchar **hints,
|
||||||
|
gboolean request_new,
|
||||||
|
DBusGMethodInvocation *context)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->get_secrets)
|
||||||
|
NM_SYSCONFIG_CONNECTION_GET_CLASS (self)->get_secrets (self, setting_name, hints, request_new, context);
|
||||||
|
else {
|
||||||
|
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
|
||||||
|
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
|
||||||
|
"%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
|
||||||
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMSysconfigConnection *self;
|
NMSysconfigConnection *self;
|
||||||
DBusGMethodInvocation *context;
|
DBusGMethodInvocation *context;
|
||||||
@@ -379,11 +571,10 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dbus_update (NMExportedConnection *exported,
|
dbus_update (NMSysconfigConnection *self,
|
||||||
GHashTable *new_settings,
|
GHashTable *new_settings,
|
||||||
DBusGMethodInvocation *context)
|
DBusGMethodInvocation *context)
|
||||||
{
|
{
|
||||||
NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (exported);
|
|
||||||
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
|
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
|
||||||
PolkitCall *call;
|
PolkitCall *call;
|
||||||
NMConnection *tmp;
|
NMConnection *tmp;
|
||||||
@@ -482,10 +673,9 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dbus_delete (NMExportedConnection *exported,
|
dbus_delete (NMSysconfigConnection *self,
|
||||||
DBusGMethodInvocation *context)
|
DBusGMethodInvocation *context)
|
||||||
{
|
{
|
||||||
NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (exported);
|
|
||||||
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
|
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
|
||||||
PolkitCall *call;
|
PolkitCall *call;
|
||||||
|
|
||||||
@@ -577,7 +767,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dbus_get_secrets (NMExportedConnection *exported,
|
dbus_get_secrets (NMSysconfigConnection *exported,
|
||||||
const gchar *setting_name,
|
const gchar *setting_name,
|
||||||
const gchar **hints,
|
const gchar **hints,
|
||||||
gboolean request_new,
|
gboolean request_new,
|
||||||
@@ -605,6 +795,8 @@ dbus_get_secrets (NMExportedConnection *exported,
|
|||||||
static void
|
static void
|
||||||
settings_connection_interface_init (NMSettingsConnectionInterface *iface)
|
settings_connection_interface_init (NMSettingsConnectionInterface *iface)
|
||||||
{
|
{
|
||||||
|
iface->update = update;
|
||||||
|
iface->delete = do_delete;
|
||||||
iface->get_secrets = get_secrets;
|
iface->get_secrets = get_secrets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,13 +838,17 @@ static void
|
|||||||
nm_sysconfig_connection_class_init (NMSysconfigConnectionClass *class)
|
nm_sysconfig_connection_class_init (NMSysconfigConnectionClass *class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
NMExportedConnectionClass *ec_class = NM_EXPORTED_CONNECTION_CLASS (class);
|
|
||||||
|
|
||||||
g_type_class_add_private (class, sizeof (NMSysconfigConnectionPrivate));
|
g_type_class_add_private (class, sizeof (NMSysconfigConnectionPrivate));
|
||||||
|
|
||||||
/* Virtual methods */
|
/* Virtual methods */
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
ec_class->update = dbus_update;
|
class->get_settings = get_settings;
|
||||||
ec_class->delete = dbus_delete;
|
class->update = dbus_update;
|
||||||
ec_class->get_secrets = dbus_get_secrets;
|
class->delete = dbus_delete;
|
||||||
|
class->get_secrets = dbus_get_secrets;
|
||||||
|
|
||||||
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class),
|
||||||
|
&dbus_glib_nm_sysconfig_connection_object_info);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#define NM_SYSCONFIG_CONNECTION_H
|
#define NM_SYSCONFIG_CONNECTION_H
|
||||||
|
|
||||||
#include <nm-connection.h>
|
#include <nm-connection.h>
|
||||||
#include <nm-exported-connection.h>
|
#include <dbus/dbus-glib.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@@ -34,11 +34,27 @@ G_BEGIN_DECLS
|
|||||||
#define NM_SYSCONFIG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION, NMSysconfigConnectionClass))
|
#define NM_SYSCONFIG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION, NMSysconfigConnectionClass))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMExportedConnection parent;
|
NMConnection parent;
|
||||||
} NMSysconfigConnection;
|
} NMSysconfigConnection;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMExportedConnectionClass parent;
|
NMConnectionClass parent;
|
||||||
|
|
||||||
|
GHashTable * (*get_settings) (NMSysconfigConnection *self,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
void (*update) (NMSysconfigConnection *self,
|
||||||
|
GHashTable *new_settings,
|
||||||
|
DBusGMethodInvocation *context);
|
||||||
|
|
||||||
|
void (*delete) (NMSysconfigConnection *self,
|
||||||
|
DBusGMethodInvocation *context);
|
||||||
|
|
||||||
|
void (*get_secrets) (NMSysconfigConnection *self,
|
||||||
|
const gchar *setting_name,
|
||||||
|
const gchar **hints,
|
||||||
|
gboolean request_new,
|
||||||
|
DBusGMethodInvocation *context);
|
||||||
} NMSysconfigConnectionClass;
|
} NMSysconfigConnectionClass;
|
||||||
|
|
||||||
GType nm_sysconfig_connection_get_type (void);
|
GType nm_sysconfig_connection_get_type (void);
|
||||||
|
@@ -183,7 +183,7 @@ list_connections (NMSettingsInterface *settings)
|
|||||||
|
|
||||||
g_hash_table_iter_init (&iter, priv->connections);
|
g_hash_table_iter_init (&iter, priv->connections);
|
||||||
while (g_hash_table_iter_next (&iter, &key, NULL))
|
while (g_hash_table_iter_next (&iter, &key, NULL))
|
||||||
list = g_slist_prepend (list, NM_EXPORTED_CONNECTION (key));
|
list = g_slist_prepend (list, NM_SYSCONFIG_CONNECTION (key));
|
||||||
return g_slist_reverse (list);
|
return g_slist_reverse (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,13 +207,13 @@ impl_settings_list_connections (NMSysconfigSettings *self,
|
|||||||
static NMSettingsConnectionInterface *
|
static NMSettingsConnectionInterface *
|
||||||
get_connection_by_path (NMSettingsInterface *settings, const char *path)
|
get_connection_by_path (NMSettingsInterface *settings, const char *path)
|
||||||
{
|
{
|
||||||
NMExportedConnection *connection = NULL;
|
NMSysconfigConnection *connection = NULL;
|
||||||
GSList *list = NULL, *iter;
|
GSList *list = NULL, *iter;
|
||||||
|
|
||||||
list = list_connections (settings);
|
list = list_connections (settings);
|
||||||
for (iter = list; iter; iter = g_slist_next (iter)) {
|
for (iter = list; iter; iter = g_slist_next (iter)) {
|
||||||
if (!strcmp (nm_connection_get_path (NM_CONNECTION (iter->data)), path)) {
|
if (!strcmp (nm_connection_get_path (NM_CONNECTION (iter->data)), path)) {
|
||||||
connection = NM_EXPORTED_CONNECTION (iter->data);
|
connection = NM_SYSCONFIG_CONNECTION (iter->data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ nm_ifupdown_connection_new (if_block *block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_secrets (NMExportedConnection *exported,
|
get_secrets (NMSysconfigConnection *exported,
|
||||||
const gchar *setting_name,
|
const gchar *setting_name,
|
||||||
const gchar **hints,
|
const gchar **hints,
|
||||||
gboolean request_new,
|
gboolean request_new,
|
||||||
@@ -81,7 +81,7 @@ get_secrets (NMExportedConnection *exported,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NM_EXPORTED_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->get_secrets (exported, setting_name, hints, request_new, context);
|
NM_SYSCONFIG_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->get_secrets (exported, setting_name, hints, request_new, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -165,7 +165,7 @@ static void
|
|||||||
nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class)
|
nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (ifupdown_connection_class);
|
GObjectClass *object_class = G_OBJECT_CLASS (ifupdown_connection_class);
|
||||||
NMExportedConnectionClass *connection_class = NM_EXPORTED_CONNECTION_CLASS (ifupdown_connection_class);
|
NMSysconfigConnectionClass *connection_class = NM_SYSCONFIG_CONNECTION_CLASS (ifupdown_connection_class);
|
||||||
|
|
||||||
g_type_class_add_private (ifupdown_connection_class, sizeof (NMIfupdownConnectionPrivate));
|
g_type_class_add_private (ifupdown_connection_class, sizeof (NMIfupdownConnectionPrivate));
|
||||||
|
|
||||||
|
@@ -458,7 +458,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
|
|||||||
for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) {
|
for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) {
|
||||||
g_signal_emit_by_name (self,
|
g_signal_emit_by_name (self,
|
||||||
NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED,
|
NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED,
|
||||||
NM_EXPORTED_CONNECTION (cl_iter->data));
|
NM_SYSCONFIG_CONNECTION (cl_iter->data));
|
||||||
}
|
}
|
||||||
g_list_free (con_list);
|
g_list_free (con_list);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user