Commit 84f3d0c3 authored by Simon McVittie's avatar Simon McVittie

CbyPerUserBridge: Take a service manager argument at construct-time

Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
Reviewed-by: Frédéric Dalleau's avatarFrédéric Dalleau <frederic.dalleau@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D7070
parent 0ba685df
......@@ -420,7 +420,7 @@ gint main(gint argc, gchar *pArgv[])
/* Register to receive TerminateBundle() before we start launching anything,
* so that anything we launch, we are definitely able to terminate. */
per_user_bridge = cby_per_user_bridge_new ();
per_user_bridge = cby_per_user_bridge_new (service_manager);
cby_per_user_bridge_register_async (per_user_bridge, per_user_bridge_cb,
g_object_ref (task));
......
......@@ -170,7 +170,7 @@ main (int argc,
/* Register to receive TerminateBundle() before we start launching anything,
* so that anything we launch, we are definitely able to terminate. */
per_user_bridge = cby_per_user_bridge_new ();
per_user_bridge = cby_per_user_bridge_new (service_manager);
cby_per_user_bridge_register_async (per_user_bridge, per_user_bridge_cb,
g_object_ref (task));
......
......@@ -17,10 +17,16 @@ struct _CbyPerUserBridge
GDBusConnection *system_bus;
CbyPrivilegedAppHelper1 *priv_app_helper_proxy;
GTask *register_task;
CbyServiceManager *service_manager;
};
G_DEFINE_TYPE (CbyPerUserBridge, cby_per_user_bridge, CBY_TYPE_PER_USER_APP_MANAGER1_SKELETON)
enum
{
PROP_SERVICE_MANAGER = 1,
};
static void
terminate_bundle_final_cb (GObject *source_object,
GAsyncResult *result,
......@@ -106,6 +112,48 @@ cby_per_user_bridge_constructed (GObject *object)
G_CALLBACK (cby_per_user_bridge_terminate_bundle), NULL);
}
static void
cby_per_user_bridge_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
CbyPerUserBridge *self = CBY_PER_USER_BRIDGE (object);
switch (prop_id)
{
case PROP_SERVICE_MANAGER:
g_value_set_object (value, self->service_manager);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cby_per_user_bridge_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
CbyPerUserBridge *self = CBY_PER_USER_BRIDGE (object);
switch (prop_id)
{
case PROP_SERVICE_MANAGER:
/* construct-only */
g_assert (self->service_manager == NULL);
self->service_manager = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cby_per_user_bridge_dispose (GObject *object)
{
......@@ -120,6 +168,7 @@ cby_per_user_bridge_dispose (GObject *object)
g_clear_object (&self->system_bus);
g_clear_object (&self->priv_app_helper_proxy);
g_clear_object (&self->register_task);
g_clear_object (&self->service_manager);
G_OBJECT_CLASS (cby_per_user_bridge_parent_class)->dispose (object);
}
......@@ -131,6 +180,19 @@ cby_per_user_bridge_class_init (CbyPerUserBridgeClass *klass)
object_class->constructed = cby_per_user_bridge_constructed;
object_class->dispose = cby_per_user_bridge_dispose;
object_class->get_property = cby_per_user_bridge_get_property;
object_class->set_property = cby_per_user_bridge_set_property;
/**
* CbyPerUserBridge:service-manager:
*
* The service manager used to stop services.
*/
g_object_class_install_property (object_class, PROP_SERVICE_MANAGER,
g_param_spec_object (
"service-manager", "Service manager",
"Service manager used to stop services", CBY_TYPE_SERVICE_MANAGER,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
......@@ -139,9 +201,13 @@ cby_per_user_bridge_init (CbyPerUserBridge *self)
}
CbyPerUserBridge *
cby_per_user_bridge_new (void)
cby_per_user_bridge_new (CbyServiceManager *service_manager)
{
return g_object_new (CBY_TYPE_PER_USER_BRIDGE, NULL);
g_return_val_if_fail (CBY_IS_SERVICE_MANAGER (service_manager), NULL);
return g_object_new (CBY_TYPE_PER_USER_BRIDGE,
"service-manager", service_manager,
NULL);
}
static void
......
......@@ -15,13 +15,15 @@
#include <canterbury/canterbury-platform.h>
#include "service-manager.h"
G_BEGIN_DECLS
#define CBY_TYPE_PER_USER_BRIDGE (cby_per_user_bridge_get_type ())
G_DECLARE_FINAL_TYPE (CbyPerUserBridge, cby_per_user_bridge, CBY, PER_USER_BRIDGE, CbyPerUserAppManager1Skeleton)
CbyPerUserBridge *cby_per_user_bridge_new (void);
CbyPerUserBridge *cby_per_user_bridge_new (CbyServiceManager *service_manager);
void cby_per_user_bridge_register_async (CbyPerUserBridge *self,
GAsyncReadyCallback callback,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment