mmifw-ipc: create, register and destroy mmifw event handlers 20/264120/1
authorSung-Jin Park <sj76.park@samsung.com>
Mon, 12 Jul 2021 11:03:11 +0000 (20:03 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 13 Sep 2021 12:14:31 +0000 (21:14 +0900)
Change-Id: I75c067c83edb90630e1240b36531bc9f7b4c588a
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/mmifw-ipc.c

index 7b433a745dd93ff7968ea1f006e12d0afdedff1d..80eb6337236242565a075547201397870205ac4e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+* Copyright Â© 2021 Samsung Electronics co., Ltd. All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
@@ -36,6 +36,15 @@ static uid_t _uid = -1;
 static int _connected = 0;
 static mmi_state _state = MMI_STATE_NONE;
 
+rpc_port_mmifw_focus_event_cb_h focus_cb_h;
+rpc_port_mmifw_state_change_event_cb_h state_change_cb_h;
+rpc_port_mmifw_wakeup_event_cb_h wakeup_cb_h;
+rpc_port_mmifw_key_event_cb_h key_cb_h;
+rpc_port_mmifw_gesture_event_cb_h gesture_cb_h;
+rpc_port_mmifw_voice_event_cb_h voice_cb_h;
+rpc_port_mmifw_action_event_cb_h action_cb_h;
+rpc_port_mmifw_feedback_event_cb_h feedback_cb_h;
+
 rpc_port_proxy_mmifw_h
 mmi_ipc_get_rpc_h(void)
 {
@@ -72,12 +81,79 @@ mmi_ipc_get_stub_appid(void)
        return _stub_appid;
 }
 
+/* event callbacks */
+static void _focus_event_cb(void *user_data, rpc_port_focus_event_h args)
+{
+       //TODO : create event
+}
+
+static void _state_change_event_cb(void *user_data, rpc_port_state_change_event_h args)
+{
+       //TODO : create event
+}
+
+static void _wakeup_event_cb(void *user_data, rpc_port_wakeup_event_h args)
+{
+       //TODO : create event
+}
+
+static void _key_event_cb(void *user_data, rpc_port_key_event_h args)
+{
+       //TODO : create event
+}
+
+static void _gesture_event_cb(void *user_data, rpc_port_gesture_event_h args)
+{
+       //TODO : create event
+}
+
+static void _voice_event_cb(void *user_data, rpc_port_voice_event_h args)
+{
+       //TODO : create event
+}
+
+static void _action_event_cb(void *user_data, rpc_port_action_event_h args)
+{
+       //TODO : create event
+}
+
+static void _feedback_event_cb(void *user_data, rpc_port_feedback_event_h args)
+{
+       //TODO : create event
+}
+
 static void _on_connected(rpc_port_proxy_mmifw_h h, void *user_data)
 {
        int r;
 
        LOGI("...");
        _connected = 1;
+
+       focus_cb_h = rpc_port_mmifw_focus_event_cb_create(_focus_event_cb, false, NULL);
+       state_change_cb_h = rpc_port_mmifw_state_change_event_cb_create(_state_change_event_cb, false, NULL);
+       wakeup_cb_h = rpc_port_mmifw_wakeup_event_cb_create(_wakeup_event_cb, false, NULL);
+       key_cb_h = rpc_port_mmifw_key_event_cb_create(_key_event_cb, false, NULL);
+       gesture_cb_h = rpc_port_mmifw_gesture_event_cb_create(_gesture_event_cb, false, NULL);
+       voice_cb_h = rpc_port_mmifw_voice_event_cb_create(_voice_event_cb, false, NULL);
+       action_cb_h = rpc_port_mmifw_action_event_cb_create(_action_event_cb, false, NULL);
+       feedback_cb_h = rpc_port_mmifw_feedback_event_cb_create(_feedback_event_cb, false, NULL);
+
+       if (!focus_cb_h || !state_change_cb_h || !wakeup_cb_h || !key_cb_h
+               || !gesture_cb_h || !voice_cb_h || !action_cb_h || !feedback_cb_h)
+       {
+               LOGE("Failed to create event callbacks !");
+               //TODO: Disconnect by destroying rpc_port_proxy_mmifw_h
+               return;
+       }
+
+       r = rpc_port_proxy_mmifw_invoke_register_cb(h, focus_cb_h, state_change_cb_h, wakeup_cb_h,
+                       key_cb_h, gesture_cb_h, voice_cb_h, action_cb_h, feedback_cb_h);
+       if (r != RPC_PORT_ERROR_NONE)
+       {
+               LOGE("Failed to register event callbacks !\n");
+               //TODO: Disconnect by destroying rpc_port_proxy_mmifw_h
+               return;
+       }
 }
 
 static void _on_disconnected(rpc_port_proxy_mmifw_h h, void *user_data)
@@ -96,6 +172,14 @@ mmi_ipc_init(const char *appid)
 {
        /* initialize handles */
        _rpc_h = NULL;
+       focus_cb_h = NULL;
+       state_change_cb_h = NULL;
+       wakeup_cb_h = NULL;
+       key_cb_h = NULL;
+       gesture_cb_h = NULL;
+       voice_cb_h = NULL;
+       action_cb_h = NULL;
+       feedback_cb_h = NULL;
 
        _uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
        LOGI("uid=%d\n", _uid);
@@ -143,6 +227,23 @@ err:
 void
 mmi_ipc_shutdown(void)
 {
+       rpc_port_mmifw_focus_event_cb_destroy(focus_cb_h);
+       rpc_port_mmifw_state_change_event_cb_destroy(state_change_cb_h);
+       rpc_port_mmifw_wakeup_event_cb_destroy(wakeup_cb_h);
+       rpc_port_mmifw_key_event_cb_destroy(key_cb_h);
+       rpc_port_mmifw_gesture_event_cb_destroy(gesture_cb_h);
+       rpc_port_mmifw_voice_event_cb_destroy(voice_cb_h);
+       rpc_port_mmifw_action_event_cb_destroy(action_cb_h);
+       rpc_port_mmifw_feedback_event_cb_destroy(feedback_cb_h);
+       focus_cb_h = NULL;
+       state_change_cb_h = NULL;
+       wakeup_cb_h = NULL;
+       key_cb_h = NULL;
+       gesture_cb_h = NULL;
+       voice_cb_h = NULL;
+       action_cb_h = NULL;
+       feedback_cb_h = NULL;
+
        rpc_port_proxy_mmifw_destroy(_rpc_h);
        _rpc_h = NULL;
 }