2008-11-14 Dan Williams <dcbw@redhat.com>

* libnm-glib/libnm_glib.ver
	  libnm-glib/nm-dbus-settings-system.c
	  libnm-glib/nm-dbus-settings-system.h
		- Add libnm-glib bits for CanModify



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4289 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-11-14 19:54:10 +00:00
parent afe017c772
commit 0efa714d50
4 changed files with 64 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2008-11-14 Dan Williams <dcbw@redhat.com>
* libnm-glib/libnm_glib.ver
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add libnm-glib bits for CanModify
2008-11-14 Dan Williams <dcbw@redhat.com>
* introspection/nm-settings-system.xml

View file

@ -46,6 +46,7 @@ global:
nm_dbus_settings_get_type;
nm_dbus_settings_new;
nm_dbus_settings_system_add_connection;
nm_dbus_settings_system_get_can_modify;
nm_dbus_settings_system_get_type;
nm_dbus_settings_system_get_unmanaged_devices;
nm_dbus_settings_system_new;

View file

@ -40,6 +40,9 @@ typedef struct {
gboolean got_hostname;
char *hostname;
gboolean got_can_modify;
gboolean can_modify;
gboolean disposed;
} NMDBusSettingsSystemPrivate;
@ -47,6 +50,7 @@ enum {
PROP_0,
PROP_UNMANAGED_DEVICES,
PROP_HOSTNAME,
PROP_CAN_MODIFY,
LAST_PROP
};
@ -201,12 +205,44 @@ nm_dbus_settings_system_get_hostname (NMDBusSettingsSystem *self)
return priv->hostname;
}
gboolean
nm_dbus_settings_system_get_can_modify (NMDBusSettingsSystem *self)
{
NMDBusSettingsSystemPrivate *priv;
GValue value = { 0, };
GError *err = NULL;
g_return_val_if_fail (NM_IS_DBUS_SETTINGS_SYSTEM (self), FALSE);
priv = NM_DBUS_SETTINGS_SYSTEM_GET_PRIVATE (self);
if (priv->got_can_modify)
return priv->can_modify;
if (!dbus_g_proxy_call (priv->props_proxy, "Get", &err,
G_TYPE_STRING, NM_DBUS_SERVICE_SYSTEM_SETTINGS,
G_TYPE_STRING, "CanModify",
G_TYPE_INVALID,
G_TYPE_VALUE, &value,
G_TYPE_INVALID)) {
g_warning ("Could not retrieve can-modify: %s", err->message);
g_error_free (err);
return FALSE;
}
priv->can_modify = g_value_get_boolean (&value);
g_value_unset (&value);
return priv->can_modify;
}
static void
proxy_properties_changed (DBusGProxy *proxy,
GHashTable *properties,
gpointer user_data)
{
NMDBusSettingsSystem *self = NM_DBUS_SETTINGS_SYSTEM (user_data);
NMDBusSettingsSystemPrivate * priv = NM_DBUS_SETTINGS_SYSTEM_GET_PRIVATE (self);
GValue *value;
value = (GValue *) g_hash_table_lookup (properties, "UnmanagedDevices");
@ -220,6 +256,12 @@ proxy_properties_changed (DBusGProxy *proxy,
update_hostname (self, value);
g_object_notify (G_OBJECT (self), NM_DBUS_SETTINGS_SYSTEM_HOSTNAME);
}
value = (GValue *) g_hash_table_lookup (properties, "CanModify");
if (value) {
priv->can_modify = g_value_get_boolean (value);
g_object_notify (G_OBJECT (self), NM_DBUS_SETTINGS_SYSTEM_CAN_MODIFY);
}
}
static void
@ -303,6 +345,9 @@ get_property (GObject *object, guint prop_id,
case PROP_HOSTNAME:
g_value_set_string (value, nm_dbus_settings_system_get_hostname (self));
break;
case PROP_CAN_MODIFY:
g_value_set_boolean (value, nm_dbus_settings_system_get_can_modify (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -336,5 +381,13 @@ nm_dbus_settings_system_class_init (NMDBusSettingsSystemClass *dbus_settings_cla
"Configured hostname",
NULL,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_HOSTNAME,
g_param_spec_boolean (NM_DBUS_SETTINGS_SYSTEM_CAN_MODIFY,
"Can modify",
"Can modify",
FALSE,
G_PARAM_READABLE));
}

View file

@ -37,6 +37,7 @@ G_BEGIN_DECLS
#define NM_DBUS_SETTINGS_SYSTEM_UNMANAGED_DEVICES "unmanaged-devices"
#define NM_DBUS_SETTINGS_SYSTEM_HOSTNAME "hostname"
#define NM_DBUS_SETTINGS_SYSTEM_CAN_MODIFY "can-modify"
typedef struct {
NMDBusSettings parent;
@ -62,6 +63,8 @@ gboolean nm_dbus_settings_system_save_hostname (NMDBusSettingsSystem *self,
const char *hostname,
GError **err);
gboolean nm_dbus_settings_system_get_can_modify (NMDBusSettingsSystem *self);
G_END_DECLS
#endif /* NM_DBUS_SETTINGS_SYSTEM_H */