gdm_session_worker_constructor (GType                  type,
                                guint                  n_construct_properties,
                                GObjectConstructParam *construct_properties)
{
        GdmSessionWorker  *worker;
        GError            *error;

        worker = GDM_SESSION_WORKER (G_OBJECT_CLASS (gdm_session_worker_parent_class)->constructor (type,
                                                                                                    n_construct_properties,
                                                                                                    construct_properties));

        g_debug ("GdmSessionWorker: connecting to address: %s", worker->priv->server_address);

        error = NULL;
        worker->priv->connection = g_dbus_connection_new_for_address_sync (worker->priv->server_address,
                                                                           G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
                                                                           NULL,
                                                                           NULL,
                                                                           &error);
        if (worker->priv->connection == NULL) {
                g_warning ("error opening connection: %s", error->message);
                g_clear_error (&error);

                exit (EXIT_FAILURE);
        }

        worker->priv->manager = GDM_DBUS_WORKER_MANAGER (gdm_dbus_worker_manager_proxy_new_sync (worker->priv->connection,
                                                                                                 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
                                                                                                 NULL, /* dbus name */
                                                                                                 GDM_SESSION_DBUS_PATH,
                                                                                                 NULL,
                                                                                                 &error));
        if (worker->priv->manager == NULL) {
                g_warning ("error creating session proxy: %s", error->message);
                g_clear_error (&error);

                exit (EXIT_FAILURE);
        }

        if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (worker),
                                               worker->priv->connection,
                                               GDM_WORKER_DBUS_PATH,
                                               &error)) {
                g_warning ("Error while exporting object: %s", error->message);
                exit (EXIT_FAILURE);
        }

        g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (worker->priv->manager), G_MAXINT);

        /* Send an initial Hello message so that the session can associate
         * the conversation we manage with our pid.
         */
        gdm_dbus_worker_manager_call_hello_sync (worker->priv->manager,
                                                 NULL,
                                                 NULL);

        return G_OBJECT (worker);
}