libnm-glib: remove NMSettingsInterface

NMSettingsInterface was created to allow code to operate on a settings
service without caring about what kind of settings service it was. Now
that we have just one settings service, this is no longer needed.

More work needs to be done in order to handle errors and permission
settings in an appropriate manner.
This commit is contained in:
Daniel Gnoutcheff 2010-08-03 13:23:30 -04:00
parent aee48901f4
commit c2f4b10ab5
18 changed files with 417 additions and 709 deletions

View file

@ -45,7 +45,6 @@
#include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h>
#include <nm-remote-settings.h>
#include <nm-settings-interface.h>
#include <nm-settings-connection-interface.h>
#include <nm-vpn-connection.h>
@ -141,7 +140,7 @@ static gboolean find_device_for_connection (NmCli *nmc, NMConnection *connection
static const char *active_connection_state_to_string (NMActiveConnectionState state);
static void active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpointer user_data);
static void activate_connection_cb (gpointer user_data, const char *path, GError *error);
static void get_connections_cb (NMSettingsInterface *settings, gpointer user_data);
static void get_connections_cb (NMRemoteSettings *settings, gpointer user_data);
static NMCResultCode do_connections_list (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_connections_status (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_connection_up (NmCli *nmc, int argc, char **argv);
@ -1454,12 +1453,12 @@ error:
/* callback called when connections are obtained from the settings service */
static void
get_connections_cb (NMSettingsInterface *settings, gpointer user_data)
get_connections_cb (NMRemoteSettings *settings, gpointer user_data)
{
ArgsInfo *args = (ArgsInfo *) user_data;
GError *error = NULL;
args->nmc->system_connections = nm_settings_interface_list_connections (settings);
args->nmc->system_connections = nm_remote_settings_list_connections (settings);
if (args->argc == 0) {
if (!nmc_terse_option_check (args->nmc->print_output, args->nmc->required_fields, &error))
@ -1545,7 +1544,7 @@ do_connections (NmCli *nmc, int argc, char **argv)
}
/* connect to signal "connections-read" - emitted when connections are fetched and ready */
g_signal_connect (nmc->system_settings, NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
g_signal_connect (nmc->system_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
G_CALLBACK (get_connections_cb), &args_info);

View file

@ -35,7 +35,6 @@
#include <nm-client.h>
#include <nm-setting-connection.h>
#include <nm-remote-settings.h>
#include <nm-settings-interface.h>
#include <nm-settings-connection-interface.h>
#include "nmcli.h"

View file

@ -32,7 +32,6 @@
<xi:include href="xml/nm-remote-connection.xml"/>
<xi:include href="xml/nm-remote-settings.xml"/>
<xi:include href="xml/nm-settings-connection-interface.xml"/>
<xi:include href="xml/nm-settings-interface.xml"/>
<xi:include href="xml/nm-settings-service.xml"/>
<xi:include href="xml/nm-types.xml"/>
<xi:include href="xml/nm-vpn-connection.xml"/>

View file

@ -76,7 +76,6 @@ libnminclude_HEADERS = \
nm-ip6-config.h \
nm-dhcp6-config.h \
nm-remote-connection.h \
nm-settings-interface.h \
nm-remote-settings.h \
nm-settings-connection-interface.h
@ -107,7 +106,6 @@ libnm_glib_la_SOURCES = \
nm-dhcp6-config.c \
nm-remote-connection.c \
nm-remote-connection-private.h \
nm-settings-interface.c \
nm-remote-settings.c \
nm-settings-connection-interface.c

View file

@ -118,6 +118,11 @@ global:
nm_object_get_type;
nm_remote_connection_get_type;
nm_remote_connection_new;
nm_remote_settings_add_connection;
nm_remote_settings_get_connection_by_path;
nm_remote_settings_list_connections;
nm_remote_settings_get_permissions;
nm_remote_settings_save_hostname;
nm_remote_settings_get_type;
nm_remote_settings_new;
nm_serial_device_get_bytes_received;
@ -128,14 +133,6 @@ global:
nm_settings_connection_interface_get_secrets;
nm_settings_connection_interface_get_type;
nm_settings_connection_interface_update;
nm_settings_interface_add_connection;
nm_settings_interface_error_get_type;
nm_settings_interface_error_quark;
nm_settings_interface_get_connection_by_path;
nm_settings_interface_get_type;
nm_settings_interface_list_connections;
nm_settings_interface_get_permissions;
nm_settings_interface_save_hostname;
nm_settings_error_quark;
nm_settings_get_type;
nm_settings_list_connections;

View file

@ -29,13 +29,9 @@
#include "nm-dbus-glib-types.h"
#include "nm-remote-settings.h"
#include "nm-settings-bindings.h"
#include "nm-settings-interface.h"
#include "nm-remote-connection-private.h"
static void settings_interface_init (NMSettingsInterface *class);
G_DEFINE_TYPE_EXTENDED (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE, settings_interface_init))
G_DEFINE_TYPE (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT)
#define NM_REMOTE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsPrivate))
@ -64,13 +60,39 @@ enum {
PROP_0,
PROP_BUS,
PROP_SERVICE_RUNNING,
PROP_HOSTNAME,
PROP_CAN_MODIFY,
LAST_PROP
};
static NMSettingsConnectionInterface *
get_connection_by_path (NMSettingsInterface *settings, const char *path)
/* Signals */
enum {
NEW_CONNECTION,
CONNECTIONS_READ,
CHECK_PERMISSIONS,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
/**
* nm_remote_settings_get_connection_by_path:
* @settings: the %NMRemoteSettings
* @path: the D-Bus object path of the remote connection
*
* Returns the %NMRemoteConnection representing the connection at @path.
*
* Returns: the remote connection object on success, or NULL if the object was
* not known
**/
NMRemoteConnection *
nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, const char *path)
{
g_return_val_if_fail (settings != NULL, NULL);
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
g_return_val_if_fail (path != NULL, NULL);
return g_hash_table_lookup (NM_REMOTE_SETTINGS_GET_PRIVATE (settings)->connections, path);
}
@ -121,7 +143,7 @@ connection_init_result_cb (NMRemoteConnection *remote,
/* Finally, let users know of the new connection now that it has all
* its settings and is valid.
*/
g_signal_emit_by_name (self, "new-connection", remote);
g_signal_emit (self, signals[NEW_CONNECTION], 0, remote);
break;
case NM_REMOTE_CONNECTION_INIT_RESULT_ERROR:
default:
@ -132,7 +154,7 @@ connection_init_result_cb (NMRemoteConnection *remote,
/* Let listeners know that all connections have been found */
if (!g_hash_table_size (priv->pending))
g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ);
g_signal_emit (self, signals[CONNECTIONS_READ], 0);
}
static void
@ -180,7 +202,7 @@ fetch_connections_done (DBusGProxy *proxy,
/* Let listeners know we are done getting connections */
if (connections->len == 0) {
g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ);
g_signal_emit (self, signals[CONNECTIONS_READ], 0);
return;
}
@ -207,14 +229,26 @@ fetch_connections (gpointer user_data)
return FALSE;
}
static GSList *
list_connections (NMSettingsInterface *settings)
/**
* nm_remote_settings_list_connections:
* @settings: the %NMRemoteSettings
*
* Returns: all connections in the remote settings service, represented as
* %NMRemoteConnection instances
**/
GSList *
nm_remote_settings_list_connections (NMRemoteSettings *settings)
{
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
NMRemoteSettingsPrivate *priv;
GSList *list = NULL;
GHashTableIter iter;
gpointer value;
g_return_val_if_fail (settings != NULL, NULL);
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, NULL, &value))
list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
@ -223,8 +257,8 @@ list_connections (NMSettingsInterface *settings)
}
typedef struct {
NMSettingsInterface *self;
NMSettingsAddConnectionFunc callback;
NMRemoteSettings *self;
NMRemoteSettingsAddConnectionFunc callback;
gpointer callback_data;
} AddConnectionInfo;
@ -238,18 +272,37 @@ add_connection_done (DBusGProxy *proxy,
info->callback (info->self, error, info->callback_data);
g_free (info);
}
static gboolean
add_connection (NMSettingsInterface *settings,
NMConnection *connection,
NMSettingsAddConnectionFunc callback,
gpointer user_data)
/**
* nm_remote_settings_add_connection:
* @settings: the %NMRemoteSettings
* @connection: the connection to add. Note that this object's settings will be
* added, not the object itself
* @callback: callback to be called when the add operation completes
* @user_data: caller-specific data passed to @callback
*
* Requests that the remote settings service add the given settings to a new
* connection.
*
* Returns: TRUE if the request was successful, FALSE if it failed
**/
gboolean
nm_remote_settings_add_connection (NMRemoteSettings *settings,
NMConnection *connection,
NMRemoteSettingsAddConnectionFunc callback,
gpointer user_data)
{
NMRemoteSettings *self = NM_REMOTE_SETTINGS (settings);
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
NMRemoteSettingsPrivate *priv;
AddConnectionInfo *info;
GHashTable *new_settings;
g_return_val_if_fail (settings != NULL, FALSE);
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
g_return_val_if_fail (connection != NULL, FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
info = g_malloc0 (sizeof (AddConnectionInfo));
info->self = settings;
info->callback = callback;
@ -291,8 +344,8 @@ remove_connections (gpointer user_data)
}
typedef struct {
NMSettingsInterface *settings;
NMSettingsSaveHostnameFunc callback;
NMRemoteSettings *settings;
NMRemoteSettingsSaveHostnameFunc callback;
gpointer callback_data;
} SaveHostnameInfo;
@ -309,16 +362,35 @@ save_hostname_cb (DBusGProxy *proxy,
g_clear_error (&error);
}
static gboolean
save_hostname (NMSettingsInterface *settings,
const char *hostname,
NMSettingsSaveHostnameFunc callback,
gpointer user_data)
/**
* nm_remote_settings_save_hostname:
* @settings: the %NMRemoteSettings
* @hostname: the new persistent hostname to set, or NULL to clear any existing
* persistent hostname
* @callback: callback to be called when the hostname operation completes
* @user_data: caller-specific data passed to @callback
*
* Requests that the machine's persistent hostname be set to the specified value
* or cleared.
*
* Returns: TRUE if the request was successful, FALSE if it failed
**/
gboolean
nm_remote_settings_save_hostname (NMRemoteSettings *settings,
const char *hostname,
NMRemoteSettingsSaveHostnameFunc callback,
gpointer user_data)
{
NMRemoteSettings *self = NM_REMOTE_SETTINGS (settings);
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
NMRemoteSettingsPrivate *priv;
SaveHostnameInfo *info;
g_return_val_if_fail (settings != NULL, FALSE);
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
g_return_val_if_fail (hostname != NULL, FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
info = g_malloc0 (sizeof (SaveHostnameInfo));
info->settings = settings;
info->callback = callback;
@ -334,8 +406,8 @@ save_hostname (NMSettingsInterface *settings,
}
typedef struct {
NMSettingsInterface *settings;
NMSettingsGetPermissionsFunc callback;
NMRemoteSettings *settings;
NMRemoteSettingsGetPermissionsFunc callback;
gpointer callback_data;
} GetPermissionsInfo;
@ -359,14 +431,31 @@ get_permissions_cb (DBusGProxy *proxy,
g_clear_error (&error);
}
static gboolean
get_permissions (NMSettingsInterface *settings,
NMSettingsGetPermissionsFunc callback,
gpointer user_data)
/**
* nm_remote_settings_get_permissions:
* @settings: the %NMRemoteSettings
* @callback: callback to be called when the permissions operation completes
* @user_data: caller-specific data passed to @callback
*
* Requests an indication of the operations the caller is permitted to perform
* including those that may require authorization.
*
* Returns: TRUE if the request was successful, FALSE if it failed
**/
gboolean
nm_remote_settings_get_permissions (NMRemoteSettings *settings,
NMRemoteSettingsGetPermissionsFunc callback,
gpointer user_data)
{
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
NMRemoteSettingsPrivate *priv;
GetPermissionsInfo *info;
g_return_val_if_fail (settings != NULL, FALSE);
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
/* Skip D-Bus if we already have permissions */
if (priv->have_permissions) {
callback (settings, priv->permissions, NULL, user_data);
@ -421,7 +510,7 @@ check_permissions_cb (DBusGProxy *proxy, gpointer user_data)
/* Permissions need to be re-fetched */
priv->have_permissions = FALSE;
g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CHECK_PERMISSIONS);
g_signal_emit (self, signals[CHECK_PERMISSIONS], 0);
}
static void
@ -441,12 +530,12 @@ properties_changed_cb (DBusGProxy *proxy,
if (!strcmp ((const char *) key, "Hostname")) {
g_free (priv->hostname);
priv->hostname = g_value_dup_string (value);
g_object_notify (G_OBJECT (self), NM_SETTINGS_INTERFACE_HOSTNAME);
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME);
}
if (!strcmp ((const char *) key, "CanModify")) {
priv->can_modify = g_value_get_boolean (value);
g_object_notify (G_OBJECT (self), NM_SETTINGS_INTERFACE_CAN_MODIFY);
g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY);
}
}
}
@ -482,17 +571,6 @@ get_all_cb (DBusGProxy *proxy,
/****************************************************************/
static void
settings_interface_init (NMSettingsInterface *iface)
{
/* interface implementation */
iface->list_connections = list_connections;
iface->get_connection_by_path = get_connection_by_path;
iface->add_connection = add_connection;
iface->save_hostname = save_hostname;
iface->get_permissions = get_permissions;
}
/**
* nm_remote_settings_new:
* @bus: a valid and connected D-Bus connection
@ -682,10 +760,10 @@ get_property (GObject *object, guint prop_id,
case PROP_SERVICE_RUNNING:
g_value_set_boolean (value, priv->service_running);
break;
case NM_SETTINGS_INTERFACE_PROP_HOSTNAME:
case PROP_HOSTNAME:
g_value_set_string (value, priv->hostname);
break;
case NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY:
case PROP_CAN_MODIFY:
g_value_set_boolean (value, priv->can_modify);
break;
default:
@ -724,13 +802,48 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class)
FALSE,
G_PARAM_READABLE));
g_object_class_override_property (object_class,
NM_SETTINGS_INTERFACE_PROP_HOSTNAME,
NM_SETTINGS_INTERFACE_HOSTNAME);
g_object_class_install_property
(object_class, PROP_HOSTNAME,
g_param_spec_string (NM_REMOTE_SETTINGS_HOSTNAME,
"Hostname",
"Persistent hostname",
NULL,
G_PARAM_READABLE));
g_object_class_override_property (object_class,
NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY,
NM_SETTINGS_INTERFACE_CAN_MODIFY);
g_object_class_install_property
(object_class, PROP_CAN_MODIFY,
g_param_spec_boolean (NM_REMOTE_SETTINGS_CAN_MODIFY,
"CanModify",
"Can modify anything (hostname, connections, etc)",
FALSE,
G_PARAM_READABLE));
/* Signals */
signals[NEW_CONNECTION] =
g_signal_new (NM_REMOTE_SETTINGS_NEW_CONNECTION,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMRemoteSettingsClass, new_connection),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
signals[CONNECTIONS_READ] =
g_signal_new (NM_REMOTE_SETTINGS_CONNECTIONS_READ,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMRemoteSettingsClass, connections_read),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[CHECK_PERMISSIONS] =
g_signal_new (NM_REMOTE_SETTINGS_CHECK_PERMISSIONS,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMRemoteSettingsClass, check_permissions),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}

