mmifw: implement mmi apis using mmifw-ipc api 19/264119/1
authorSung-Jin Park <sj76.park@samsung.com>
Mon, 12 Jul 2021 10:58:51 +0000 (19:58 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 13 Sep 2021 12:14:29 +0000 (21:14 +0900)
Change-Id: Id10c43fdefc4ae9da22e344d88174e3a9cd9ed4b
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/mmifw.c
src/mmifw.h

index 229d3aa..dbf8012 100644 (file)
@@ -22,8 +22,7 @@
 */
 
 #include "mmifw.h"
-#include  <rpc-port/rpc-port.h>
-#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);
 }
 
index 7e9631d..429bf2c 100644 (file)
@@ -25,7 +25,6 @@
 #define __MMIFW_H__
 
 #include <Ecore.h>
-#include <rpc-port/rpc-port.h>
 #include <mmifw-event-types.h>
 
 #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" {