Commit 973da32a authored by Guido Gunther's avatar Guido Gunther Committed by Sebastian Krzyszkowiak
Browse files

Avoid sensor-proxy singleton

Treat it as regular initable that is fetched from the shell
like other managers.
parent 23ae71f8
......@@ -52,27 +52,13 @@ phosh_sensor_proxy_manager_init (PhoshSensorProxyManager *self)
PhoshSensorProxyManager *
phosh_sensor_proxy_manager_get_default_failable (void)
phosh_sensor_proxy_manager_new (GError **err)
{
static PhoshSensorProxyManager *instance;
GError *err = NULL;
GInitable *ret;
if (instance == NULL) {
ret = g_initable_new (PHOSH_TYPE_SENSOR_PROXY_MANAGER, NULL, &err,
"g-flags", G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
"g-name", IIO_SENSOR_PROXY_DBUS_NAME,
"g-bus-type", G_BUS_TYPE_SYSTEM,
"g-object-path", IIO_SENSOR_PROXY_DBUS_OBJECT,
"g-interface-name", IIO_SENSOR_PROXY_DBUS_IFACE_NAME,
NULL);
if (ret != NULL) {
instance = PHOSH_SENSOR_PROXY_MANAGER (ret);
} else {
g_warning ("Can't connect to iio-sensor-sensor proxy: %s", err->message);
return NULL;
}
g_object_add_weak_pointer (G_OBJECT (instance), (gpointer *)&instance);
}
return instance;
return g_initable_new (PHOSH_TYPE_SENSOR_PROXY_MANAGER, NULL, err,
"g-flags", G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
"g-name", IIO_SENSOR_PROXY_DBUS_NAME,
"g-bus-type", G_BUS_TYPE_SYSTEM,
"g-object-path", IIO_SENSOR_PROXY_DBUS_OBJECT,
"g-interface-name", IIO_SENSOR_PROXY_DBUS_IFACE_NAME,
NULL);
}
......@@ -13,6 +13,6 @@
G_DECLARE_FINAL_TYPE (PhoshSensorProxyManager, phosh_sensor_proxy_manager,
PHOSH, SENSOR_PROXY_MANAGER, PhoshDBusSensorProxyProxy)
PhoshSensorProxyManager *phosh_sensor_proxy_manager_get_default_failable (void);
PhoshSensorProxyManager *phosh_sensor_proxy_manager_new (GError **err);
gboolean phosh_sensor_proxy_manager_claim_proximity_sync (PhoshSensorProxyManager *self,
GError **err);
......@@ -457,12 +457,15 @@ on_fade_out_timeout (PhoshShell *self)
static gboolean
setup_idle_cb (PhoshShell *self)
{
g_autoptr (GError) err = NULL;
PhoshShellPrivate *priv = phosh_shell_get_instance_private (self);
priv->session_manager = phosh_session_manager_new ();
priv->mode_manager = phosh_mode_manager_new ();
priv->sensor_proxy_manager = phosh_sensor_proxy_manager_get_default_failable ();
priv->sensor_proxy_manager = phosh_sensor_proxy_manager_new (&err);
if (!priv->sensor_proxy_manager)
g_warning ("Failed to connect to sensor-proxy: %s", err->message);
panels_create (self);
/* Create background after panel since it needs the panel's size */
......@@ -493,7 +496,6 @@ setup_idle_cb (PhoshShell *self)
G_CONNECT_SWAPPED);
priv->location_manager = phosh_location_manager_new ();
priv->sensor_proxy_manager = phosh_sensor_proxy_manager_get_default_failable ();
if (priv->sensor_proxy_manager) {
priv->proximity = phosh_proximity_new (priv->sensor_proxy_manager,
priv->lockscreen_manager);
......
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