From 1fe2c358e2f4cd9acc7fc8dbd6121f5a9908b80c Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 12 Jul 2021 19:58:51 +0900 Subject: [PATCH] mmifw: implement mmi apis using mmifw-ipc api Change-Id: Id10c43fdefc4ae9da22e344d88174e3a9cd9ed4b Signed-off-by: Sung-Jin Park --- src/mmifw.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++------------ src/mmifw.h | 12 +++++------ 2 files changed, 62 insertions(+), 21 deletions(-) diff --git a/src/mmifw.c b/src/mmifw.c index 229d3aa..dbf8012 100644 --- a/src/mmifw.c +++ b/src/mmifw.c @@ -22,8 +22,7 @@ */ #include "mmifw.h" -#include -#include "interface/mmifw_proxy.h" +#include "mmifw-ipc.h" #define ERR(x) @@ -36,8 +35,6 @@ int MMI_EVENT_VOICE; int MMI_EVENT_ACTION; int MMI_EVENT_FEEDBACK; -rpc_port_proxy_mmifw_h rpc_h; - static int _mmi_init_count = 0; MMIFW_API int @@ -90,11 +87,33 @@ mmi_shutdown(void) MMIFW_API mmi_handle mmi_instance_create(const char *app_id) { - mmi_handle h; + mmi_handle h = NULL; + + h = (mmi_handle)calloc(1, sizeof(mmi_struct)); + + if (!h) + { + ERR("Failed to allocate memory for mmi_handle !\n"); + return NULL; + } + + if (mmi_ipc_init(app_id)) + { + ERR("Failed to init mmifw ipc !\n"); + goto err; + } - (void) app_id; + h->rpc_h = mmi_ipc_get_rpc_h(); + h->app_id = mmi_ipc_get_appid(); + h->stub_appid = mmi_ipc_get_stub_appid(); + h->uid = mmi_ipc_get_uid(); + h->state = mmi_ipc_get_state(); return h; +err: + if (h) + free(h); + return NULL; } MMIFW_API mmi_event_listener * @@ -113,31 +132,51 @@ mmi_event_add_listener(mmi_handle h, int ev_type, mmi_event_handler_cb func, con MMIFW_API mmi_result mmi_request_send_get_focus(mmi_handle h) { - mmi_result res; + mmi_result res = MMI_RESULT_SUCCESS; - (void) h; + if (!h) + { + ERR("Given mmi_handle is invalid !\n"); + return MMI_RESULT_FAIL; + } + rpc_port_proxy_mmifw_invoke_get_focus(h->rpc_h, h->app_id); return res; } MMIFW_API mmi_state mmi_state_get_current_state(mmi_handle h) { - mmi_state state; + mmi_state state = MMI_STATE_NONE; - (void) h; + if (!h) + { + ERR("Given mmi_handle is invalid !\n"); + return state; + } + state = h->state; return state; } MMIFW_API mmi_result mmi_request_send_set_state(mmi_handle h, mmi_state state) { - mmi_result res; + mmi_result res = MMI_RESULT_SUCCESS; - (void) h; - (void) state; + if (!h) + { + ERR("Given mmi_handle is invalid !\n"); + return MMI_RESULT_FAIL; + } + if (state == h->state) + { + ERR("Given state equals to the current state. Ignored !\n"); + return res; + } + + rpc_port_proxy_mmifw_invoke_set_state(h->rpc_h, h->app_id, state); return res; } @@ -159,6 +198,10 @@ mmi_event_remove_all_listeners(mmi_handle h) MMIFW_API void mmi_instance_destroy(mmi_handle h) { - (void) h; + if (!h) + return; + + mmi_ipc_shutdown(); + free(h); } diff --git a/src/mmifw.h b/src/mmifw.h index 7e9631d..429bf2c 100644 --- a/src/mmifw.h +++ b/src/mmifw.h @@ -25,7 +25,6 @@ #define __MMIFW_H__ #include -#include #include #define MMIFW_API __attribute__ ((visibility("default"))) @@ -63,17 +62,16 @@ typedef enum MMI_STATE_TERMINATION } mmi_state; -struct _mmi_struct +typedef struct { mmifw_rpc_h rpc_h; - const char *sender_id; - bool connected; + const char *app_id; + const char *stub_appid; int uid; int state; - const char *stub_appid; -}; +} mmi_struct; -typedef struct _mmi_struct* mmi_handle; +typedef mmi_struct* mmi_handle; #ifdef __cplusplus extern "C" { -- 2.7.4