Commit a3be3b6e authored by Dan Williams's avatar Dan Williams

2008-08-12 Dan Williams <dcbw@redhat.com>

	* introspection/nm-settings-system.xml
	  system-settings/src/dbus-settings.c
	  system-settings/src/dbus-settings.h
		- Add a 'Hostname' property (rw) which represents the configured
			hostname and domain of the system, if any

	* system-settings/src/nm-system-config-error.c
	  system-settings/src/nm-system-config-error.h
	  system-settings/src/nm-system-config-interface.c
	  system-settings/src/nm-system-config-interface.h
		- Add a 'hostname' property to the plugin interface
		- Add a method to send updated hostname to plugins to save in their
			backing configuration store

	* system-settings/plugins/keyfile/nm-keyfile-connection.c
	  system-settings/plugins/keyfile/plugin.c
	  system-settings/plugins/keyfile/writer.c
	  system-settings/plugins/keyfile/writer.h
	  system-settings/plugins/ifcfg-suse/plugin.c
		- Add minimal hostname support

	* system-settings/plugins/ifcfg-fedora/plugin.c
		- Add support for updating system hostname in /etc/sysconfig/network



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3941 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 1cb8b4a1
2008-08-12 Dan Williams <dcbw@redhat.com>
* introspection/nm-settings-system.xml
system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- Add a 'Hostname' property (rw) which represents the configured
hostname and domain of the system, if any
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Add a 'hostname' property to the plugin interface
- Add a method to send updated hostname to plugins to save in their
backing configuration store
* system-settings/plugins/keyfile/nm-keyfile-connection.c
system-settings/plugins/keyfile/plugin.c
system-settings/plugins/keyfile/writer.c
system-settings/plugins/keyfile/writer.h
system-settings/plugins/ifcfg-suse/plugin.c
- Add minimal hostname support
* system-settings/plugins/ifcfg-fedora/plugin.c
- Add support for updating system hostname in /etc/sysconfig/network
2008-08-12 Dan Williams <dcbw@redhat.com>
* system-settings/plugins/ifcfg-fedora/shvar.c
......
......@@ -8,14 +8,27 @@
<method name="AddConnection">
<tp:docstring>
Add new connection.
Add new connection.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_add_connection"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="connection" type="a{sa{sv}}" direction="in">
<tp:docstring>
Connection properties.
</tp:docstring>
<tp:docstring>
Connection properties.
</tp:docstring>
</arg>
</method>
<method name="SetHostname">
<tp:docstring>
Sets the configured machine hostname and domain.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_set_hostname"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="hostname" type="s" direction="in">
<tp:docstring>
Fully-qualified hostname to set in configuration. To clear hostname, pass a zero-length string. Example: "mycomputer.foobar.com"
</tp:docstring>
</arg>
</method>
......@@ -25,6 +38,12 @@
</tp:docstring>
</property>
<property name="Hostname" type="s" access="readwrite">
<tp:docstring>
The configured hostname of the machine.
</tp:docstring>
</property>
<signal name="PropertiesChanged">
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
<tp:docstring>
......
......@@ -44,8 +44,10 @@
#include "plugin.h"
#include "nm-system-config-interface.h"
#include "nm-ifcfg-connection.h"
#include "shvar.h"
#define IFCFG_DIR SYSCONFDIR"/sysconfig/network-scripts/"
#define NETWORK_FILE SYSCONFDIR"/sysconfig/network"
static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class);
......@@ -73,9 +75,13 @@ typedef struct {
NMSystemConfigHalManager *hal_mgr;
GHashTable *connections;
char *hostname;
GFileMonitor *monitor;
guint monitor_id;
GFileMonitor *ifcfg_monitor;
guint ifcfg_monitor_id;
GFileMonitor *network_monitor;
guint network_monitor_id;
} SCPluginIfcfgPrivate;
......@@ -416,22 +422,120 @@ dir_changed (GFileMonitor *monitor,
g_free (name);
}
static void
read_hostname (SCPluginIfcfg *plugin, gboolean notify)
{
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
shvarFile *network;
char *new_hostname;
gboolean changed = FALSE;
network = svNewFile (NETWORK_FILE);
if (!network)
return;
new_hostname = svGetValue (network, "HOSTNAME");
if (new_hostname && strlen (new_hostname)) {
g_free (priv->hostname);
priv->hostname = new_hostname;
changed = TRUE;
} else
g_free (new_hostname);
svCloseFile (network);
if (changed) {
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "system hostname '%s'.", priv->hostname);
if (notify)
g_object_notify (G_OBJECT (plugin), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
}
}
static gboolean
write_hostname (SCPluginIfcfg *plugin, const char *hostname, GError **error)
{
shvarFile *network;
gboolean success = FALSE;
network = svNewFile (NETWORK_FILE);
if (!network) {
/* May not be created; try to create it */
network = svCreateFile (NETWORK_FILE);
if (!network)
return FALSE;
}
svSetValue (network, "HOSTNAME", hostname);
if (svWriteFile (network, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) == 0)
success = TRUE;
svCloseFile (network);
return success;
}
static void
network_changed (GFileMonitor *monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
gpointer user_data)
{
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data);
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
switch (event_type) {
case G_FILE_MONITOR_EVENT_DELETED:
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "system hostname cleared.");
g_free (priv->hostname);
priv->hostname = NULL;
g_object_notify (G_OBJECT (plugin), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
break;
case G_FILE_MONITOR_EVENT_CREATED:
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
read_hostname (plugin, TRUE);
break;
default:
break;
}
}
static void
setup_monitoring (SCPluginIfcfg *plugin)
{
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
GFile *file;
GFileMonitor *monitor;
GError *error = NULL;
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
/* monitor the ifcfg file directory */
file = g_file_new_for_path (IFCFG_DIR);
monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &error);
g_object_unref (file);
if (monitor) {
priv->monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), plugin);
priv->monitor = monitor;
priv->ifcfg_monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), plugin);
priv->ifcfg_monitor = monitor;
} else {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "unable to monitor %s for changes: (%d) %s.",
IFCFG_DIR, error->code, error->message);
g_error_free (error);
error = NULL;
}
/* monitor the 'network' file */
file = g_file_new_for_path (NETWORK_FILE);
monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
g_object_unref (file);
if (monitor) {
priv->network_monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (network_changed), plugin);
priv->network_monitor = monitor;
} else {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "unable to monitor %s for changes: (%d) %s.",
NETWORK_FILE, error->code, error->message);
g_error_free (error);
error = NULL;
}
}
......@@ -462,6 +566,12 @@ get_connections (NMSystemConfigInterface *config)
return list;
}
static gboolean
set_hostname (NMSystemConfigInterface *config, const char *hostname, GError **error)
{
return write_hostname (SC_PLUGIN_IFCFG (config), hostname, error);
}
static void
init (NMSystemConfigInterface *config, NMSystemConfigHalManager *hal_manager)
{
......@@ -483,6 +593,8 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
error->message ? error->message : "(unknown)");
g_error_free (error);
}
read_hostname (plugin, FALSE);
}
static void
......@@ -499,12 +611,22 @@ dispose (GObject *object)
if (priv->connections)
g_hash_table_destroy (priv->connections);
if (priv->monitor) {
if (priv->monitor_id)
g_signal_handler_disconnect (priv->monitor, priv->monitor_id);
g_free (priv->hostname);
if (priv->ifcfg_monitor) {
if (priv->ifcfg_monitor_id)
g_signal_handler_disconnect (priv->ifcfg_monitor, priv->ifcfg_monitor_id);
g_file_monitor_cancel (priv->ifcfg_monitor);
g_object_unref (priv->ifcfg_monitor);
}
if (priv->network_monitor) {
if (priv->network_monitor_id)
g_signal_handler_disconnect (priv->network_monitor, priv->network_monitor_id);
g_file_monitor_cancel (priv->monitor);
g_object_unref (priv->monitor);
g_file_monitor_cancel (priv->network_monitor);
g_object_unref (priv->network_monitor);
}
G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object);
......@@ -520,6 +642,9 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object);
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
switch (prop_id) {
case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME:
g_value_set_string (value, IFCFG_PLUGIN_NAME);
......@@ -527,6 +652,31 @@ get_property (GObject *object, guint prop_id,
case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO:
g_value_set_string (value, IFCFG_PLUGIN_INFO);
break;
case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:
g_value_set_string (value, priv->hostname);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object);
GError *error = NULL;
switch (prop_id) {
case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:
if (!write_hostname (plugin, g_value_get_string (value), &error)) {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not save hostname: %s",
(error && error->message) ? error->message : "(unknown)");
if (error)
g_error_free (error);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -543,6 +693,7 @@ sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
object_class->dispose = dispose;
object_class->finalize = finalize;
object_class->get_property = get_property;
object_class->set_property = set_property;
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME,
......@@ -551,6 +702,10 @@ sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO,
NM_SYSTEM_CONFIG_INTERFACE_INFO);
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME,
NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
}
static void
......@@ -559,6 +714,7 @@ system_config_interface_init (NMSystemConfigInterface *system_config_interface_c
/* interface implementation */
system_config_interface_class->get_connections = get_connections;
system_config_interface_class->get_unmanaged_devices = get_unmanaged_devices;
system_config_interface_class->set_hostname = set_hostname;
system_config_interface_class->init = init;
}
......
......@@ -65,6 +65,7 @@ typedef struct {
gboolean initialized;
GHashTable *connections;
GHashTable *unmanaged_devices;
char *hostname;
guint32 default_gw;
GFileMonitor *default_gw_monitor;
......@@ -351,6 +352,7 @@ dispose (GObject *object)
g_hash_table_destroy (priv->connections);
g_hash_table_destroy (priv->unmanaged_devices);
g_free (priv->hostname);
if (priv->default_gw_monitor) {
if (priv->default_gw_monitor_id)
......@@ -372,6 +374,8 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (object);
switch (prop_id) {
case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME:
g_value_set_string (value, IFCFG_PLUGIN_NAME);
......@@ -379,6 +383,20 @@ get_property (GObject *object, guint prop_id,
case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO:
g_value_set_string (value, IFCFG_PLUGIN_INFO);
break;
case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:
g_value_set_string (value, priv->hostname);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -393,6 +411,7 @@ sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
g_type_class_add_private (req_class, sizeof (SCPluginIfcfgPrivate));
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->dispose = dispose;
g_object_class_override_property (object_class,
......@@ -402,6 +421,10 @@ sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO,
NM_SYSTEM_CONFIG_INTERFACE_INFO);
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME,
NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
}
static void
......
......@@ -55,14 +55,13 @@ get_id (NMExportedConnection *exported)
static gboolean
update (NMExportedConnection *exported,
GHashTable *new_settings,
GError **err)
GError **error)
{
gboolean success;
success = NM_EXPORTED_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->update (exported, new_settings, err);
success = NM_EXPORTED_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->update (exported, new_settings, error);
if (success)
write_connection (nm_exported_connection_get_connection (exported));
success = write_connection (nm_exported_connection_get_connection (exported), error);
return success;
}
......
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
#include <config.h>
#include <sys/stat.h>
......@@ -36,6 +36,8 @@ G_DEFINE_TYPE_EXTENDED (SCPluginKeyfile, sc_plugin_keyfile, G_TYPE_OBJECT, 0,
typedef struct {
GHashTable *hash;
char *hostname;
GFileMonitor *monitor;
guint monitor_id;
......@@ -182,9 +184,11 @@ get_connections (NMSystemConfigInterface *config)
}
static gboolean
add_connection (NMSystemConfigInterface *config, NMConnection *connection)
add_connection (NMSystemConfigInterface *config,
NMConnection *connection,
GError **error)
{
return write_connection (connection);
return write_connection (connection, error);
}
/* GObject */
......@@ -198,6 +202,8 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (object);
switch (prop_id) {
case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME:
g_value_set_string (value, KEYFILE_PLUGIN_NAME);
......@@ -205,6 +211,20 @@ get_property (GObject *object, guint prop_id,
case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO:
g_value_set_string (value, KEYFILE_PLUGIN_INFO);
break;
case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:
g_value_set_string (value, priv->hostname);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -232,6 +252,8 @@ dispose (GObject *object)
if (priv->hash)
g_hash_table_destroy (priv->hash);
g_free (priv->hostname);
G_OBJECT_CLASS (sc_plugin_keyfile_parent_class)->dispose (object);
}
......@@ -244,6 +266,7 @@ sc_plugin_keyfile_class_init (SCPluginKeyfileClass *req_class)
object_class->dispose = dispose;
object_class->get_property = get_property;
object_class->set_property = set_property;
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME,
......@@ -252,6 +275,10 @@ sc_plugin_keyfile_class_init (SCPluginKeyfileClass *req_class)
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO,
NM_SYSTEM_CONFIG_INTERFACE_INFO);
g_object_class_override_property (object_class,
NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME,
NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
}
static void
......
......@@ -264,7 +264,7 @@ write_setting_value (NMSetting *setting,
}
gboolean
write_connection (NMConnection *connection)
write_connection (NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
GKeyFile *key_file;
......
......@@ -6,6 +6,6 @@
#include <glib.h>
#include <nm-connection.h>
gboolean write_connection (NMConnection *connection);
gboolean write_connection (NMConnection *connection, GError **error);
#endif /* _KEYFILE_PLUGIN_WRITER_H */
This diff is collapsed.
......@@ -39,6 +39,7 @@ typedef struct _NMSysconfigSettingsClass NMSysconfigSettingsClass;
#define NM_SYSCONFIG_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
#define NM_SYSCONFIG_SETTINGS_UNMANAGED_DEVICES "unmanaged-devices"
#define NM_SYSCONFIG_SETTINGS_HOSTNAME "hostname"
struct _NMSysconfigSettings
{
......
......@@ -29,6 +29,8 @@ nm_sysconfig_settings_error_get_type (void)
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_UPDATE_NOT_SUPPORTED, "UpdateNotSupported"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_DELETE_NOT_SUPPORTED, "DeleteNotSupported"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_ADD_FAILED, "AddFailed"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_SET_HOSTNAME_FAILED, "SetHostnameFailed"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_INVALID_HOSTNAME, "InvalidHostname"),
{ 0, 0, 0 }
};
......
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
#ifndef NM_SYSTEM_CONFIG_ERROR_H
#define NM_SYSTEM_CONFIG_ERROR_H
......@@ -13,7 +13,9 @@ enum {
NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
NM_SYSCONFIG_SETTINGS_ERROR_UPDATE_NOT_SUPPORTED,
NM_SYSCONFIG_SETTINGS_ERROR_DELETE_NOT_SUPPORTED,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_FAILED
NM_SYSCONFIG_SETTINGS_ERROR_ADD_FAILED,
NM_SYSCONFIG_SETTINGS_ERROR_SET_HOSTNAME_FAILED,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_HOSTNAME
};
#define NM_SYSCONFIG_SETTINGS_ERROR (nm_sysconfig_settings_error_quark ())
......
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
......@@ -48,6 +48,14 @@ interface_init (gpointer g_iface)
NULL,
G_PARAM_READABLE));
g_object_interface_install_property
(g_iface,
g_param_spec_string (NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME,
"Hostname",
"Configured system hostname",
NULL,
G_PARAM_READWRITE));
/* Signals */
g_signal_new ("connection-added",
iface_type,
......@@ -139,7 +147,8 @@ nm_system_config_interface_supports_add (NMSystemConfigInterface *config)
gboolean
nm_system_config_interface_add_connection (NMSystemConfigInterface *config,
NMConnection *connection)
NMConnection *connection,
GError **error)
{
gboolean success = FALSE;
......@@ -147,7 +156,23 @@ nm_system_config_interface_add_connection (NMSystemConfigInterface *config,
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection)
success = NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection (config, connection);
success = NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection (config, connection, error);
return success;
}
gboolean
nm_system_config_interface_set_hostname (NMSystemConfigInterface *config,
const char *hostname,
GError **error)
{
gboolean success = FALSE;
g_return_val_if_fail (config != NULL, FALSE);
if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->set_hostname)
success = NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->set_hostname (config, hostname, error);
return success;
}
......@@ -60,12 +60,14 @@ GObject * nm_system_config_factory (void);
#define NM_SYSTEM_CONFIG_INTERFACE_NAME "name"
#define NM_SYSTEM_CONFIG_INTERFACE_INFO "info"
#define NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME "hostname"
typedef enum {
NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST = 0x1000,
NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME = NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST,
NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO,
NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME,
} NMSystemConfigInterfaceProp;
......@@ -92,7 +94,13 @@ struct _NMSystemConfigInterface {
/*
* Add a new connection.
*/
gboolean (*add_connection) (NMSystemConfigInterface *config, NMConnection *connection);
gboolean (*add_connection) (NMSystemConfigInterface *config, NMConnection *connection, GError **error);
/*
* Set the configured hostname/domain in the plugin's backing configuration store.
* Should _NOT_ call sethostname(2) or setdomainname(2).
*/
gboolean (*set_hostname) (NMSystemConfigInterface *config, const char *hostname, GError **error);
/* Signals */
......@@ -115,7 +123,12 @@ GSList *nm_system_config_interface_get_unmanaged_devices (NMSystemConfigInterfac
gboolean nm_system_config_interface_supports_add (NMSystemConfigInterface *config);
gboolean nm_system_config_interface_add_connection (NMSystemConfigInterface *config,
NMConnection *connection);
NMConnection *connection,
GError **error);
gboolean nm_system_config_interface_set_hostname (NMSystemConfigInterface *config,
const char *hostname,
GError **error);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment