diff --git a/docs/libnm-glib/Makefile.am b/docs/libnm-glib/Makefile.am index 96ff66eee3..b12e730a4c 100644 --- a/docs/libnm-glib/Makefile.am +++ b/docs/libnm-glib/Makefile.am @@ -51,7 +51,6 @@ IGNORE_HFILES= \ nm-ip6-config-bindings.h \ nm-settings-bindings.h \ nm-settings-glue.h \ - nm-settings-system-bindings.h \ nm-vpn-connection-bindings.h \ nm-vpn-plugin-glue.h diff --git a/docs/libnm-glib/libnm-glib-docs.sgml b/docs/libnm-glib/libnm-glib-docs.sgml index 422c9d3c4a..87e6b40d0c 100644 --- a/docs/libnm-glib/libnm-glib-docs.sgml +++ b/docs/libnm-glib/libnm-glib-docs.sgml @@ -34,7 +34,6 @@ - diff --git a/include/NetworkManager.h b/include/NetworkManager.h index 4001dae036..56fcfa2762 100644 --- a/include/NetworkManager.h +++ b/include/NetworkManager.h @@ -47,7 +47,6 @@ #define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings" #define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManagerSettings" -#define NM_DBUS_IFACE_SETTINGS_SYSTEM "org.freedesktop.NetworkManagerSettings.System" #define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManagerSettings" #define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManagerSettings.Connection" diff --git a/introspection/nm-settings-system.xml b/introspection/nm-settings-system.xml deleted file mode 100644 index 598274c0d1..0000000000 --- a/introspection/nm-settings-system.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - Implemented by the system settings service to provide additional settings to NetworkManager. - - - - - Save the hostname to persistent configuration. - - - - - - The hostname to save to persistent configuration. If blank, the persistent hostname is cleared. - - - - - - - The machine hostname stored in persistent configuration. - - - - - - If true, adding and modifying connections is supported. - - - - - - - A dictionary mapping property names to variant boxed values - - - - - - - Emitted when system authorization details change, indicating that clients may wish to recheck permissions with GetPermissions. - - - - - - Returns a bitfield indicating certain operations the caller is permitted to perform. Some of these operations may require authorization by the user. - - - - - - A bitfield of permitted operations. Some of these operations may require the user to authorize via password entry or other means. - - - - - - - No permissions. - - - Can modify/add/delete connections. - - - Can share connections via a encrypted user-created WiFi network. - - - Can share connections via a open/unencrypted user-created WiFi network. - - - Can modify the persistent system hostname. - - - - - - diff --git a/introspection/nm-settings.xml b/introspection/nm-settings.xml index b252c00d59..67e6d2abbe 100644 --- a/introspection/nm-settings.xml +++ b/introspection/nm-settings.xml @@ -31,6 +31,58 @@ + + + Save the hostname to persistent configuration. + + + + + + The hostname to save to persistent configuration. If blank, the persistent hostname is cleared. + + + + + + + Returns a bitfield indicating certain operations the caller is permitted to perform. Some of these operations may require authorization by the user. + + + + + + A bitfield of permitted operations. Some of these operations may require the user to authorize via password entry or other means. + + + + + + + The machine hostname stored in persistent configuration. + + + + + + If true, adding and modifying connections is supported. + + + + + + + A dictionary mapping property names to variant boxed values + + + + + + + Emitted when system authorization details change, indicating that clients may wish to recheck permissions with GetPermissions. + + + Emitted when a new connection has been added. @@ -42,6 +94,24 @@ + + + No permissions. + + + Can modify/add/delete connections. + + + Can share connections via a encrypted user-created WiFi network. + + + Can share connections via a open/unencrypted user-created WiFi network. + + + Can modify the persistent system hostname. + + + diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index 2e91ecb670..388ab54027 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -13,7 +13,6 @@ BUILT_SOURCES = \ nm-exported-connection-glue.h \ nm-exported-connection-bindings.h \ nm-settings-bindings.h \ - nm-settings-system-bindings.h \ nm-vpn-connection-bindings.h \ nm-vpn-plugin-glue.h \ nm-active-connection-bindings.h \ @@ -79,7 +78,6 @@ libnminclude_HEADERS = \ nm-dhcp6-config.h \ nm-remote-connection.h \ nm-settings-interface.h \ - nm-settings-system-interface.h \ nm-remote-settings.h \ nm-settings-connection-interface.h \ nm-exported-connection.h @@ -112,7 +110,6 @@ libnm_glib_la_SOURCES = \ nm-remote-connection.c \ nm-remote-connection-private.h \ nm-settings-interface.c \ - nm-settings-system-interface.c \ nm-remote-settings.c \ nm-settings-connection-interface.c \ nm-exported-connection.c @@ -164,9 +161,6 @@ nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml nm-settings-bindings.h: $(top_srcdir)/introspection/nm-settings.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $< -nm-settings-system-bindings.h: $(top_srcdir)/introspection/nm-settings-system.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_system --mode=glib-client --output=$@ $< - nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=$@ $< diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index 0967c9a39a..2dc9783cc8 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -137,10 +137,8 @@ global: nm_settings_interface_get_connection_by_path; nm_settings_interface_get_type; nm_settings_interface_list_connections; - nm_settings_system_interface_get_type; - nm_settings_system_interface_add_connection; - nm_settings_system_interface_get_permissions; - nm_settings_system_interface_save_hostname; + nm_settings_interface_get_permissions; + nm_settings_interface_save_hostname; nm_settings_error_quark; nm_settings_get_type; nm_settings_list_connections; diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c index 0e1a0fd6c0..8b0c4ecad4 100644 --- a/libnm-glib/nm-remote-settings.c +++ b/libnm-glib/nm-remote-settings.c @@ -30,16 +30,12 @@ #include "nm-remote-settings.h" #include "nm-settings-bindings.h" #include "nm-settings-interface.h" -#include "nm-settings-system-bindings.h" -#include "nm-settings-system-interface.h" #include "nm-remote-connection-private.h" static void settings_interface_init (NMSettingsInterface *class); -static void settings_system_interface_init (NMSettingsSystemInterface *class); G_DEFINE_TYPE_EXTENDED (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE, settings_interface_init) - G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_SYSTEM_INTERFACE, settings_system_interface_init)) + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE, settings_interface_init)) #define NM_REMOTE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsPrivate)) @@ -52,8 +48,7 @@ typedef struct { gboolean service_running; DBusGProxy *props_proxy; - DBusGProxy *sys_proxy; - NMSettingsSystemPermissions permissions; + NMSettingsPermissions permissions; gboolean have_permissions; char *hostname; gboolean can_modify; @@ -296,8 +291,8 @@ remove_connections (gpointer user_data) } typedef struct { - NMSettingsSystemInterface *settings; - NMSettingsSystemSaveHostnameFunc callback; + NMSettingsInterface *settings; + NMSettingsSaveHostnameFunc callback; gpointer callback_data; } SaveHostnameInfo; @@ -315,9 +310,9 @@ save_hostname_cb (DBusGProxy *proxy, } static gboolean -save_hostname (NMSettingsSystemInterface *settings, +save_hostname (NMSettingsInterface *settings, const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, + NMSettingsSaveHostnameFunc callback, gpointer user_data) { NMRemoteSettings *self = NM_REMOTE_SETTINGS (settings); @@ -329,7 +324,7 @@ save_hostname (NMSettingsSystemInterface *settings, info->callback = callback; info->callback_data = user_data; - dbus_g_proxy_begin_call (priv->sys_proxy, "SaveHostname", + dbus_g_proxy_begin_call (priv->proxy, "SaveHostname", save_hostname_cb, info, g_free, @@ -339,8 +334,8 @@ save_hostname (NMSettingsSystemInterface *settings, } typedef struct { - NMSettingsSystemInterface *settings; - NMSettingsSystemGetPermissionsFunc callback; + NMSettingsInterface *settings; + NMSettingsGetPermissionsFunc callback; gpointer callback_data; } GetPermissionsInfo; @@ -352,7 +347,7 @@ get_permissions_cb (DBusGProxy *proxy, GetPermissionsInfo *info = user_data; NMRemoteSettings *self = NM_REMOTE_SETTINGS (info->settings); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); - NMSettingsSystemPermissions permissions = NM_SETTINGS_SYSTEM_PERMISSION_NONE; + NMSettingsPermissions permissions = NM_SETTINGS_PERMISSION_NONE; GError *error = NULL; dbus_g_proxy_end_call (proxy, call, &error, @@ -365,8 +360,8 @@ get_permissions_cb (DBusGProxy *proxy, } static gboolean -get_permissions (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, +get_permissions (NMSettingsInterface *settings, + NMSettingsGetPermissionsFunc callback, gpointer user_data) { NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); @@ -384,7 +379,7 @@ get_permissions (NMSettingsSystemInterface *settings, info->callback = callback; info->callback_data = user_data; - dbus_g_proxy_begin_call (priv->sys_proxy, "GetPermissions", + dbus_g_proxy_begin_call (priv->proxy, "GetPermissions", get_permissions_cb, info, g_free, @@ -426,7 +421,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_SYSTEM_INTERFACE_CHECK_PERMISSIONS); + g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CHECK_PERMISSIONS); } static void @@ -446,12 +441,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_SYSTEM_INTERFACE_HOSTNAME); + g_object_notify (G_OBJECT (self), NM_SETTINGS_INTERFACE_HOSTNAME); } if (!strcmp ((const char *) key, "CanModify")) { priv->can_modify = g_value_get_boolean (value); - g_object_notify (G_OBJECT (self), NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY); + g_object_notify (G_OBJECT (self), NM_SETTINGS_INTERFACE_CAN_MODIFY); } } } @@ -494,14 +489,8 @@ settings_interface_init (NMSettingsInterface *iface) iface->list_connections = list_connections; iface->get_connection_by_path = get_connection_by_path; iface->add_connection = add_connection; -} - -static void -settings_system_interface_init (NMSettingsSystemInterface *klass) -{ - /* interface implementation */ - klass->save_hostname = save_hostname; - klass->get_permissions = get_permissions; + iface->save_hostname = save_hostname; + iface->get_permissions = get_permissions; } /** @@ -603,29 +592,22 @@ constructor (GType type, "org.freedesktop.DBus.Properties"); g_assert (priv->props_proxy); - /* System settings proxy */ - priv->sys_proxy = dbus_g_proxy_new_for_name (priv->bus, - NM_DBUS_SERVICE_SYSTEM_SETTINGS, - NM_DBUS_PATH_SETTINGS, - NM_DBUS_IFACE_SETTINGS_SYSTEM); - g_assert (priv->sys_proxy); - dbus_g_proxy_set_default_timeout (priv->sys_proxy, G_MAXINT); - + /* Monitor properties */ dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID); - dbus_g_proxy_add_signal (priv->sys_proxy, "PropertiesChanged", + dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged", DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->sys_proxy, "PropertiesChanged", + dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged", G_CALLBACK (properties_changed_cb), object, NULL); /* Monitor for permissions changes */ - dbus_g_proxy_add_signal (priv->sys_proxy, "CheckPermissions", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->sys_proxy, "CheckPermissions", + dbus_g_proxy_add_signal (priv->proxy, "CheckPermissions", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->proxy, "CheckPermissions", G_CALLBACK (check_permissions_cb), object, NULL); @@ -635,7 +617,7 @@ constructor (GType type, get_all_cb, object, NULL, - G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS_SYSTEM, + G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS, G_TYPE_INVALID); return object; @@ -700,10 +682,10 @@ get_property (GObject *object, guint prop_id, case PROP_SERVICE_RUNNING: g_value_set_boolean (value, priv->service_running); break; - case NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME: + case NM_SETTINGS_INTERFACE_PROP_HOSTNAME: g_value_set_string (value, priv->hostname); break; - case NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY: + case NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY: g_value_set_boolean (value, priv->can_modify); break; default: @@ -743,12 +725,12 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class) G_PARAM_READABLE)); g_object_class_override_property (object_class, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME, - NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME); + NM_SETTINGS_INTERFACE_PROP_HOSTNAME, + NM_SETTINGS_INTERFACE_HOSTNAME); g_object_class_override_property (object_class, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY, - NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY); + NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY, + NM_SETTINGS_INTERFACE_CAN_MODIFY); } diff --git a/libnm-glib/nm-settings-interface.c b/libnm-glib/nm-settings-interface.c index 3bd4037a1e..951c59a24f 100644 --- a/libnm-glib/nm-settings-interface.c +++ b/libnm-glib/nm-settings-interface.c @@ -145,6 +145,65 @@ nm_settings_interface_add_connection (NMSettingsInterface *settings, 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 @@ -156,6 +215,23 @@ nm_settings_interface_init (gpointer g_iface) 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, @@ -173,6 +249,14 @@ nm_settings_interface_init (gpointer g_iface) 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; } diff --git a/libnm-glib/nm-settings-interface.h b/libnm-glib/nm-settings-interface.h index 5920bd8255..6f10c97864 100644 --- a/libnm-glib/nm-settings-interface.h +++ b/libnm-glib/nm-settings-interface.h @@ -47,13 +47,33 @@ GQuark nm_settings_interface_error_quark (void); 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_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; @@ -61,6 +81,15 @@ 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; @@ -75,6 +104,15 @@ struct _NMSettingsInterface { 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, @@ -82,6 +120,8 @@ struct _NMSettingsInterface { void (*connections_read) (NMSettingsInterface *settings); + void (*check_permissions) (NMSettingsInterface *settings); + /* Padding for future expansion */ void (*_reserved1) (void); void (*_reserved2) (void); @@ -104,6 +144,15 @@ gboolean nm_settings_interface_add_connection (NMSettingsInterface *settings, 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 */ diff --git a/libnm-glib/nm-settings-system-interface.c b/libnm-glib/nm-settings-system-interface.c deleted file mode 100644 index 0f59377a53..0000000000 --- a/libnm-glib/nm-settings-system-interface.c +++ /dev/null @@ -1,150 +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 - 2008 Red Hat, Inc. - */ - -#include "nm-settings-interface.h" -#include "nm-settings-system-interface.h" - - -/** - * nm_settings_system_interface_save_hostname: - * @settings: a object implementing %NMSettingsSystemInterface - * @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_system_interface_save_hostname (NMSettingsSystemInterface *settings, - const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (settings != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_SYSTEM_INTERFACE (settings), FALSE); - g_return_val_if_fail (hostname != NULL, FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->save_hostname) { - return NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->save_hostname (settings, - hostname, - callback, - user_data); - } - return FALSE; -} - -/** - * nm_settings_system_interface_get_permissions: - * @settings: a object implementing %NMSettingsSystemInterface - * @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_system_interface_get_permissions (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, - gpointer user_data) -{ - g_return_val_if_fail (settings != NULL, FALSE); - g_return_val_if_fail (NM_IS_SETTINGS_SYSTEM_INTERFACE (settings), FALSE); - g_return_val_if_fail (callback != NULL, FALSE); - - if (NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->get_permissions) - return NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->get_permissions (settings, callback, user_data); - return FALSE; -} - -static void -nm_settings_system_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_SYSTEM_INTERFACE_HOSTNAME, - "Hostname", - "Persistent hostname", - NULL, - G_PARAM_READABLE)); - - g_object_interface_install_property - (g_iface, - g_param_spec_boolean (NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY, - "CanModify", - "Can modify anything (hostname, connections, etc)", - FALSE, - G_PARAM_READABLE)); - - /* Signals */ - g_signal_new (NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsSystemInterface, check_permissions), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - initialized = TRUE; -} - -GType -nm_settings_system_interface_get_type (void) -{ - static GType itype = 0; - - if (!itype) { - const GTypeInfo iinfo = { - sizeof (NMSettingsSystemInterface), /* class_size */ - nm_settings_system_interface_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - itype = g_type_register_static (G_TYPE_INTERFACE, - "NMSettingsSystemInterface", - &iinfo, 0); - - g_type_interface_add_prerequisite (itype, NM_TYPE_SETTINGS_INTERFACE); - } - - return itype; -} - diff --git a/libnm-glib/nm-settings-system-interface.h b/libnm-glib/nm-settings-system-interface.h deleted file mode 100644 index d016556123..0000000000 --- a/libnm-glib/nm-settings-system-interface.h +++ /dev/null @@ -1,108 +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 - 2009 Red Hat, Inc. - */ - -#ifndef NM_SETTINGS_SYSTEM_INTERFACE_H -#define NM_SETTINGS_SYSTEM_INTERFACE_H - -#include - -#include "NetworkManager.h" - -G_BEGIN_DECLS - -typedef enum { - NM_SETTINGS_SYSTEM_PERMISSION_NONE = 0x0, - NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY = 0x1, - NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_PROTECTED = 0x2, - NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_OPEN = 0x4, - NM_SETTINGS_SYSTEM_PERMISSION_HOSTNAME_MODIFY = 0x8 -} NMSettingsSystemPermissions; - -#define NM_TYPE_SETTINGS_SYSTEM_INTERFACE (nm_settings_system_interface_get_type ()) -#define NM_SETTINGS_SYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE, NMSettingsSystemInterface)) -#define NM_IS_SETTINGS_SYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE)) -#define NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE, NMSettingsSystemInterface)) - -#define NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME "hostname" -#define NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY "can-modify" - -#define NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS "check-permissions" - -typedef enum { - NM_SETTINGS_SYSTEM_INTERFACE_PROP_FIRST = 0x1000, - - NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME = NM_SETTINGS_SYSTEM_INTERFACE_PROP_FIRST, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY -} NMSettingsSystemInterfaceProp; - - -typedef struct _NMSettingsSystemInterface NMSettingsSystemInterface; - - -typedef void (*NMSettingsSystemSaveHostnameFunc) (NMSettingsSystemInterface *settings, - GError *error, - gpointer user_data); - -typedef void (*NMSettingsSystemGetPermissionsFunc) (NMSettingsSystemInterface *settings, - NMSettingsSystemPermissions permissions, - GError *error, - gpointer user_data); - -struct _NMSettingsSystemInterface { - GTypeInterface g_iface; - - /* Methods */ - gboolean (*save_hostname) (NMSettingsSystemInterface *settings, - const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, - gpointer user_data); - - gboolean (*get_permissions) (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, - gpointer user_data); - - /* Signals */ - void (*check_permissions) (NMSettingsSystemInterface *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_system_interface_get_type (void); - -gboolean nm_settings_system_interface_save_hostname (NMSettingsSystemInterface *settings, - const char *hostname, - NMSettingsSystemSaveHostnameFunc callback, - gpointer user_data); - -gboolean nm_settings_system_interface_get_permissions (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, - gpointer user_data); - -G_END_DECLS - -#endif /* NM_SETTINGS_SYSTEM_INTERFACE_H */ diff --git a/src/nm-manager.c b/src/nm-manager.c index f77d89a8f1..6f2191f1fb 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -53,7 +53,6 @@ #include "nm-sysconfig-settings.h" #include "nm-secrets-provider-interface.h" #include "nm-settings-interface.h" -#include "nm-settings-system-interface.h" #include "nm-manager-auth.h" #define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd" @@ -3014,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_SYSTEM_INTERFACE_HOSTNAME, + g_signal_connect (priv->sys_settings, "notify::" NM_SETTINGS_INTERFACE_HOSTNAME, G_CALLBACK (system_hostname_changed_cb), singleton); g_signal_connect (priv->sys_settings, "new-connection", G_CALLBACK (system_new_connection_cb), singleton); diff --git a/src/system-settings/Makefile.am b/src/system-settings/Makefile.am index 005c878cdb..0544c6e867 100644 --- a/src/system-settings/Makefile.am +++ b/src/system-settings/Makefile.am @@ -9,8 +9,7 @@ INCLUDES = -I${top_srcdir} \ noinst_LTLIBRARIES = libsystem-settings.la BUILT_SOURCES = \ - nm-settings-glue.h \ - nm-settings-system-glue.h + nm-settings-glue.h libsystem_settings_la_SOURCES = \ nm-sysconfig-settings.c \ @@ -58,9 +57,6 @@ libsystem_settings_la_LDFLAGS = -rdynamic nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $< -nm-settings-system-glue.h: $(top_srcdir)/introspection/nm-settings-system.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_system --mode=glib-server --output=$@ $< - CLEANFILES = \ $(BUILT_SOURCES) diff --git a/src/system-settings/nm-sysconfig-settings.c b/src/system-settings/nm-sysconfig-settings.c index e3b31cd580..0dff2285a2 100644 --- a/src/system-settings/nm-sysconfig-settings.c +++ b/src/system-settings/nm-sysconfig-settings.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -96,7 +95,6 @@ static void impl_settings_get_permissions (NMSysconfigSettings *self, DBusGMethodInvocation *context); #include "nm-settings-glue.h" -#include "nm-settings-system-glue.h" static void unmanaged_specs_changed (NMSystemConfigInterface *config, gpointer user_data); @@ -117,15 +115,11 @@ typedef struct { GSList *unmanaged_specs; } NMSysconfigSettingsPrivate; -static void settings_system_interface_init (NMSettingsSystemInterface *klass); - 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_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_SYSTEM_INTERFACE, - settings_system_interface_init)) + settings_interface_init)) #define NM_SYSCONFIG_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsPrivate)) @@ -391,7 +385,7 @@ hostname_changed (NMSystemConfigInterface *config, GParamSpec *pspec, gpointer user_data) { - g_object_notify (G_OBJECT (user_data), NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME); + g_object_notify (G_OBJECT (user_data), NM_SETTINGS_INTERFACE_HOSTNAME); } static void @@ -613,7 +607,7 @@ typedef struct { char *hostname; - NMSettingsSystemPermissions permissions; + NMSettingsPermissions permissions; guint32 permissions_calls; } PolkitCall; @@ -946,14 +940,14 @@ 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_SYSTEM_INTERFACE_CHECK_PERMISSIONS); + NM_SETTINGS_INTERFACE_CHECK_PERMISSIONS); } typedef struct { PolkitCall *pk_call; const char *pk_action; GCancellable *cancellable; - NMSettingsSystemPermissions permission; + NMSettingsPermissions permission; gboolean disposed; } PermissionsCall; @@ -1025,14 +1019,14 @@ static void start_permission_check (NMSysconfigSettings *self, PolkitCall *pk_call, const char *pk_action, - NMSettingsSystemPermissions permission) + NMSettingsPermissions permission) { NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self); PermissionsCall *call; g_return_if_fail (pk_call != NULL); g_return_if_fail (pk_action != NULL); - g_return_if_fail (permission != NM_SETTINGS_SYSTEM_PERMISSION_NONE); + g_return_if_fail (permission != NM_SETTINGS_PERMISSION_NONE); call = g_malloc0 (sizeof (PermissionsCall)); call->pk_call = pk_call; @@ -1068,32 +1062,32 @@ impl_settings_get_permissions (NMSysconfigSettings *self, if (get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) { start_permission_check (self, call, NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY, - NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY); + 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)) { start_permission_check (self, call, NM_SYSCONFIG_POLICY_ACTION_HOSTNAME_MODIFY, - NM_SETTINGS_SYSTEM_PERMISSION_HOSTNAME_MODIFY); + NM_SETTINGS_PERMISSION_HOSTNAME_MODIFY); } // FIXME: hook these into plugin permissions like the modify permissions */ start_permission_check (self, call, NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_OPEN, - NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_OPEN); + NM_SETTINGS_PERMISSION_WIFI_SHARE_OPEN); start_permission_check (self, call, NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_PROTECTED, - NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_PROTECTED); + NM_SETTINGS_PERMISSION_WIFI_SHARE_PROTECTED); } static gboolean -get_permissions (NMSettingsSystemInterface *settings, - NMSettingsSystemGetPermissionsFunc callback, +get_permissions (NMSettingsInterface *settings, + NMSettingsGetPermissionsFunc callback, gpointer user_data) { NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (settings); - NMSettingsSystemPermissions permissions = NM_SETTINGS_SYSTEM_PERMISSION_NONE; + 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 @@ -1103,15 +1097,15 @@ get_permissions (NMSettingsSystemInterface *settings, /* 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_SYSTEM_PERMISSION_CONNECTION_MODIFY; + 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_SYSTEM_PERMISSION_HOSTNAME_MODIFY; + permissions |= NM_SETTINGS_PERMISSION_HOSTNAME_MODIFY; // FIXME: hook these into plugin permissions like the modify permissions */ - permissions |= NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_OPEN; - permissions |= NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_PROTECTED; + permissions |= NM_SETTINGS_PERMISSION_WIFI_SHARE_OPEN; + permissions |= NM_SETTINGS_PERMISSION_WIFI_SHARE_PROTECTED; callback (settings, permissions, NULL, user_data); return TRUE; @@ -1535,21 +1529,13 @@ finalize (GObject *object) G_OBJECT_CLASS (nm_sysconfig_settings_parent_class)->finalize (object); } -static void -settings_system_interface_init (NMSettingsSystemInterface *iface) -{ - iface->get_permissions = get_permissions; - - dbus_g_object_type_install_info (G_TYPE_FROM_INTERFACE (iface), - &dbus_glib_nm_settings_system_object_info); -} - 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); @@ -1595,14 +1581,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_SYSTEM_INTERFACE_PROP_HOSTNAME: + case NM_SETTINGS_INTERFACE_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_SYSTEM_INTERFACE_PROP_CAN_MODIFY: + case NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY: g_value_set_boolean (value, !!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)); break; default: @@ -1649,12 +1635,12 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class) G_PARAM_READABLE)); g_object_class_override_property (object_class, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME, - NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME); + NM_SETTINGS_INTERFACE_PROP_HOSTNAME, + NM_SETTINGS_INTERFACE_HOSTNAME); g_object_class_override_property (object_class, - NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY, - NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY); + NM_SETTINGS_INTERFACE_PROP_CAN_MODIFY, + NM_SETTINGS_INTERFACE_CAN_MODIFY); /* signals */ signals[PROPERTIES_CHANGED] = @@ -1667,7 +1653,7 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class) G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT); dbus_g_error_domain_register (NM_SYSCONFIG_SETTINGS_ERROR, - NM_DBUS_IFACE_SETTINGS_SYSTEM, + NM_DBUS_IFACE_SETTINGS, NM_TYPE_SYSCONFIG_SETTINGS_ERROR); dbus_g_error_domain_register (NM_SETTINGS_INTERFACE_ERROR,