From 6f71a81caa714efe8600f42cc656cfacbf1f5b6c Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Thu, 4 Jun 2020 15:49:12 +0900 Subject: [PATCH] Changes dbus user_data from the listener list to a listener - We can specify listener for the dbus signal. So it is not neccesary to send whole listener list. Change-Id: Ia27233c64a897f88933ed2cbb4d97bef6fc81c1e --- src/media_controller_ipc.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/media_controller_ipc.c b/src/media_controller_ipc.c index 2b8b8cd..5d15c4f 100644 --- a/src/media_controller_ipc.c +++ b/src/media_controller_ipc.c @@ -56,34 +56,22 @@ static void __dbus_signal_cb(GDBusConnection *connection, GVariant *parameters, gpointer user_data) { - GList **listener_list = (GList **)user_data; - GList *found_item = NULL; - mc_ipc_listener_s *listener = NULL; - char *key = NULL; - - mc_debug("__mc_ipc_signal_cb Received :"); - + mc_ipc_listener_s *listener = (mc_ipc_listener_s *)user_data; gchar *message = NULL; gchar *request_id = NULL; + mc_debug("__dbus_signal_cb Received :"); + g_variant_get(parameters, "(&s&s)", &request_id, &message); mc_retm_if_failed(message); mc_retm_if_failed(user_data); - if ((request_id != NULL) && (!g_strcmp0(request_id, DEFAULT_REQ_ID))) + if (!g_strcmp0(request_id, DEFAULT_REQ_ID)) request_id = NULL; - key = __make_key_for_map(interface_name, signal_name); - found_item = g_list_find_custom(*listener_list, key, __find_dbus_listener_by_key); - if (found_item && found_item->data) { - listener = found_item->data; - mc_secure_debug("Received : [%s] (req_id = %s) from %s.%s", message, request_id, interface_name, signal_name); - listener->callback(interface_name, signal_name, message, request_id, listener->user_data); - } else { - mc_secure_error("listener[%s] not found", key); - } + mc_secure_debug("Recv: [%s] (id: %s) from %s.%s", message, request_id, interface_name, signal_name); - g_free(key); + listener->callback(interface_name, signal_name, message, request_id, listener->user_data); } static void __free_dbus_listener(gpointer data) @@ -218,7 +206,7 @@ int _mc_ipc_register_listener(GList **listener_list, GDBusConnection *connection NULL, G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__dbus_signal_cb, - (gpointer)listener_list, + (gpointer)listener, NULL); if (listener->handler == 0) { -- 2.7.4