View file

@ -31,6 +31,15 @@
G_BEGIN_DECLS
// FIXME this is temporary, permissions format to be improved
typedef enum {
NM_SETTINGS_PERMISSION_NONE = 0x0,
NM_SETTINGS_PERMISSION_CONNECTION_MODIFY = 0x1,
NM_SETTINGS_PERMISSION_WIFI_SHARE_PROTECTED = 0x2,
NM_SETTINGS_PERMISSION_WIFI_SHARE_OPEN = 0x4,
NM_SETTINGS_PERMISSION_HOSTNAME_MODIFY = 0x8
} NMSettingsPermissions;
#define NM_TYPE_REMOTE_SETTINGS (nm_remote_settings_get_type ())
#define NM_REMOTE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettings))
#define NM_REMOTE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass))
@ -38,16 +47,48 @@ G_BEGIN_DECLS
#define NM_IS_REMOTE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS))
#define NM_REMOTE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass))
#define NM_REMOTE_SETTINGS_BUS "bus"
#define NM_REMOTE_SETTINGS_BUS "bus"
#define NM_REMOTE_SETTINGS_SERVICE_RUNNING "service-running"
#define NM_REMOTE_SETTINGS_HOSTNAME "hostname"
#define NM_REMOTE_SETTINGS_CAN_MODIFY "can-modify"
typedef struct {
#define NM_REMOTE_SETTINGS_NEW_CONNECTION "new-connection"
#define NM_REMOTE_SETTINGS_CONNECTIONS_READ "connections-read"
#define NM_REMOTE_SETTINGS_CHECK_PERMISSIONS "check-permissions"
typedef struct _NMRemoteSettings NMRemoteSettings;
typedef struct _NMRemoteSettingsClass NMRemoteSettingsClass;
typedef void (*NMRemoteSettingsAddConnectionFunc) (NMRemoteSettings *settings,
GError *error,
gpointer user_data);
typedef void (*NMRemoteSettingsSaveHostnameFunc) (NMRemoteSettings *settings,
GError *error,
gpointer user_data);
typedef void (*NMRemoteSettingsGetPermissionsFunc) (NMRemoteSettings *settings,
NMSettingsPermissions permissions,
GError *error,
gpointer user_data);
struct _NMRemoteSettings {
GObject parent;
} NMRemoteSettings;
};
typedef struct {
struct _NMRemoteSettingsClass {
GObjectClass parent;
/* Signals */
void (*new_connection) (NMRemoteSettings *settings,
NMRemoteConnection *connection);
void (*connections_read) (NMRemoteSettings *settings);
void (*check_permissions) (NMRemoteSettings *settings);
/* Padding for future expansion */
void (*_reserved1) (void);
void (*_reserved2) (void);
@ -55,12 +96,31 @@ typedef struct {
void (*_reserved4) (void);
void (*_reserved5) (void);
void (*_reserved6) (void);
} NMRemoteSettingsClass;
};
GType nm_remote_settings_get_type (void);
NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus);
GSList * nm_remote_settings_list_connections (NMRemoteSettings *settings);
NMRemoteConnection * nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings,
const char *path);
gboolean nm_remote_settings_add_connection (NMRemoteSettings *self,
NMConnection *connection,
NMRemoteSettingsAddConnectionFunc callback,
gpointer user_data);
gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings,
const char *hostname,
NMRemoteSettingsSaveHostnameFunc callback,
gpointer user_data);
gboolean nm_remote_settings_get_permissions (NMRemoteSettings *settings,
NMRemoteSettingsGetPermissionsFunc callback,
gpointer user_data);
G_END_DECLS
#endif /* NM_REMOTE_SETTINGS_H */

View file

@ -1,290 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include "nm-settings-interface.h"
/**
* nm_settings_interface_error_quark:
*
* Setting error quark.
*
* Returns: the setting error quark
**/
GQuark
nm_settings_interface_error_quark (void)
{
static GQuark quark;
if (G_UNLIKELY (!quark))
quark = g_quark_from_static_string ("nm-settings-interface-error-quark");
return quark;
}
/* This should really be standard. */
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
GType
nm_settings_interface_error_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
/* The connection was invalid. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION, "InvalidConnection"),
/* The connection is read-only; modifications are not allowed. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION, "ReadOnlyConnection"),
/* A bug in the settings service caused the error. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, "InternalError"),
/* Retrieval or request of secrets failed. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE, "SecretsUnavailable"),
/* The request for secrets was canceled. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED, "SecretsRequestCanceled"),
/* The request could not be completed because permission was denied. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED, "PermissionDenied"),
/* The requested setting does not existing in this connection. */
ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING, "InvalidSetting"),
{ 0, 0, 0 },
};
etype = g_enum_register_static ("NMSettingsInterfaceError", values);
}
return etype;
}
/**
* nm_settings_list_connections:
* @settings: a object implementing %NMSettingsInterface
*
* Returns: all connections known to the object.
**/
GSList *
nm_settings_interface_list_connections (NMSettingsInterface *settings)
{
g_return_val_if_fail (settings != NULL, NULL);
g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), NULL);
if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->list_connections)
return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->list_connections (settings);
return NULL;
}
/**
* nm_settings_get_connection_by_path:
* @settings: a object implementing %NMSettingsInterface
* @path: the D-Bus object path of the remote connection
*
* Returns the object implementing %NMSettingsConnectionInterface at @path.
*
* Returns: the remote connection object on success, or NULL if the object was
* not known
**/
NMSettingsConnectionInterface *
nm_settings_interface_get_connection_by_path (NMSettingsInterface *settings,
const char *path)
{
g_return_val_if_fail (settings != NULL, NULL);
g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), NULL);
g_return_val_if_fail (path != NULL, NULL);
if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_connection_by_path)
return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_connection_by_path (settings, path);
return NULL;
}
/**
* nm_settings_interface_add_connection:
* @settings: a object implementing %NMSettingsInterface
* @connection: the settings to add; note that this object's settings will be
* added, not the object itself
* @callback: callback to be called when the add operation completes
* @user_data: caller-specific data passed to @callback
*
* Requests that the settings service add the given settings to a new connection.
*
* Returns: TRUE if the request was successful, FALSE if it failed
**/
gboolean
nm_settings_interface_add_connection (NMSettingsInterface *settings,
NMConnection *connection,
NMSettingsAddConnectionFunc callback,
gpointer user_data)
{
g_return_val_if_fail (settings != NULL, FALSE);
g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), FALSE);
g_return_val_if_fail (connection != NULL, FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->add_connection) {
return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->add_connection (settings,
connection,
callback,
user_data);
}
return FALSE;
}
/**
* nm_settings_interface_save_hostname:
* @settings: a object implementing %NMSettingsInterface
* @hostname: the new persistent hostname to set, or NULL to clear any existing
* persistent hostname
* @callback: callback to be called when the hostname operation completes
* @user_data: caller-specific data passed to @callback
*
* Requests that the machine's persistent hostname be set to the specified value
* or cleared.
*
* Returns: TRUE if the request was successful, FALSE if it failed
**/
gboolean
nm_settings_interface_save_hostname (NMSettingsInterface *settings,
const char *hostname,
NMSettingsSaveHostnameFunc callback,
gpointer user_data)
{
g_return_val_if_fail (settings != NULL, FALSE);
g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), FALSE);
g_return_val_if_fail (hostname != NULL, FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->save_hostname) {
return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->save_hostname (settings,
hostname,
callback,
user_data);
}
return FALSE;
}
/**
* nm_settings_interface_get_permissions:
* @settings: a object implementing %NMSettingsInterface
* @callback: callback to be called when the permissions operation completes
* @user_data: caller-specific data passed to @callback
*
* Requests an indication of the operations the caller is permitted to perform
* including those that may require authorization.
*
* Returns: TRUE if the request was successful, FALSE if it failed
**/
gboolean
nm_settings_interface_get_permissions (NMSettingsInterface *settings,
NMSettingsGetPermissionsFunc callback,
gpointer user_data)
{
g_return_val_if_fail (settings != NULL, FALSE);
g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), FALSE);
g_return_val_if_fail (callback != NULL, FALSE);
if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_permissions)
return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_permissions (settings, callback, user_data);
return FALSE;
}
/*****************************************************************/
static void
nm_settings_interface_init (gpointer g_iface)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
static gboolean initialized = FALSE;
if (initialized)
return;
/* Properties */
g_object_interface_install_property
(g_iface,
g_param_spec_string (NM_SETTINGS_INTERFACE_HOSTNAME,
"Hostname",
"Persistent hostname",
NULL,
G_PARAM_READABLE));
g_object_interface_install_property
(g_iface,
g_param_spec_boolean (NM_SETTINGS_INTERFACE_CAN_MODIFY,
"CanModify",
"Can modify anything (hostname, connections, etc)",
FALSE,
G_PARAM_READABLE));
/* Signals */
g_signal_new (NM_SETTINGS_INTERFACE_NEW_CONNECTION,
iface_type,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMSettingsInterface, new_connection),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_signal_new (NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
iface_type,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMSettingsInterface, connections_read),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new (NM_SETTINGS_INTERFACE_CHECK_PERMISSIONS,
iface_type,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMSettingsInterface, check_permissions),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
initialized = TRUE;
}
GType
nm_settings_interface_get_type (void)
{
static GType settings_interface_type = 0;
if (!settings_interface_type) {
const GTypeInfo settings_interface_info = {
sizeof (NMSettingsInterface), /* class_size */
nm_settings_interface_init, /* base_init */
NULL, /* base_finalize */
NULL,
NULL, /* class_finalize */
NULL, /* class_data */
0,
0, /* n_preallocs */
NULL
};
settings_interface_type = g_type_register_static (G_TYPE_INTERFACE,
"NMSettingsInterface",
&settings_interface_info, 0);
g_type_interface_add_prerequisite (settings_interface_type, G_TYPE_OBJECT);
}
return settings_interface_type;
}

