Add method for getting clines which register specified event 48/282348/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 26 Sep 2022 08:53:35 +0000 (17:53 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Fri, 30 Sep 2022 05:24:55 +0000 (14:24 +0900)
- Requirement:
Mmi core wants to get client handles which register the specified event.

- Solution:
In order to control the client following event type, mmi core module has
to get clients from the mmi client modules. Thus, this patch adds new
method for getting client handles which register the specified event.
Throught this patch, mmi core module can get the proper clients from the
mmi client module.

Change-Id: I4af834bc421dad60a79ef60b5af6b8f056ec85e7
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
src/mmimgr/mmi-client.c
src/mmimgr/mmi-client.h

index 600b8a5796593de4bb2368c9461c1e5d0209576b..9ff459ed65422871a719d1fb2828743d6ec8c583 100644 (file)
 #include <Eina.h>
 #include <stdlib.h>
 
+
+typedef struct {
+       int event_type;
+       GList *clients;
+} find_client_listening_event_args_s;
+
 Eina_Hash *_client_hash = NULL;
 static Eina_Bool _init_done = false;
 
@@ -244,6 +250,50 @@ rpc_port_stub_mmi_result_cb_h client_manager_get_result_cb_handle(mmi_client *cl
        return NULL;
 }
 
+static Eina_Bool __find_client_listening_event(const Eina_Hash *hash, const void *key, void *data, void *fdata)
+{
+       mmi_client *client = (mmi_client *)data;
+       find_client_listening_event_args_s *result = (find_client_listening_event_args_s *)fdata;
+
+       if (client == NULL || result == NULL) {
+               LOGE("Invalid data passed. Skip the current item.");
+               return EINA_TRUE;
+       }
+
+       if (g_list_length(client->result_cb_list) <= 0) {
+               LOGE("Fail to get client result_cb. There is no result_cb set");
+               return EINA_TRUE;
+       }
+
+       GList *iter = g_list_first(client->result_cb_list);
+       while (iter != NULL) {
+               mmi_result_cb_s *data = iter->data;
+               if (data != NULL) {
+                       int type = data->input_event_type;
+
+                       if (type == result->event_type) {
+                               result->clients = g_list_append(result->clients, client);
+                               break;
+                       }
+               }
+
+               iter = g_list_next(iter);
+       }
+
+       return EINA_TRUE;
+}
+
+GList *client_manager_get_clients_listening_event(int input_event_type)
+{
+       find_client_listening_event_args_s result;
+       result.event_type = input_event_type;
+       result.clients = NULL;
+
+       eina_hash_foreach(_client_hash, __find_client_listening_event, &result);
+
+       return result.clients;
+}
+
 const char *
 client_manager_get_client_sender(mmi_client *client)
 {
index bdb243f9c41f2db3b2733b2caa45b2ecbf7abf24..b418ac03ff0844707e7f48546363786b4a3595f3 100644 (file)
@@ -61,6 +61,7 @@ int client_manager_set_client_pid(mmi_client *client, pid_t pid);
 int client_manager_get_client_pid(mmi_client *client);
 const char *client_manager_get_client_sender(mmi_client *client);
 rpc_port_stub_mmi_result_cb_h client_manager_get_result_cb_handle(mmi_client *client, int input_event_type);
+GList *client_manager_get_clients_listening_event(int input_event_type);
 
 void client_manager_init(void);
 void client_manager_shutdown(void);