Commit 09c95b20 authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Add "Destroy" D-Bus signal to server for debug.

parent a7f81c3c
......@@ -157,6 +157,7 @@ eek_key_real_deserialize (EekSerializable *self,
g_variant_get_child (variant, index++, "u", &priv->keycode);
g_variant_get_child (variant, index++, "v", &symbol_matrix);
eek_symbol_matrix_free (priv->symbol_matrix);
priv->symbol_matrix = _g_variant_get_symbol_matrix (symbol_matrix);
g_variant_get_child (variant, index++, "i", &priv->column);
g_variant_get_child (variant, index++, "i", &priv->row);
......
......@@ -165,6 +165,8 @@ eek_keyboard_real_deserialize (EekSerializable *self,
while (g_variant_iter_next (&iter, "v", &outline)) {
EekOutline *_outline = _g_variant_get_outline (outline);
g_array_append_val (priv->outline_array, *_outline);
/* don't use eek_outline_free here, so as to keep _outline->points */
g_slice_free (EekOutline, _outline);
}
g_variant_get_child (variant, index++, "u", &priv->num_lock_mask);
......
......@@ -329,6 +329,7 @@ server_context_finalize (GObject *object)
{
ServerContext *context = SERVER_CONTEXT(object);
g_free (context->object_path);
g_free (context->client_connection);
G_OBJECT_CLASS (server_context_parent_class)->finalize (object);
......@@ -502,7 +503,7 @@ handle_method_call (GDBusConnection *connection,
g_hash_table_insert (context->keyboard_hash,
GUINT_TO_POINTER(++keyboard_id),
g_object_ref (serializable));
serializable);
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(u)",
keyboard_id));
......
......@@ -60,6 +60,15 @@ on_name_lost (GDBusConnection *connection,
exit (1);
}
static void
on_destroyed (ServerServer *server,
gpointer user_data)
{
GMainLoop *loop = user_data;
g_main_loop_quit (loop);
}
int
main (int argc, char **argv)
{
......@@ -147,6 +156,9 @@ main (int argc, char **argv)
}
loop = g_main_loop_new (NULL, FALSE);
g_signal_connect (server, "destroyed", G_CALLBACK(on_destroyed), loop);
g_main_loop_run (loop);
g_bus_unown_name (owner_id);
......
......@@ -22,6 +22,8 @@
#include "server-server.h"
#include "server-context.h"
#define I_(string) g_intern_static_string (string)
enum {
PROP_0,
PROP_OBJECT_PATH,
......@@ -29,6 +31,13 @@ enum {
PROP_LAST
};
enum {
DESTROYED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0, };
static const gchar introspection_xml[] =
"<node>"
" <interface name='com.redhat.Eekboard.Server'>"
......@@ -43,6 +52,7 @@ static const gchar introspection_xml[] =
" <method name='DestroyContext'>"
" <arg direction='in' type='s' name='object_path'/>"
" </method>"
" <method name='Destroy'/>"
/* signals */
" </interface>"
"</node>";
......@@ -147,6 +157,16 @@ server_server_dispose (GObject *object)
G_OBJECT_CLASS (server_server_parent_class)->dispose (object);
}
static void
server_server_finalize (GObject *object)
{
ServerServer *server = SERVER_SERVER(object);
g_free (server->object_path);
G_OBJECT_CLASS (server_server_parent_class)->dispose (object);
}
static void
server_server_constructed (GObject *object)
{
......@@ -174,6 +194,18 @@ server_server_class_init (ServerServerClass *klass)
gobject_class->constructed = server_server_constructed;
gobject_class->set_property = server_server_set_property;
gobject_class->dispose = server_server_dispose;
gobject_class->finalize = server_server_finalize;
signals[DESTROYED] =
g_signal_new (I_("destroyed"),
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
pspec = g_param_spec_string ("object-path",
"Object-path",
......@@ -360,6 +392,12 @@ handle_method_call (GDBusConnection *connection,
return;
}
if (g_strcmp0 (method_name, "Destroy") == 0) {
g_signal_emit_by_name (server, "destroyed", NULL);
g_dbus_method_invocation_return_value (invocation, NULL);
return;
}
g_return_if_reached ();
}
......
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