mmifw & ipc: add MMI_EVENT_CONNECTION event type/data struct and check code 30/264130/1
authorSung-Jin Park <sj76.park@samsung.com>
Fri, 4 Jun 2021 10:30:22 +0000 (19:30 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 13 Sep 2021 12:14:53 +0000 (21:14 +0900)
Change-Id: Id4f06accdf162656c57861255660f4f93cca1ec5
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/mmifw-event-types.h
src/mmifw-ipc.c
src/mmifw.c
src/mmifw.h

index 69b90b5..2b13355 100644 (file)
 
 typedef struct
 {
+   bool connected;
+} mmifw_event_connection;
+
+typedef struct
+{
    int type;//focus in/out
    int timestamp;
    bool focus_in;
index 9fde8ed..b92a549 100644 (file)
@@ -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)
 {
index 4a3957e..a554763 100644 (file)
 
 #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;
 }
 
index 88399ce..98cd10b 100644 (file)
@@ -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;