[PATCH] libnm-glib: added service-running property to NMRemoteSettings
- From: Witold Sowa <witold sowa gmail com>
- To: networkmanager-list gnome org
- Subject: [PATCH] libnm-glib: added service-running property to NMRemoteSettings
- Date: Wed, 02 Sep 2009 23:54:16 +0200
The new readonly boolean property informs if settings service
is running (i.e. org.freedesktop.NetworkManagerUserSettings or
org.freedesktop.NetworkManagerSystemSettings name is registered
in DBus bus).
---
libnm-glib/nm-remote-settings.c | 35 ++++++++++++++++++++++++++++++++---
libnm-glib/nm-remote-settings.h | 1 +
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c
index 0e928fb..b930ef6 100644
--- a/libnm-glib/nm-remote-settings.c
+++ b/libnm-glib/nm-remote-settings.c
@@ -45,6 +45,7 @@ typedef struct {
DBusGProxy *proxy;
GHashTable *connections;
GHashTable *pending; /* Connections we don't have settings for yet */
+ gboolean service_running;
DBusGProxy *dbus_proxy;
@@ -57,6 +58,7 @@ enum {
PROP_0,
PROP_BUS,
PROP_SCOPE,
+ PROP_SERVICE_RUNNING,
LAST_PROP
};
@@ -160,7 +162,7 @@ fetch_connections_done (DBusGProxy *proxy,
gpointer user_data)
{
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
+ NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
int i;
if (error) {
@@ -292,10 +294,15 @@ name_owner_changed (DBusGProxy *proxy,
if (priv->fetch_id)
g_source_remove (priv->fetch_id);
- if (new_owner && strlen (new_owner) > 0)
+ if (new_owner && strlen (new_owner) > 0) {
priv->fetch_id = g_idle_add (fetch_connections, self);
- else
+ priv->service_running = TRUE;
+ }
+ else {
priv->fetch_id = g_idle_add (remove_connections, self);
+ priv->service_running = FALSE;
+ }
+ g_object_notify(G_OBJECT (self), NM_REMOTE_SETTINGS_SERVICE_RUNNING);
}
}
@@ -347,6 +354,8 @@ constructor (GType type,
{
GObject *object;
NMRemoteSettingsPrivate *priv;
+ GError *err = NULL;
+
const char *service = NM_DBUS_SERVICE_USER_SETTINGS;
object = G_OBJECT_CLASS (nm_remote_settings_parent_class)->constructor (type, n_construct_params, construct_params);
@@ -378,6 +387,15 @@ constructor (GType type,
if (priv->scope == NM_CONNECTION_SCOPE_SYSTEM)
service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
+ if (!dbus_g_proxy_call(priv->dbus_proxy, "NameHasOwner", &err,
+ G_TYPE_STRING, service,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &priv->service_running,
+ G_TYPE_INVALID)) {
+ g_warning ("Error in NMRemoteSettings constructor: %s\n", err->message);
+ g_error_free (err);
+ }
+
priv->proxy = dbus_g_proxy_new_for_name (priv->bus,
service,
NM_DBUS_PATH_SETTINGS,
@@ -456,6 +474,9 @@ get_property (GObject *object, guint prop_id,
case PROP_SCOPE:
g_value_set_uint (value, priv->scope);
break;
+ case PROP_SERVICE_RUNNING:
+ g_value_set_boolean (value, priv->service_running);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -494,6 +515,14 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class)
NM_CONNECTION_SCOPE_USER,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property
+ (object_class, PROP_SERVICE_RUNNING,
+ g_param_spec_boolean (NM_REMOTE_SETTINGS_SERVICE_RUNNING,
+ "Service running",
+ "Is service running",
+ FALSE,
+ G_PARAM_READABLE));
+
/* Signals */
g_signal_new (NM_REMOTE_SETTINGS_CONNECTIONS_FETCHED,
G_OBJECT_CLASS_TYPE (object_class),
diff --git a/libnm-glib/nm-remote-settings.h b/libnm-glib/nm-remote-settings.h
index 05be199..4e97431 100644
--- a/libnm-glib/nm-remote-settings.h
+++ b/libnm-glib/nm-remote-settings.h
@@ -40,6 +40,7 @@ G_BEGIN_DECLS
#define NM_REMOTE_SETTINGS_BUS "bus"
#define NM_REMOTE_SETTINGS_SCOPE "scope"
+#define NM_REMOTE_SETTINGS_SERVICE_RUNNING "service-running"
#define NM_REMOTE_SETTINGS_CONNECTIONS_FETCHED "connections-fetched"
--
1.6.0.2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]