View file

@ -1,158 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#ifndef NM_SETTINGS_INTERFACE_H
#define NM_SETTINGS_INTERFACE_H
#include <glib-object.h>
#include "NetworkManager.h"
#include "nm-settings-connection-interface.h"
G_BEGIN_DECLS
typedef enum {
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION = 0,
NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED,
NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING,
} NMSettingsInterfaceError;
#define NM_SETTINGS_INTERFACE_ERROR (nm_settings_interface_error_quark ())
GQuark nm_settings_interface_error_quark (void);
#define NM_TYPE_SETTINGS_INTERFACE_ERROR (nm_settings_interface_error_get_type ())
GType nm_settings_interface_error_get_type (void);
typedef enum {
NM_SETTINGS_PERMISSION_NONE = 0x0,
NM_SETTINGS_PERMISSION_CONNECTION_MODIFY = 0x1,
NM_SETTINGS_PERMISSION_WIFI_SHARE_PROTECTED = 0x2,
NM_SETTINGS_PERMISSION_WIFI_SHARE_OPEN = 0x4,
NM_SETTINGS_PERMISSION_HOSTNAME_MODIFY = 0x8
} NMSettingsPermissions;
#define NM_TYPE_SETTINGS_INTERFACE (nm_settings_interface_get_type ())
#define NM_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_INTERFACE, NMSettingsInterface))
#define NM_IS_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_INTERFACE))
#define NM_SETTINGS_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_INTERFACE, NMSettingsInterface))
#define NM_SETTINGS_INTERFACE_NEW_CONNECTION "new-connection"
#define NM_SETTINGS_INTERFACE_CONNECTIONS_READ "connections-read"
#define NM_SETTINGS_INTERFACE_CHECK_PERMISSIONS "check-permissions"
#define NM_SETTINGS_INTERFACE_HOSTNAME "hostname"
#define NM_SETTINGS_INTERFACE_CAN_MODIFY "can-modify"
typedef enum {
NM_SETTINGS_INTERFACE_PROP_FIRST = 0x1000,
NM_SETTINGS_INTERFACE_PROP_HOSTNAME = NM_SETTINGS_INTERFACE_PROP_FIRST,
NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY
} NMSettingsInterfaceProp;
typedef struct _NMSettingsInterface NMSettingsInterface;
typedef void (*NMSettingsAddConnectionFunc) (NMSettingsInterface *settings,
GError *error,
gpointer user_data);
typedef void (*NMSettingsSaveHostnameFunc) (NMSettingsInterface *settings,
GError *error,
gpointer user_data);
typedef void (*NMSettingsGetPermissionsFunc) (NMSettingsInterface *settings,
NMSettingsPermissions permissions,
GError *error,
gpointer user_data);
struct _NMSettingsInterface {
GTypeInterface g_iface;
/* Methods */
/* Returns a list of objects implementing NMSettingsConnectionInterface */
GSList * (*list_connections) (NMSettingsInterface *settings);
NMSettingsConnectionInterface * (*get_connection_by_path) (NMSettingsInterface *settings,
const char *path);
gboolean (*add_connection) (NMSettingsInterface *settings,
NMConnection *connection,
NMSettingsAddConnectionFunc callback,
gpointer user_data);
gboolean (*save_hostname) (NMSettingsInterface *settings,
const char *hostname,
NMSettingsSaveHostnameFunc callback,
gpointer user_data);
gboolean (*get_permissions) (NMSettingsInterface *settings,
NMSettingsGetPermissionsFunc callback,
gpointer user_data);
/* Signals */
void (*new_connection) (NMSettingsInterface *settings,
NMSettingsConnectionInterface *connection);
void (*connections_read) (NMSettingsInterface *settings);
void (*check_permissions) (NMSettingsInterface *settings);
/* Padding for future expansion */
void (*_reserved1) (void);
void (*_reserved2) (void);
void (*_reserved3) (void);
void (*_reserved4) (void);
void (*_reserved5) (void);
void (*_reserved6) (void);
};
GType nm_settings_interface_get_type (void);
/* Returns a list of objects implementing NMSettingsConnectionInterface */
GSList *nm_settings_interface_list_connections (NMSettingsInterface *settings);
NMSettingsConnectionInterface *nm_settings_interface_get_connection_by_path (NMSettingsInterface *settings,
const char *path);
gboolean nm_settings_interface_add_connection (NMSettingsInterface *settings,
NMConnection *connection,
NMSettingsAddConnectionFunc callback,
gpointer user_data);
gboolean nm_settings_interface_save_hostname (NMSettingsInterface *settings,
const char *hostname,
NMSettingsSaveHostnameFunc callback,
gpointer user_data);
gboolean nm_settings_interface_get_permissions (NMSettingsInterface *settings,
NMSettingsGetPermissionsFunc callback,
gpointer user_data);
G_END_DECLS
#endif /* NM_SETTINGS_INTERFACE_H */

