diff options
author | Cody Russell <crussell@canonical.com> | 2009-09-22 17:31:31 -0500 |
---|---|---|
committer | Cody Russell <crussell@canonical.com> | 2009-09-22 17:31:31 -0500 |
commit | de28377d3ad3797516826f287f554dfefb7fdb47 (patch) | |
tree | 388dde3d19f7ee5d2594912877aa2b0f1e2cb2ed /src/users-service-dbus.c | |
parent | 0e5b24c9c86750f4ce10f9a53846da049caeb179 (diff) | |
download | ayatana-indicator-session-de28377d3ad3797516826f287f554dfefb7fdb47.tar.gz ayatana-indicator-session-de28377d3ad3797516826f287f554dfefb7fdb47.tar.bz2 ayatana-indicator-session-de28377d3ad3797516826f287f554dfefb7fdb47.zip |
some refactoring
Diffstat (limited to 'src/users-service-dbus.c')
-rw-r--r-- | src/users-service-dbus.c | 89 |
1 files changed, 59 insertions, 30 deletions
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 8685105..acc3f7d 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -53,6 +53,9 @@ static gboolean _users_service_server_get_users_info (UsersServiceDbus *servi const GArray *uids, GPtrArray **user_info, GError **error); +static void create_session_proxy (UsersServiceDbus *self); +static void create_system_proxy (UsersServiceDbus *self); +static void create_gdm_proxy (UsersServiceDbus *self); static void users_loaded (DBusGProxy *proxy, gpointer user_data); static void user_added (DBusGProxy *proxy, @@ -154,26 +157,57 @@ users_service_dbus_init (UsersServiceDbus *self) /* Get the buses */ priv->session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (error != NULL) { - g_error ("Unable to get session bus: %s", error->message); - g_error_free (error); + if (error != NULL) + { + g_error ("Unable to get session bus: %s", error->message); + g_error_free (error); - return; - } + return; + } priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - if (error != NULL) { - g_error("Unable to get system bus: %s", error->message); - g_error_free(error); + if (error != NULL) + { + g_error("Unable to get system bus: %s", error->message); + g_error_free(error); - return; - } + return; + } dbus_g_connection_register_g_object (priv->session_bus, INDICATOR_USERS_SERVICE_DBUS_OBJECT, G_OBJECT (self)); - /* Set up the DBUS service proxies */ + dbus_g_object_register_marshaller (_users_service_marshal_VOID__INT64, + G_TYPE_NONE, + G_TYPE_INT64, + G_TYPE_INVALID); + + create_session_proxy (self); + create_system_proxy (self); + create_gdm_proxy (self); + + users_loaded (priv->gdm_proxy, self); +} + +static void +users_service_dbus_dispose (GObject *object) +{ + G_OBJECT_CLASS (users_service_dbus_parent_class)->dispose (object); +} + +static void +users_service_dbus_finalize (GObject *object) +{ + G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object); +} + +static void +create_session_proxy (UsersServiceDbus *self) +{ + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + GError *error = NULL; + priv->dbus_proxy_session = dbus_g_proxy_new_for_name_owner (priv->session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, @@ -186,6 +220,13 @@ users_service_dbus_init (UsersServiceDbus *self) return; } +} + +static void +create_system_proxy (UsersServiceDbus *self) +{ + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + GError *error = NULL; priv->dbus_proxy_system = dbus_g_proxy_new_for_name_owner (priv->system_bus, DBUS_SERVICE_DBUS, @@ -199,6 +240,13 @@ users_service_dbus_init (UsersServiceDbus *self) return; } +} + +static void +create_gdm_proxy (UsersServiceDbus *self) +{ + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + GError *error = NULL; priv->gdm_proxy = dbus_g_proxy_new_for_name_owner (priv->system_bus, "org.gnome.DisplayManager", @@ -212,11 +260,6 @@ users_service_dbus_init (UsersServiceDbus *self) g_error_free (error); } - dbus_g_object_register_marshaller (_users_service_marshal_VOID__INT64, - G_TYPE_NONE, - G_TYPE_INT64, - G_TYPE_INVALID); - dbus_g_proxy_add_signal (priv->gdm_proxy, "UsersLoaded", G_TYPE_INVALID); @@ -259,20 +302,6 @@ users_service_dbus_init (UsersServiceDbus *self) G_CALLBACK (user_updated), self, NULL); - - users_loaded (priv->gdm_proxy, self); -} - -static void -users_service_dbus_dispose (GObject *object) -{ - G_OBJECT_CLASS (users_service_dbus_parent_class)->dispose (object); -} - -static void -users_service_dbus_finalize (GObject *object) -{ - G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object); } static void |