From: Sung-Jin Park Date: Fri, 4 Jun 2021 10:30:22 +0000 (+0900) Subject: mmifw & ipc: add MMI_EVENT_CONNECTION event type/data struct and check code X-Git-Tag: submit/tizen/20210914.042010~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a7dc1feeb3930bf4b52fa18cd2efdb0ef8a31d9c;p=platform%2Fcore%2Fuifw%2Fmmi-framework.git mmifw & ipc: add MMI_EVENT_CONNECTION event type/data struct and check code Change-Id: Id4f06accdf162656c57861255660f4f93cca1ec5 Signed-off-by: Sung-Jin Park --- diff --git a/src/mmifw-event-types.h b/src/mmifw-event-types.h index 69b90b5..2b13355 100644 --- a/src/mmifw-event-types.h +++ b/src/mmifw-event-types.h @@ -26,6 +26,11 @@ #include +typedef struct +{ + bool connected; +} mmifw_event_connection; + typedef struct { int type;//focus in/out diff --git a/src/mmifw-ipc.c b/src/mmifw-ipc.c index 9fde8ed..b92a549 100644 --- a/src/mmifw-ipc.c +++ b/src/mmifw-ipc.c @@ -549,9 +549,15 @@ err: static void _on_connected(rpc_port_proxy_mmifw_h h, void *user_data) { int r; + mmifw_event_connection *ev = NULL; - LOGI("..."); - _connected = 1; + ev = (mmifw_event_connection *)calloc(1, sizeof(mmifw_event_connection)); + + if (!ev) + { + LOGE("Failed to allocate memory for connection event !\n"); + return; + } 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); @@ -578,12 +584,31 @@ static void _on_connected(rpc_port_proxy_mmifw_h h, void *user_data) //TODO: Disconnect by destroying rpc_port_proxy_mmifw_h return; } + + _connected = 1; + ev->connected = true; + ecore_event_add(MMI_EVENT_CONNECTION, ev, NULL, user_data); + + LOGI("..."); } static void _on_disconnected(rpc_port_proxy_mmifw_h h, void *user_data) { - LOGI("..."); + mmifw_event_connection *ev = NULL; + + ev = (mmifw_event_connection *)calloc(1, sizeof(mmifw_event_connection)); + + if (!ev) + { + LOGE("Failed to allocate memory for connection event !\n"); + return; + } + _connected = 0; + ev->connected = false; + ecore_event_add(MMI_EVENT_CONNECTION, ev, NULL, user_data); + + LOGI("..."); } static void _on_rejected(rpc_port_proxy_mmifw_h h, void *user_data) { diff --git a/src/mmifw.c b/src/mmifw.c index 4a3957e..a554763 100644 --- a/src/mmifw.c +++ b/src/mmifw.c @@ -23,9 +23,11 @@ #include "mmifw.h" #include "mmifw-ipc.h" +#include "mmifw-dbg.h" #define ERR(x) +int MMI_EVENT_CONNECTION; int MMI_EVENT_FOCUS; int MMI_EVENT_STATE_CHANGE; int MMI_EVENT_WAKE_UP; @@ -58,6 +60,7 @@ mmi_init(void) listener_list = NULL; } + MMI_EVENT_CONNECTION = ecore_event_type_new(); MMI_EVENT_FOCUS = ecore_event_type_new(); MMI_EVENT_STATE_CHANGE = ecore_event_type_new(); MMI_EVENT_WAKE_UP = ecore_event_type_new(); @@ -84,6 +87,7 @@ mmi_shutdown(void) _mmi_init_count--; + MMI_EVENT_CONNECTION = -1; MMI_EVENT_FOCUS = -1; MMI_EVENT_STATE_CHANGE = -1; MMI_EVENT_WAKE_UP = -1; @@ -164,7 +168,16 @@ mmi_request_send_get_focus(mmi_handle h) return MMI_RESULT_FAIL; } - rpc_port_proxy_mmifw_invoke_get_focus(h->rpc_h); + if (mmi_ipc_is_connected()) + rpc_port_proxy_mmifw_invoke_get_focus(h->rpc_h); + else + { + ERR("Not connected yet !\n"); + res = MMI_RESULT_FAIL; + } + + LOGI("Get_focus request has been sent !\n"); + return res; } diff --git a/src/mmifw.h b/src/mmifw.h index 88399ce..98cd10b 100644 --- a/src/mmifw.h +++ b/src/mmifw.h @@ -29,6 +29,7 @@ #define MMIFW_API __attribute__ ((visibility("default"))) +MMIFW_API extern int MMI_EVENT_CONNECTION; MMIFW_API extern int MMI_EVENT_FOCUS; MMIFW_API extern int MMI_EVENT_STATE_CHANGE; MMIFW_API extern int MMI_EVENT_WAKE_UP;