View file

@ -51,8 +51,8 @@
#include "nm-bluez-manager.h"
#include "nm-bluez-common.h"
#include "nm-sysconfig-settings.h"
#include "nm-sysconfig-connection.h"
#include "nm-secrets-provider-interface.h"
#include "nm-settings-interface.h"
#include "nm-manager-auth.h"
#define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd"
@ -838,7 +838,7 @@ system_query_connections (NMManager *manager)
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
GSList *system_connections, *iter;
system_connections = nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (priv->sys_settings));
system_connections = nm_sysconfig_settings_list_connections (priv->sys_settings);
for (iter = system_connections; iter; iter = g_slist_next (iter))
system_internal_new_connection (manager, NM_SETTINGS_CONNECTION_INTERFACE (iter->data));
g_slist_free (system_connections);
@ -1862,13 +1862,13 @@ system_get_secrets_idle_cb (gpointer user_data)
{
GetSecretsInfo *info = user_data;
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (info->manager);
NMSettingsConnectionInterface *connection;
NMSysconfigConnection *connection;
GError *error = NULL;
const char *hints[3] = { NULL, NULL, NULL };
info->idle_id = 0;
connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (priv->sys_settings),
connection = nm_sysconfig_settings_get_connection_by_path (priv->sys_settings,
info->connection_path);
if (!connection) {
error = g_error_new_literal (NM_MANAGER_ERROR,
@ -1886,7 +1886,7 @@ system_get_secrets_idle_cb (gpointer user_data)
hints[0] = info->hint1;
hints[1] = info->hint2;
nm_settings_connection_interface_get_secrets (connection,
nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (connection),
info->setting_name,
hints,
info->request_new,
@ -3013,7 +3013,7 @@ nm_manager_get (const char *config_file,
g_signal_connect (priv->sys_settings, "notify::" NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS,
G_CALLBACK (system_unmanaged_devices_changed_cb), singleton);
g_signal_connect (priv->sys_settings, "notify::" NM_SETTINGS_INTERFACE_HOSTNAME,
g_signal_connect (priv->sys_settings, "notify::" NM_SYSCONFIG_SETTINGS_HOSTNAME,
G_CALLBACK (system_hostname_changed_cb), singleton);
g_signal_connect (priv->sys_settings, "new-connection",
G_CALLBACK (system_new_connection_cb), singleton);

View file

@ -27,7 +27,6 @@
#include "nm-system-config-error.h"
#include "nm-dbus-glib-types.h"
#include "nm-settings-connection-interface.h"
#include "nm-settings-interface.h"
#include "nm-polkit-helpers.h"
#include "nm-logging.h"
@ -261,8 +260,8 @@ get_secrets (NMSettingsConnectionInterface *connection,
* nm_sysconfig_connection_update().
*/
if (!priv->secrets) {
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
"%s.%d - Internal error; secrets cache invalid.",
__FILE__, __LINE__);
(*callback) (connection, NULL, error, user_data);
@ -272,8 +271,8 @@ get_secrets (NMSettingsConnectionInterface *connection,
setting = nm_connection_get_setting_by_name (priv->secrets, setting_name);
if (!setting) {
error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING,
error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_SETTING,
"%s.%d - Connection didn't have requested setting '%s'.",
__FILE__, __LINE__, setting_name);
(*callback) (connection, NULL, error, user_data);
@ -311,8 +310,8 @@ check_writable (NMConnection *connection, GError **error)
NM_TYPE_SETTING_CONNECTION);
if (!s_con) {
g_set_error_literal (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
"Connection did not have required 'connection' setting");
return FALSE;
}
@ -323,8 +322,8 @@ check_writable (NMConnection *connection, GError **error)
*/
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,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_READ_ONLY_CONNECTION,
"Connection is read-only");
return FALSE;
}
@ -374,8 +373,8 @@ impl_sysconfig_connection_update (NMSysconfigConnection *self,
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,
error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"%s: %s:%d update() unimplemented", __func__, __FILE__, __LINE__);
dbus_g_method_return_error (context, error);
g_error_free (error);
@ -397,8 +396,8 @@ impl_sysconfig_connection_delete (NMSysconfigConnection *self,
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,
error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__);
dbus_g_method_return_error (context, error);
g_error_free (error);
@ -417,8 +416,8 @@ impl_sysconfig_connection_get_secrets (NMSysconfigConnection *self,
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,
error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
dbus_g_method_return_error (context, error);
g_error_free (error);

View file

@ -33,7 +33,6 @@
#include <nm-connection.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <nm-settings-interface.h>
#include <nm-setting-8021x.h>
#include <nm-setting-bluetooth.h>
@ -115,16 +114,14 @@ typedef struct {
GSList *unmanaged_specs;
} NMSysconfigSettingsPrivate;
static void settings_interface_init (NMSettingsInterface *klass);
G_DEFINE_TYPE_WITH_CODE (NMSysconfigSettings, nm_sysconfig_settings, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE,
settings_interface_init))
G_DEFINE_TYPE (NMSysconfigSettings, nm_sysconfig_settings, G_TYPE_OBJECT)
#define NM_SYSCONFIG_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsPrivate))
enum {
PROPERTIES_CHANGED,
NEW_CONNECTION,
CHECK_PERMISSIONS,
LAST_SIGNAL
};
@ -135,6 +132,8 @@ enum {
PROP_0,
PROP_BUS,
PROP_UNMANAGED_SPECS,
PROP_HOSTNAME,
PROP_CAN_MODIFY,
LAST_PROP
};
@ -171,15 +170,20 @@ load_connections (NMSysconfigSettings *self)
unmanaged_specs_changed (NULL, self);
}
static GSList *
list_connections (NMSettingsInterface *settings)
GSList *
nm_sysconfig_settings_list_connections (NMSysconfigSettings *settings)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (settings);
NMSysconfigSettingsPrivate *priv;
GHashTableIter iter;
gpointer key;
GSList *list = NULL;
load_connections (NM_SYSCONFIG_SETTINGS (settings));
g_return_val_if_fail (settings != NULL, NULL);
g_return_val_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings), NULL);
priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (settings);
load_connections (settings);
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, &key, NULL))
@ -194,7 +198,7 @@ impl_settings_list_connections (NMSysconfigSettings *self,
{
GSList *list = NULL, *iter;
list = list_connections (NM_SETTINGS_INTERFACE (self));
list = nm_sysconfig_settings_list_connections (self);
*connections = g_ptr_array_sized_new (g_slist_length (list) + 1);
for (iter = list; iter; iter = g_slist_next (iter)) {
g_ptr_array_add (*connections,
@ -204,13 +208,17 @@ impl_settings_list_connections (NMSysconfigSettings *self,
return TRUE;
}
static NMSettingsConnectionInterface *
get_connection_by_path (NMSettingsInterface *settings, const char *path)
NMSysconfigConnection *
nm_sysconfig_settings_get_connection_by_path (NMSysconfigSettings *settings, const char *path)
{
NMSysconfigConnection *connection = NULL;
GSList *list = NULL, *iter;
list = list_connections (settings);
g_return_val_if_fail (settings != NULL, NULL);
g_return_val_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings), NULL);
g_return_val_if_fail (path != NULL, NULL);
list = nm_sysconfig_settings_list_connections (settings);
for (iter = list; iter; iter = g_slist_next (iter)) {
if (!strcmp (nm_connection_get_path (NM_CONNECTION (iter->data)), path)) {
connection = NM_SYSCONFIG_CONNECTION (iter->data);
@ -219,7 +227,7 @@ get_connection_by_path (NMSettingsInterface *settings, const char *path)
}
g_slist_free (list);
return (NMSettingsConnectionInterface *) connection;
return connection;
}
static void
@ -385,7 +393,7 @@ hostname_changed (NMSystemConfigInterface *config,
GParamSpec *pspec,
gpointer user_data)
{
g_object_notify (G_OBJECT (user_data), NM_SETTINGS_INTERFACE_HOSTNAME);
g_object_notify (G_OBJECT (user_data), NM_SYSCONFIG_SETTINGS_HOSTNAME);
}
static void
@ -574,7 +582,7 @@ claim_connection (NMSysconfigSettings *self,
if (do_export) {
export_connection (self, connection);
g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_NEW_CONNECTION, connection);
g_signal_emit (self, signals[NEW_CONNECTION], 0, connection);
}
}
@ -602,7 +610,6 @@ typedef struct {
gboolean disposed;
NMConnection *connection;
NMSettingsAddConnectionFunc callback;
gpointer callback_data;
char *hostname;
@ -617,8 +624,6 @@ static PolkitCall *
polkit_call_new (NMSysconfigSettings *self,
DBusGMethodInvocation *context,
NMConnection *connection,
NMSettingsAddConnectionFunc callback,
gpointer callback_data,
const char *hostname)
{
PolkitCall *call;
@ -633,10 +638,6 @@ polkit_call_new (NMSysconfigSettings *self,
call->context = context;
if (connection)
call->connection = g_object_ref (connection);
if (callback) {
call->callback = callback;
call->callback_data = callback_data;
}
if (hostname)
call->hostname = g_strdup (hostname);
@ -720,7 +721,7 @@ pk_add_cb (GObject *object, GAsyncResult *result, gpointer user_data)
&error);
/* Some random error happened */
if (error) {
call->callback (NM_SETTINGS_INTERFACE (self), error, call->callback_data);
dbus_g_method_return_error (call->context, error);
goto out;
}
@ -729,12 +730,12 @@ pk_add_cb (GObject *object, GAsyncResult *result, gpointer user_data)
error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
"Insufficient privileges.");
call->callback (NM_SETTINGS_INTERFACE (self), error, call->callback_data);
dbus_g_method_return_error (call->context, error);
goto out;
}
if (add_new_connection (self, call->connection, &add_error))
call->callback (NM_SETTINGS_INTERFACE (self), NULL, call->callback_data);
dbus_g_method_return (call->context);
else {
error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_FAILED,
@ -742,7 +743,7 @@ pk_add_cb (GObject *object, GAsyncResult *result, gpointer user_data)
add_error ? add_error->code : -1,
(add_error && add_error->message) ? add_error->message : "(unknown)");
g_error_free (add_error);
call->callback (NM_SETTINGS_INTERFACE (self), error, call->callback_data);
dbus_g_method_return_error (call->context, error);
}
out:
@ -753,27 +754,34 @@ out:
}
static void
internal_add_connection (NMSysconfigSettings *self,
NMConnection *connection,
DBusGMethodInvocation *context, /* Only present for D-Bus calls */
NMSettingsAddConnectionFunc callback,
gpointer user_data)
impl_settings_add_connection (NMSysconfigSettings *self,
GHashTable *settings,
DBusGMethodInvocation *context)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
PolkitCall *call;
NMConnection *connection;
GError *error = NULL;
connection = nm_connection_new_from_hash (settings, &error);
if (!connection) {
g_assert (error);
dbus_g_method_return_error (context, error);
g_error_free (error);
return;
}
/* Do any of the plugins support adding? */
if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) {
error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
"None of the registered plugins support add.");
callback (NM_SETTINGS_INTERFACE (self), error, user_data);
dbus_g_method_return_error (context, error);
g_error_free (error);
return;
}
call = polkit_call_new (self, context, connection, callback, user_data, NULL);
call = polkit_call_new (self, context, connection, NULL);
g_assert (call);
polkit_authority_check_authorization (priv->authority,
call->subject,
@ -784,52 +792,8 @@ internal_add_connection (NMSysconfigSettings *self,
pk_add_cb,
call);
priv->pk_calls = g_slist_append (priv->pk_calls, call);
}
static void
dbus_add_connection_cb (NMSettingsInterface *settings,
GError *error,
gpointer user_data)
{
DBusGMethodInvocation *context = user_data;
if (error)
dbus_g_method_return_error (context, error);
else
dbus_g_method_return (context);
}
static void
impl_settings_add_connection (NMSysconfigSettings *self,
GHashTable *settings,
DBusGMethodInvocation *context)
{
NMConnection *tmp;
GError *error = NULL;
/* Check if the settings are valid first */
tmp = nm_connection_new_from_hash (settings, &error);
if (!tmp) {
g_assert (error);
dbus_g_method_return_error (context, error);
g_error_free (error);
return;
}
internal_add_connection (self, tmp, context, dbus_add_connection_cb, context);
g_object_unref (tmp);
}
static gboolean
settings_interface_add_connection (NMSettingsInterface *settings,
NMConnection *connection,
NMSettingsAddConnectionFunc callback,
gpointer user_data)
{
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (settings);
internal_add_connection (self, connection, NULL, callback, user_data);
return TRUE;
g_object_unref (connection);
}
static void
@ -922,7 +886,7 @@ impl_settings_save_hostname (NMSysconfigSettings *self,
return;
}
call = polkit_call_new (self, context, NULL, NULL, NULL, hostname);
call = polkit_call_new (self, context, NULL, hostname);
g_assert (call);
polkit_authority_check_authorization (priv->authority,
call->subject,
@ -939,8 +903,7 @@ static void
pk_authority_changed_cb (GObject *object, gpointer user_data)
{
/* Let clients know they should re-check their authorization */
g_signal_emit_by_name (NM_SYSCONFIG_SETTINGS (user_data),
NM_SETTINGS_INTERFACE_CHECK_PERMISSIONS);
g_signal_emit (NM_SYSCONFIG_SETTINGS (user_data), signals[CHECK_PERMISSIONS], 0);
}
typedef struct {
@ -1053,7 +1016,7 @@ impl_settings_get_permissions (NMSysconfigSettings *self,
{
PolkitCall *call;
call = polkit_call_new (self, context, NULL, NULL, NULL, FALSE);
call = polkit_call_new (self, context, NULL, FALSE);
g_assert (call);
/* Start checks for the various permissions */
@ -1081,36 +1044,6 @@ impl_settings_get_permissions (NMSysconfigSettings *self,
NM_SETTINGS_PERMISSION_WIFI_SHARE_PROTECTED);
}
static gboolean
get_permissions (NMSettingsInterface *settings,
NMSettingsGetPermissionsFunc callback,
gpointer user_data)
{
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (settings);
NMSettingsPermissions permissions = NM_SETTINGS_PERMISSION_NONE;
/* Local caller (ie, NM) gets full permissions by default because it doesn't
* need authorization. However, permissions are still subject to plugin's
* restrictions. i.e. if no plugins support connection-modify, then even
* the local caller won't get that permission.
*/
/* Only check for connection-modify if one of our plugins supports it. */
if (get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS))
permissions |= NM_SETTINGS_PERMISSION_CONNECTION_MODIFY;
/* Only check for hostname-modify if one of our plugins supports it. */
if (get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME))
permissions |= NM_SETTINGS_PERMISSION_HOSTNAME_MODIFY;
// FIXME: hook these into plugin permissions like the modify permissions */
permissions |= NM_SETTINGS_PERMISSION_WIFI_SHARE_OPEN;
permissions |= NM_SETTINGS_PERMISSION_WIFI_SHARE_PROTECTED;
callback (settings, permissions, NULL, user_data);
return TRUE;
}
static gboolean
have_connection_for_device (NMSysconfigSettings *self, GByteArray *mac)
{
@ -1529,19 +1462,6 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_sysconfig_settings_parent_class)->finalize (object);
}
static void
settings_interface_init (NMSettingsInterface *iface)
{
iface->add_connection = settings_interface_add_connection;
iface->list_connections = list_connections;
iface->get_connection_by_path = get_connection_by_path;
iface->get_permissions = get_permissions;
dbus_g_object_type_install_info (G_TYPE_FROM_INTERFACE (iface),
&dbus_glib_nm_settings_object_info);
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
@ -1581,14 +1501,14 @@ get_property (GObject *object, guint prop_id,
copy = g_slist_append (copy, g_strdup (iter->data));
g_value_take_boxed (value, copy);
break;
case NM_SETTINGS_INTERFACE_PROP_HOSTNAME:
case PROP_HOSTNAME:
g_value_take_string (value, nm_sysconfig_settings_get_hostname (self));
/* Don't ever pass NULL through D-Bus */
if (!g_value_get_string (value))
g_value_set_static_string (value, "");
break;
case NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY:
case PROP_CAN_MODIFY:
g_value_set_boolean (value, !!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS));
break;
default:
@ -1634,13 +1554,21 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
DBUS_TYPE_G_LIST_OF_STRING,
G_PARAM_READABLE));
g_object_class_override_property (object_class,
NM_SETTINGS_INTERFACE_PROP_HOSTNAME,
NM_SETTINGS_INTERFACE_HOSTNAME);
g_object_class_install_property
(object_class, PROP_HOSTNAME,
g_param_spec_string (NM_SYSCONFIG_SETTINGS_HOSTNAME,
"Hostname",
"Persistent hostname",
NULL,
G_PARAM_READABLE));
g_object_class_override_property (object_class,
NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY,
NM_SETTINGS_INTERFACE_CAN_MODIFY);
g_object_class_install_property
(object_class, PROP_CAN_MODIFY,
g_param_spec_boolean (NM_SYSCONFIG_SETTINGS_CAN_MODIFY,
"CanModify",
"Can modify anything (hostname, connections, etc)",
FALSE,
G_PARAM_READABLE));
/* signals */
signals[PROPERTIES_CHANGED] =
@ -1651,15 +1579,28 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT);
signals[NEW_CONNECTION] =
g_signal_new (NM_SYSCONFIG_SETTINGS_NEW_CONNECTION,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
signals[CHECK_PERMISSIONS] =
g_signal_new (NM_SYSCONFIG_SETTINGS_CHECK_PERMISSIONS,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
dbus_g_error_domain_register (NM_SYSCONFIG_SETTINGS_ERROR,
NM_DBUS_IFACE_SETTINGS,
NM_TYPE_SYSCONFIG_SETTINGS_ERROR);
dbus_g_error_domain_register (NM_SETTINGS_INTERFACE_ERROR,
NM_DBUS_IFACE_SETTINGS,
NM_TYPE_SETTINGS_INTERFACE_ERROR);
/* And register all the settings errors with D-Bus */
dbus_g_error_domain_register (NM_CONNECTION_ERROR, NULL, NM_TYPE_CONNECTION_ERROR);
dbus_g_error_domain_register (NM_SETTING_802_1X_ERROR, NULL, NM_TYPE_SETTING_802_1X_ERROR);
@ -1678,6 +1619,10 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
dbus_g_error_domain_register (NM_SETTING_WIRELESS_SECURITY_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_SECURITY_ERROR);
dbus_g_error_domain_register (NM_SETTING_WIRELESS_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_ERROR);
dbus_g_error_domain_register (NM_SETTING_ERROR, NULL, NM_TYPE_SETTING_ERROR);
dbus_g_object_type_install_info (NM_TYPE_SYSCONFIG_SETTINGS,
&dbus_glib_nm_settings_object_info);
}
static void

View file

@ -32,6 +32,15 @@
#include "nm-system-config-interface.h"
#include "nm-device.h"
// FIXME this is temporary, permissions format to be improved
typedef enum {
NM_SETTINGS_PERMISSION_NONE = 0x0,
NM_SETTINGS_PERMISSION_CONNECTION_MODIFY = 0x1,
NM_SETTINGS_PERMISSION_WIFI_SHARE_PROTECTED = 0x2,
NM_SETTINGS_PERMISSION_WIFI_SHARE_OPEN = 0x4,
NM_SETTINGS_PERMISSION_HOSTNAME_MODIFY = 0x8
} NMSettingsPermissions;
#define NM_TYPE_SYSCONFIG_SETTINGS (nm_sysconfig_settings_get_type ())
#define NM_SYSCONFIG_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettings))
#define NM_SYSCONFIG_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
@ -39,8 +48,13 @@
#define NM_IS_SYSCONFIG_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_SETTINGS))
#define NM_SYSCONFIG_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
#define NM_SYSCONFIG_SETTINGS_BUS "bus"
#define NM_SYSCONFIG_SETTINGS_BUS "bus"
#define NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS "unmanaged-specs"
#define NM_SYSCONFIG_SETTINGS_HOSTNAME "hostname"
#define NM_SYSCONFIG_SETTINGS_CAN_MODIFY "can-modify"
#define NM_SYSCONFIG_SETTINGS_NEW_CONNECTION "new-connection"
#define NM_SYSCONFIG_SETTINGS_CHECK_PERMISSIONS "check-permissions"
typedef struct {
GObject parent_instance;
@ -60,6 +74,12 @@ NMSysconfigSettings *nm_sysconfig_settings_new (const char *config_file,
DBusGConnection *bus,
GError **error);
/* Returns a list of NMSysconfigConnections */
GSList * nm_sysconfig_settings_list_connections (NMSysconfigSettings *settings);
NMSysconfigConnection * nm_sysconfig_settings_get_connection_by_path (NMSysconfigSettings *settings,
const char *path);
const GSList *nm_sysconfig_settings_get_unmanaged_specs (NMSysconfigSettings *self);
char *nm_sysconfig_settings_get_hostname (NMSysconfigSettings *self);

View file

@ -42,6 +42,22 @@ nm_sysconfig_settings_error_get_type (void)
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_GENERAL, "GeneralError"),
/* The connection was invalid. */
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION, "InvalidConnection"),
/* The connection is read-only; modifications are not allowed. */
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_READ_ONLY_CONNECTION, "ReadOnlyConnection"),
/* A bug in the settings service caused the error. */
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR, "InternalError"),
/* Retrieval or request of secrets failed. */
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_UNAVAILABLE, "SecretsUnavailable"),
/* The request for secrets was canceled. */
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED, "SecretsRequestCanceled"),
/* The request could not be completed because permission was denied. */
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_PERMISSION_DENIED, "PermissionDenied"),
/* The requested setting does not existing in this connection. */
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_INVALID_SETTING, "InvalidSetting"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED, "NotPrivileged"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED, "AddNotSupported"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_UPDATE_NOT_SUPPORTED, "UpdateNotSupported"),

