From f1fbb375479e92bdc4a68836acb0e7e54e0721d5 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 22 Jun 2019 15:31:08 +0000 Subject: [PATCH] Kill connection in context service --- eekboard/eekboard-context-service.c | 102 ---------------------------- src/server-context-service.c | 4 +- src/server-context-service.h | 3 +- src/server-service.c | 4 +- 4 files changed, 3 insertions(+), 110 deletions(-) diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index 970f0c42..5771d102 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -40,7 +40,6 @@ enum { PROP_0, PROP_OBJECT_PATH, - PROP_CONNECTION, PROP_CLIENT_NAME, PROP_KEYBOARD, PROP_VISIBLE, @@ -61,7 +60,6 @@ static guint signals[LAST_SIGNAL] = { 0, }; (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServicePrivate)) struct _EekboardContextServicePrivate { - GDBusConnection *connection; GDBusNodeInfo *introspection_data; guint registration_id; @@ -204,9 +202,6 @@ eekboard_context_service_real_show_keyboard (EekboardContextService *self) { gboolean visible = self->priv->visible; self->priv->visible = TRUE; - if (visible != self->priv->visible) - emit_visibility_changed_signal (self, - self->priv->visible); } static void @@ -214,9 +209,6 @@ eekboard_context_service_real_hide_keyboard (EekboardContextService *self) { gboolean visible = self->priv->visible; self->priv->visible = FALSE; - if (visible != self->priv->visible) - emit_visibility_changed_signal (self, - self->priv->visible); } static void @@ -226,7 +218,6 @@ eekboard_context_service_set_property (GObject *object, GParamSpec *pspec) { EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object); - GDBusConnection *connection; switch (prop_id) { case PROP_OBJECT_PATH: @@ -234,12 +225,6 @@ eekboard_context_service_set_property (GObject *object, g_free (context->priv->object_path); context->priv->object_path = g_value_dup_string (value); break; - case PROP_CONNECTION: - connection = g_value_get_object (value); - if (context->priv->connection) - g_object_unref (context->priv->connection); - context->priv->connection = g_object_ref (connection); - break; case PROP_CLIENT_NAME: if (context->priv->client_name) g_free (context->priv->client_name); @@ -279,9 +264,6 @@ eekboard_context_service_get_property (GObject *object, case PROP_OBJECT_PATH: g_value_set_string (value, context->priv->object_path); break; - case PROP_CONNECTION: - g_value_set_object (value, context->priv->connection); - break; case PROP_CLIENT_NAME: g_value_set_string (value, context->priv->client_name); break; @@ -310,17 +292,6 @@ eekboard_context_service_dispose (GObject *object) context->priv->keyboard_hash = NULL; } - if (context->priv->connection) { - if (context->priv->registration_id > 0) { - g_dbus_connection_unregister_object (context->priv->connection, - context->priv->registration_id); - context->priv->registration_id = 0; - } - - g_object_unref (context->priv->connection); - context->priv->connection = NULL; - } - if (context->priv->introspection_data) { g_dbus_node_info_unref (context->priv->introspection_data); context->priv->introspection_data = NULL; @@ -509,20 +480,6 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass) PROP_OBJECT_PATH, pspec); - /** - * EekboardContextService:connection: - * - * D-Bus connection. - */ - pspec = g_param_spec_object ("connection", - "Connection", - "Connection", - G_TYPE_DBUS_CONNECTION, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE); - g_object_class_install_property (gobject_class, - PROP_CONNECTION, - pspec); - /** * EekboardContextService:client-name: * @@ -630,31 +587,6 @@ disconnect_keyboard_signals (EekboardContextService *context) } } -static void -emit_visibility_changed_signal (EekboardContextService *context, - gboolean visible) -{ - return; // FIXME: update Visible property - if (context->priv->connection && context->priv->enabled) { - GError *error = NULL; - gboolean retval; - - retval = g_dbus_connection_emit_signal (context->priv->connection, - NULL, - context->priv->object_path, - EEKBOARD_CONTEXT_SERVICE_INTERFACE, - "VisibilityChanged", - g_variant_new ("(b)", visible), - &error); - if (!retval) { - g_warning ("failed to emit VisibilityChanged signal: %s", - error->message); - g_error_free (error); - g_assert_not_reached (); - } - } -} - static gboolean on_repeat_timeout (EekboardContextService *context); static gboolean @@ -716,7 +648,6 @@ void eekboard_context_service_enable (EekboardContextService *context) { g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context)); - g_return_if_fail (context->priv->connection); if (!context->priv->enabled) { context->priv->enabled = TRUE; @@ -737,27 +668,12 @@ eekboard_context_service_disable (EekboardContextService *context) GError *error; g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context)); - g_return_if_fail (context->priv->connection); if (context->priv->enabled) { gboolean retval; context->priv->enabled = FALSE; - error = NULL; - retval = g_dbus_connection_emit_signal (context->priv->connection, - NULL, - context->priv->object_path, - EEKBOARD_CONTEXT_SERVICE_INTERFACE, - "Disabled", - NULL, - &error); - if (!retval) { - g_warning ("failed to emit Disabled signal: %s", - error->message); - g_error_free (error); - g_assert_not_reached (); - } g_signal_emit (context, signals[DISABLED], 0); } } @@ -766,7 +682,6 @@ void eekboard_context_service_show_keyboard (EekboardContextService *context) { g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context)); - g_return_if_fail (context->priv->connection); EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context)->show_keyboard (context); } @@ -775,7 +690,6 @@ void eekboard_context_service_hide_keyboard (EekboardContextService *context) { g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context)); - g_return_if_fail (context->priv->connection); EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context)->hide_keyboard (context); } @@ -793,26 +707,10 @@ eekboard_context_service_destroy (EekboardContextService *context) GError *error; g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context)); - g_return_if_fail (context->priv->connection); if (context->priv->enabled) { eekboard_context_service_disable (context); } - - error = NULL; - retval = g_dbus_connection_emit_signal (context->priv->connection, - NULL, - context->priv->object_path, - EEKBOARD_CONTEXT_SERVICE_INTERFACE, - "Destroyed", - NULL, - &error); - if (!retval) { - g_warning ("failed to emit Destroyed signal: %s", - error->message); - g_error_free (error); - g_assert_not_reached (); - } g_signal_emit (context, signals[DESTROYED], 0); } diff --git a/src/server-context-service.c b/src/server-context-service.c index 7af27e50..605759b9 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -492,12 +492,10 @@ server_context_service_init (ServerContextService *context) ServerContextService * server_context_service_new (const gchar *client_name, - const gchar *object_path, - GDBusConnection *connection) + const gchar *object_path) { return g_object_new (SERVER_TYPE_CONTEXT_SERVICE, "client-name", client_name, "object-path", object_path, - "connection", connection, NULL); } diff --git a/src/server-context-service.h b/src/server-context-service.h index 01114720..e37bc88f 100644 --- a/src/server-context-service.h +++ b/src/server-context-service.h @@ -32,8 +32,7 @@ G_BEGIN_DECLS typedef struct _ServerContextService ServerContextService; ServerContextService *server_context_service_new (const gchar *client_name, - const gchar *object_path, - GDBusConnection *connection); + const gchar *object_path); G_END_DECLS #endif /* SERVER_CONTEXT_SERVICE_H */ diff --git a/src/server-service.c b/src/server-service.c index 59ac3333..4fd7946b 100644 --- a/src/server-service.c +++ b/src/server-service.c @@ -42,9 +42,7 @@ server_service_real_create_context (EekboardService *self, GDBusConnection *connection; ServerContextService *context; - g_object_get (G_OBJECT(self), "connection", &connection, NULL); - context = server_context_service_new (client_name, object_path, connection); - g_object_unref (connection); + context = server_context_service_new (client_name, object_path); return EEKBOARD_CONTEXT_SERVICE(context); }