View file

@ -27,6 +27,13 @@
enum {
NM_SYSCONFIG_SETTINGS_ERROR_GENERAL = 0,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
NM_SYSCONFIG_SETTINGS_ERROR_READ_ONLY_CONNECTION,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_UNAVAILABLE,
NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
NM_SYSCONFIG_SETTINGS_ERROR_PERMISSION_DENIED,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_SETTING,
NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
NM_SYSCONFIG_SETTINGS_ERROR_UPDATE_NOT_SUPPORTED,

View file

@ -38,12 +38,13 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <nm-setting-connection.h>
#include <nm-settings-interface.h>
#include "common.h"
#include "nm-dbus-glib-types.h"
#include "plugin.h"
#include "nm-system-config-interface.h"
#include "nm-system-config-error.h"
#include "nm-ifcfg-connection.h"
#include "nm-inotify-helper.h"
#include "shvar.h"
@ -537,8 +538,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
if (!g_path_is_absolute (in_ifcfg)) {
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
"ifcfg path '%s' is not absolute", in_ifcfg);
return FALSE;
}
@ -546,8 +547,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
connection = g_hash_table_lookup (priv->connections, in_ifcfg);
if (!connection) {
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
"ifcfg file '%s' unknown", in_ifcfg);
return FALSE;
}
@ -555,8 +556,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
if (!s_con) {
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"unable to retrieve the connection setting");
return FALSE;
}
@ -564,8 +565,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
uuid = nm_setting_connection_get_uuid (s_con);
if (!uuid) {
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"unable to get the UUID");
return FALSE;
}
@ -573,8 +574,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
path = nm_connection_get_path (NM_CONNECTION (connection));
if (!path) {
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"unable to get the connection D-Bus path");
return FALSE;
}

View file

@ -1,5 +1,6 @@
INCLUDES = \
-I$(top_srcdir)/system-settings/src \
-I$(top_srcdir)/src/system-settings \
-I$(top_srcdir)/include \
-I$(top_srcdir)/libnm-util \
-I$(top_srcdir)/libnm-glib
@ -16,5 +17,7 @@ libkeyfile_io_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS)
libkeyfile_io_la_LIBADD = $(GLIB_LIBS)
libkeyfile_io_la_LIBADD = \
$(top_builddir)/src/system-settings/libsystem-settings.la \
$(GLIB_LIBS)

View file

@ -36,9 +36,9 @@
#include <string.h>
#include <arpa/inet.h>
#include <netinet/ether.h>
#include <nm-settings-interface.h>
#include "nm-dbus-glib-types.h"
#include "nm-system-config-error.h"
#include "writer.h"
#include "reader.h"
@ -668,8 +668,8 @@ write_connection (NMConnection *connection,
g_file_set_contents (path, data, len, error);
if (chown (path, owner_uid, owner_grp) < 0) {
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"%s.%d: error chowning '%s': %d", __FILE__, __LINE__,
path, errno);
unlink (path);
@ -677,8 +677,8 @@ write_connection (NMConnection *connection,
err = chmod (path, S_IRUSR | S_IWUSR);
if (err) {
g_set_error (error,
NM_SETTINGS_INTERFACE_ERROR,
NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"%s.%d: error setting permissions on '%s': %d", __FILE__,
__LINE__, path, errno);
unlink (path);