Rename mmifw to mmi because this module is the library for application 54/277154/1
authorsungwook79.park <sungwook79.park@samsung.com>
Thu, 16 Jun 2022 04:38:24 +0000 (13:38 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Fri, 1 Jul 2022 06:07:32 +0000 (15:07 +0900)
Change-Id: I7d44a0818a07fa26ea6b8ec440953c254f9f9267
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
31 files changed:
README.md
meson.build
packaging/mmi.manifest [new file with mode: 0644]
packaging/mmi.spec [new file with mode: 0644]
packaging/mmifw.manifest [deleted file]
packaging/mmifw.spec [deleted file]
src/meson.build
src/mmi-dbg.h [new file with mode: 0644]
src/mmi-event-types.h [new file with mode: 0644]
src/mmi-ipc.c [new file with mode: 0644]
src/mmi-ipc.h [new file with mode: 0644]
src/mmi.c [new file with mode: 0644]
src/mmi.h [new file with mode: 0644]
src/mmifw-dbg.h [deleted file]
src/mmifw-event-types.h [deleted file]
src/mmifw-ipc.c [deleted file]
src/mmifw-ipc.h [deleted file]
src/mmifw.c [deleted file]
src/mmifw.h [deleted file]
tests/meson.build
tests/mmi-ipc-test.cpp [new file with mode: 0644]
tests/mmi-main-test.cpp [new file with mode: 0644]
tests/mmi-tests.cpp [new file with mode: 0644]
tests/mmi-tests.h [new file with mode: 0644]
tests/mmifw-ipc-test.cpp [deleted file]
tests/mmifw-main-test.cpp [deleted file]
tests/mmifw-tests.cpp [deleted file]
tests/mmifw-tests.h [deleted file]
tests/wait-helper.cpp
tidl/mmi.tidl [new file with mode: 0644]
tidl/mmifw.tidl [deleted file]

index 65866e93067f0d3f8443cb762c146bce6178c33e..4579c8a3132b09cb57a335a80ac3343e55523370 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-# MMI(Multi-modal Interaction) Framework  
-  
+# MMI(Multi-modal Interaction) Framework Library
+
 [Source Tree]  
 .  
 ├── CODEOWNERS  
@@ -7,20 +7,20 @@
 ├── meson.build  
 ├── meson_options.txt  
 ├── packaging  
-│   ├── mmifw.manifest  
-│   └── mmifw.spec  
-├── README.md  
-├── src  
-│   ├── interface  
-│   │   ├── mmifw_proxy.c  
-│   │   └── mmifw_proxy.h  
-│   ├── meson.build  
-│   ├── mmifw.c  
-│   └── mmifw.h  
-├── tests  
-│   ├── meson.build  
-│   ├── mmifw-tests.cpp  
-│   └── mmifw-tests.h  
-└── tidl  
-    └── mmifw.tidl  
+│   ├── mmi.manifest
+│   └── mmi.spec
+├── README.md
+├── src
+│   ├── interface
+│   │   ├── mmi_proxy.c
+│   │   └── mmi_proxy.h
+│   ├── meson.build
+│   ├── mmi.c
+│   └── mmi.h
+├── tests
+│   ├── meson.build
+│   ├── mmi-tests.cpp
+│   └── mmi-tests.h
+└── tidl
+    └── mmi.tidl
   
index 3d9cf32b5120ae10a761d4b8398dac57fe7384f1..4d9bb63a7f5acfafe2803c23ceb121b67c347585 100644 (file)
@@ -1,15 +1,15 @@
 project(
-       'mmifw',
+       'mmi',
        ['c', 'cpp'],
        version : '0.0.1',
        license : 'MIT',
        default_options : ['b_pie=true']
 )
 
-mmifw_version = meson.project_version().split('.')
-mmifw_prefix = get_option('prefix')
-mmifw_prefix_bindir = join_paths(mmifw_prefix, get_option('bindir'))
-mmifw_prefix_libdir = join_paths(mmifw_prefix, get_option('libdir'))
+mmi_version = meson.project_version().split('.')
+mmi_prefix = get_option('prefix')
+mmi_prefix_bindir = join_paths(mmi_prefix, get_option('bindir'))
+mmi_prefix_libdir = join_paths(mmi_prefix, get_option('libdir'))
 
 pkgconfig = import('pkgconfig')
 
diff --git a/packaging/mmi.manifest b/packaging/mmi.manifest
new file mode 100644 (file)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
diff --git a/packaging/mmi.spec b/packaging/mmi.spec
new file mode 100644 (file)
index 0000000..9d2b489
--- /dev/null
@@ -0,0 +1,86 @@
+%define USE_GCOV 0
+
+Name:          mmi
+Version:       0.0.1
+Release:       0
+Summary:       Multi-modal Interaction Framework Library
+License:       MIT
+URL:           http://www.tizen.org
+Source:                %{name}-%{version}.tar.xz
+Source1004:    %{name}.manifest
+
+BuildRequires: meson
+BuildRequires: tidl
+BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(rpc-port)
+BuildRequires: pkgconfig(ecore)
+
+#Build dependencies for tests
+BuildRequires: pkgconfig(gmock)
+
+%description
+MMI(Multi-modal Interaction) Framework Library
+
+%package devel
+Summary:       Development package for MMI Framework Library
+Group:         Development/Libraries
+Requires:      %{name} = %{version}-%{release}
+Requires:      pkgconfig(rpc-port)
+%description devel
+Development package for MMI Framework Library
+
+%package tests
+Summary:       Testcases for MMI Framework Library
+Group:         System/Libraries
+%description tests
+Testcases for testing MMI Framework APIs
+
+%prep
+%setup -q
+cp %{SOURCE1004} .
+
+#generate mmi-proxy using TIDL Compiler
+tidlc -p -l C -i tidl/mmi.tidl -o mmi_proxy
+mv mmi_proxy.* src
+
+%build
+%if "%{USE_GCOV}" == "1"
+CFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
+CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
+LDFLAGS+=" -lgcov"
+%endif
+meson setup --prefix=/usr \
+       --bindir %{_bindir} \
+       --libdir %{_libdir} \
+       builddir
+ninja -C builddir all
+
+%install
+DESTDIR=%{buildroot} ninja -C builddir install
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license COPYING
+%{_libdir}/*.so.*
+
+%files devel
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license COPYING
+%{_includedir}/mmi*.h
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/*
+
+%files tests
+%defattr(-,root,root,-)
+%license COPYING
+%{_bindir}/mmi-tests
+
diff --git a/packaging/mmifw.manifest b/packaging/mmifw.manifest
deleted file mode 100644 (file)
index 75b0fa5..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-    <request>
-        <domain name="_"/>
-    </request>
-</manifest>
diff --git a/packaging/mmifw.spec b/packaging/mmifw.spec
deleted file mode 100644 (file)
index 622e2a5..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-%define USE_GCOV 0
-
-Name:          mmifw
-Version:       0.0.1
-Release:       0
-Summary:       Multi-modal Interaction Framework Library
-License:       MIT
-URL:           http://www.tizen.org
-Source:                %{name}-%{version}.tar.xz
-Source1004:    %{name}.manifest
-
-BuildRequires: meson
-BuildRequires: tidl
-BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(bundle)
-BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(rpc-port)
-BuildRequires: pkgconfig(ecore)
-
-#Build dependencies for tests
-BuildRequires: pkgconfig(gmock)
-
-%description
-MMI(Multi-modal Interaction) Framework Library
-
-%package devel
-Summary:       Development package for MMI Framework
-Group:         Development/Libraries
-Requires:      %{name} = %{version}-%{release}
-Requires:      pkgconfig(rpc-port)
-%description devel
-Development package for MMI Framework
-
-%package tests
-Summary:       Testcases for MMI Framework
-Group:         System/Libraries
-%description tests
-Testcases for testing MMI Framework APIs
-
-%prep
-%setup -q
-cp %{SOURCE1004} .
-
-#generate mmi-proxy using TIDL Compiler
-tidlc -p -l C -i tidl/mmifw.tidl -o mmifw_proxy
-mv mmifw_proxy.* src
-
-%build
-%if "%{USE_GCOV}" == "1"
-CFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
-CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
-LDFLAGS+=" -lgcov"
-%endif
-meson setup --prefix=/usr \
-       --bindir %{_bindir} \
-       --libdir %{_libdir} \
-       builddir
-ninja -C builddir all
-
-%install
-DESTDIR=%{buildroot} ninja -C builddir install
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%files
-%manifest %{name}.manifest
-%defattr(-,root,root,-)
-%license COPYING
-%{_libdir}/*.so.*
-
-%files devel
-%manifest %{name}.manifest
-%defattr(-,root,root,-)
-%license COPYING
-%{_includedir}/mmifw*.h
-%{_libdir}/*.so
-%{_libdir}/pkgconfig/*
-
-%files tests
-%defattr(-,root,root,-)
-%license COPYING
-%{_bindir}/mmifw-tests
-
index 08246e2f6ced3226d7430af9de735060402b1c37..7a5eb019c82b9bab2f979952611110b2314a3f83 100644 (file)
@@ -1,16 +1,16 @@
-mmifw_srcs = [
-       'mmifw.h',
-       'mmifw.c',
-       'mmifw-ipc.h',
-       'mmifw-ipc.c',
-       'mmifw-dbg.h',
-       'mmifw_proxy.h',
-       'mmifw_proxy.c'
+mmi_srcs = [
+       'mmi.h',
+       'mmi.c',
+       'mmi-ipc.h',
+       'mmi-ipc.c',
+       'mmi-dbg.h',
+       'mmi_proxy.h',
+       'mmi_proxy.c'
        ]
 
 install_headers(
-       'mmifw.h',
-       'mmifw-event-types.h'
+       'mmi.h',
+       'mmi-event-types.h'
        )
 
 glib_dep = dependency('glib-2.0', method : 'pkg-config')
@@ -21,7 +21,7 @@ rpc_port_dep = dependency('rpc-port', method : 'pkg-config')
 libtzplatform_config_dep = dependency('libtzplatform-config')
 ecore_dep = dependency('ecore', method : 'pkg-config')
 
-mmifw_deps = [
+mmi_deps = [
        ecore_dep,
        glib_dep,
        gio_dep,
@@ -30,29 +30,29 @@ mmifw_deps = [
        rpc_port_dep,
        libtzplatform_config_dep]
 
-mmifw_include_dirs = include_directories(
+mmi_include_dirs = include_directories(
        '.'
        )
 
-mmifw_lib = shared_library(
-       'mmifw',
-       mmifw_srcs,
-       dependencies : [mmifw_deps],
-       include_directories : [mmifw_include_dirs],
+mmi_lib = shared_library(
+       'mmi',
+       mmi_srcs,
+       dependencies : [mmi_deps],
+       include_directories : [mmi_include_dirs],
        version : meson.project_version(),
        install : true
        )
 
 pkgconfig.generate(
-       filebase : 'mmifw',
-       name : 'mmifw',
+       filebase : 'mmi',
+       name : 'mmi',
        description : 'Multi-modal Interaction Framework Library',
        version : meson.project_version(),
-       libraries : mmifw_lib
+       libraries : mmi_lib
        )
 
-mmifw_declared_dep = declare_dependency(
-       link_with : mmifw_lib,
-       dependencies : [mmifw_deps],
-       include_directories : [mmifw_include_dirs]      
+mmi_declared_dep = declare_dependency(
+       link_with : mmi_lib,
+       dependencies : [mmi_deps],
+       include_directories : [mmi_include_dirs]
        )
diff --git a/src/mmi-dbg.h b/src/mmi-dbg.h
new file mode 100644 (file)
index 0000000..6be604d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_DBG_H__
+#define __MMI_DBG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MMI"
+
+#ifndef _E
+#define _E LOGE
+#endif
+
+#ifndef _D
+#define _D LOGD
+#endif
+
+#ifndef _I
+#define _I LOGI
+#endif
+
+#ifndef _W
+#define _W LOGW
+#endif
+
+#endif // __MMI_DBG_H__ 
diff --git a/src/mmi-event-types.h b/src/mmi-event-types.h
new file mode 100644 (file)
index 0000000..9f3b469
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_EVENT_TYPES_H__
+#define __MMI_EVENT_TYPES_H__
+
+#include <stdbool.h>
+
+typedef struct
+{
+   bool connected;
+} mmi_event_connection;
+
+typedef struct
+{
+   int type;//focus in/out
+   int timestamp;
+   bool focus_in;
+} mmi_event_focus;
+
+typedef struct {
+   int type;//state change
+   int timestamp;
+   int state;
+   int old_state;
+} mmi_event_state_change;
+
+typedef struct {
+   int type;
+   int timestamp;
+   char *source;//event source information like voice, gesture, key, vision, and so on
+} mmi_event_wakeup;
+
+typedef struct
+{
+   int type;//up, down, left, right, select, back, ...
+   int timestamp;
+   int keycode;
+   bool key_down;
+   char *keyname;
+   char *source;//event source information
+} mmi_event_key;
+
+typedef struct {
+   int type;//swipe up, down, left, right, yes, ...
+   int timestamp;
+   char *source;//event source information
+} mmi_event_gesture;
+
+typedef struct {
+   int type;//voice up, down, left, right, select, back, ...
+   int timestamp;
+   char *source;//event source information
+} mmi_event_voice;
+
+typedef struct {
+   int type;//action play/pause/resume/stop/execute/launch/revoke/volume ...
+   int timestamp;
+   char *cmd;
+   char **args;
+   int nargs;
+   char *source;//event source information
+} mmi_event_action;
+
+typedef struct
+{
+   int type;//feedback positive, feedback negative, feedback comment
+   int timestamp;
+   char *feedback;
+   char *comment;
+} mmi_event_feedback;
+
+#endif //__MMI_EVENT_TYPES_H__
diff --git a/src/mmi-ipc.c b/src/mmi-ipc.c
new file mode 100644 (file)
index 0000000..cdf5647
--- /dev/null
@@ -0,0 +1,798 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmi.h"
+#include "mmi-ipc.h"
+#include "mmi-dbg.h"
+
+#include <tzplatform_config.h>
+#include <unistd.h>
+#include <rpc-port.h>
+#include <rpc-port-internal.h>
+
+static rpc_port_proxy_mmi_h _rpc_h;
+static const char* _appid = "";
+static const char* _stub_appid = "mmi-manager";
+static uid_t _uid = -1;
+static int _connected = 0;
+static mmi_state _state = MMI_STATE_NONE;
+
+rpc_port_proxy_mmi_focus_event_cb_h focus_cb_h;
+rpc_port_proxy_mmi_state_change_event_cb_h state_change_cb_h;
+rpc_port_proxy_mmi_wakeup_event_cb_h wakeup_cb_h;
+rpc_port_proxy_mmi_key_event_cb_h key_cb_h;
+rpc_port_proxy_mmi_gesture_event_cb_h gesture_cb_h;
+rpc_port_proxy_mmi_voice_event_cb_h voice_cb_h;
+rpc_port_proxy_mmi_action_event_cb_h action_cb_h;
+rpc_port_proxy_mmi_feedback_event_cb_h feedback_cb_h;
+
+rpc_port_proxy_mmi_h
+mmi_ipc_get_rpc_h(void)
+{
+       return _rpc_h;
+}
+
+mmi_state
+mmi_ipc_get_state(void)
+{
+       return _state;
+}
+
+int
+mmi_ipc_get_uid(void)
+{
+       return _uid;
+}
+
+bool
+mmi_ipc_is_connected(void)
+{
+       return _connected ? true : false;
+}
+
+const char *
+mmi_ipc_get_appid(void)
+{
+       return _appid;
+}
+
+const char *
+mmi_ipc_get_stub_appid(void)
+{
+       return _stub_appid;
+}
+
+static void _focus_event_cb(void *user_data, rpc_port_proxy_focus_event_h args)
+{
+       int r;
+       mmi_event_focus *ev = NULL;
+
+       ev = (mmi_event_focus *)calloc(1, sizeof(mmi_event_focus));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory focus event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_focus_event_get_type(args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_focus_event_get_timestamp(args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_focus_event_get_focus_in(args, &ev->focus_in);
+       if (r)
+       {
+               LOGE("Failed to get focus_in (error:%d)\n", r);
+               goto err;
+       }
+
+       ecore_event_add(MMI_EVENT_FOCUS, ev, NULL, user_data);
+       return;
+err:
+       if (ev)
+               free(ev);
+}
+
+static void _state_change_event_cb(void *user_data, rpc_port_proxy_state_change_event_h args)
+{
+       int r;
+       mmi_event_state_change *ev = NULL;
+
+       ev = (mmi_event_state_change *)calloc(1, sizeof(mmi_event_state_change));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory state_change event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_state_change_event_get_type(args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_state_change_event_get_timestamp(args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_state_change_event_get_state(args, &ev->state);
+       if (r)
+       {
+               LOGE("Failed to get state (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_state_change_event_get_old_state(args, &ev->old_state);
+       if (r)
+       {
+               LOGE("Failed to get old_state (error:%d)\n", r);
+               goto err;
+       }
+
+       _state = ev->state;
+       ecore_event_add(MMI_EVENT_STATE_CHANGE, ev, NULL, user_data);
+       return;
+err:
+       if (ev)
+               free(ev);
+}
+
+static void
+_wakeup_event_free(void *data, void *ev)
+{
+       mmi_event_wakeup *e = (mmi_event_wakeup *)ev;
+
+       if (e->source)
+               free(e->source);
+       free(e);
+}
+
+static void _wakeup_event_cb(void *user_data, rpc_port_proxy_wakeup_event_h args)
+{
+       int r;
+       mmi_event_wakeup *ev = NULL;
+
+       ev = (mmi_event_wakeup *)calloc(1, sizeof(mmi_event_wakeup));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory wakeup event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_wakeup_event_get_type(args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_wakeup_event_get_timestamp(args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_wakeup_event_get_source(args, &ev->source);
+       if (r)
+       {
+               LOGE("Failed to get source (error:%d)\n", r);
+               goto err;
+       }
+
+       ecore_event_add(MMI_EVENT_WAKE_UP, ev, _wakeup_event_free, user_data);
+       return;
+err:
+       if (ev)
+               _wakeup_event_free(NULL, ev);
+}
+
+static void
+_key_event_free(void *data, void *ev)
+{
+       mmi_event_key *e = (mmi_event_key *)ev;
+
+       if (e->keyname)
+               free(e->keyname);
+       if (e->source)
+               free(e->source);
+       free(e);
+}
+
+static void _key_event_cb(void *user_data, rpc_port_proxy_key_event_h args)
+{
+       int r;
+       mmi_event_key *ev = NULL;
+
+       ev = (mmi_event_key *)calloc(1, sizeof(mmi_event_key));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory key event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_key_event_get_type(args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_key_event_get_timestamp(args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_key_event_get_keycode(args, &ev->keycode);
+       if (r)
+       {
+               LOGE("Failed to get keycode (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_key_event_get_key_down(args, &ev->key_down);
+       if (r)
+       {
+               LOGE("Failed to get key_down (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_key_event_get_keyname(args, &ev->keyname);
+       if (r)
+       {
+               LOGE("Failed to get keyname (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_key_event_get_source(args, &ev->source);
+       if (r)
+       {
+               LOGE("Failed to get source (error:%d)\n", r);
+               goto err;
+       }
+
+       ecore_event_add(MMI_EVENT_KEY, ev, _key_event_free, user_data);
+       return;
+err:
+       if (ev)
+               _key_event_free(NULL, ev);
+}
+
+static void
+_gesture_event_free(void *data, void *ev)
+{
+        mmi_event_gesture *e = (mmi_event_gesture *)ev;
+
+        if (e->source)
+                free(e->source);
+        free(e);
+}
+
+static void _gesture_event_cb(void *user_data, rpc_port_proxy_gesture_event_h args)
+{
+       int r;
+       mmi_event_gesture *ev = NULL;
+
+       ev = (mmi_event_gesture *)calloc(1, sizeof(mmi_event_gesture));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory gesture event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_gesture_event_get_type(args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_gesture_event_get_timestamp(args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_gesture_event_get_source(args, &ev->source);
+       if (r)
+       {
+               LOGE("Failed to get source (error:%d)\n", r);
+               goto err;
+       }
+
+       ecore_event_add(MMI_EVENT_GESTURE, ev, _gesture_event_free, user_data);
+       return;
+err:
+       if (ev)
+               _gesture_event_free(NULL, ev);
+}
+
+static void
+_voice_event_free(void *data, void *ev)
+{
+        mmi_event_voice *e = (mmi_event_voice *)ev;
+
+        if (e->source)
+                free(e->source);
+        free(e);
+}
+
+static void _voice_event_cb(void *user_data, rpc_port_proxy_voice_event_h args)
+{
+       int r;
+       mmi_event_voice *ev = NULL;
+
+       ev = (mmi_event_voice *)calloc(1, sizeof(mmi_event_voice));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory voice event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_voice_event_get_type(args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_voice_event_get_timestamp(args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_voice_event_get_source(args, &ev->source);
+       if (r)
+       {
+               LOGE("Failed to get source (error:%d)\n", r);
+               goto err;
+       }
+
+       ecore_event_add(MMI_EVENT_VOICE, ev, _voice_event_free, user_data);
+       return;
+err:
+       if (ev)
+               _voice_event_free(NULL, ev);
+}
+
+static void
+_action_event_free(void *data, void *ev)
+{
+       mmi_event_action *e = (mmi_event_action *)ev;
+
+       if (e->cmd)
+               free(e->cmd);
+       if (e->source)
+               free(e->source);
+       if (e->args)
+       {
+               for(int n = 0; n < e->nargs; ++n)
+                       if (e->args[n])
+                               free(e->args[n]);
+
+       }
+       free(e);
+}
+
+static void _action_event_cb(void *user_data, rpc_port_proxy_action_event_h ev_args)
+{
+       int r;
+       int args_size;
+       mmi_event_action *ev = NULL;
+       rpc_port_proxy_array_string_h array_string_h = NULL;
+
+       ev = (mmi_event_action *)calloc(1, sizeof(mmi_event_action));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory action event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_action_event_get_type(ev_args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_action_event_get_timestamp(ev_args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_action_event_get_cmd(ev_args, &ev->cmd);
+       if (r)
+       {
+               LOGE("Failed to get cmd (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_action_event_get_nargs(ev_args, &ev->nargs);
+       if (r)
+       {
+               LOGE("Failed to get nargs (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_action_event_get_args(ev_args, &array_string_h);
+       if (r)
+       {
+               LOGE("Failed to get array_string_h ! (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_array_string_get(array_string_h, &ev->args, &args_size);
+       if (r)
+       {
+               LOGE("Failed to get array string (error:%d)\n", r);
+               goto err;
+       }
+
+       if (args_size != ev->nargs)
+       {
+               LOGE("Invalid args_size in event (args_size=%d, nargs=%d) !\n", args_size, ev->nargs);
+               goto err;
+       }
+
+       r = rpc_port_proxy_action_event_get_source(ev_args, &ev->source);
+       if (r)
+       {
+               LOGE("Failed to get source (error:%d)\n", r);
+               goto err;
+       }
+
+       ecore_event_add(MMI_EVENT_ACTION, ev, _action_event_free, user_data);
+       return;
+err:
+       if (ev)
+               _action_event_free(NULL, ev);
+       if (array_string_h)
+               rpc_port_proxy_array_string_destroy(array_string_h);
+}
+
+static void
+_feedback_event_free(void *data, void *ev)
+{
+       mmi_event_feedback *e = (mmi_event_feedback *)ev;
+
+       if (e->feedback)
+               free(e->feedback);
+       if (e->comment)
+               free(e->comment);
+       free(e);
+}
+
+static void _feedback_event_cb(void *user_data, rpc_port_proxy_feedback_event_h args)
+{
+       int r;
+       mmi_event_feedback *ev = NULL;
+
+       ev = (mmi_event_feedback *)calloc(1, sizeof(mmi_event_feedback));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory feedback event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_feedback_event_get_type(args, &ev->type);
+       if (r)
+       {
+               LOGE("Failed to get type (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_feedback_event_get_timestamp(args, &ev->timestamp);
+       if (r)
+       {
+               LOGE("Failed to get timestamp (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_feedback_event_get_feedback(args, &ev->feedback);
+       if (r)
+       {
+               LOGE("Failed to get feedback (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_feedback_event_get_comment(args, &ev->comment);
+       if (r)
+       {
+               LOGE("Failed to get comment (error:%d)\n", r);
+               goto err;
+       }
+
+       ecore_event_add(MMI_EVENT_FEEDBACK, ev, _feedback_event_free, user_data);
+       return;
+err:
+       if (ev)
+               _feedback_event_free(NULL, ev);
+}
+
+static void _on_connected(rpc_port_proxy_mmi_h h, void *user_data)
+{
+       int r;
+       mmi_event_connection *ev = NULL;
+
+       ev = (mmi_event_connection *)calloc(1, sizeof(mmi_event_connection));
+
+       if (!ev)
+       {
+               LOGE("Failed to allocate memory for connection event !\n");
+               return;
+       }
+
+       r = rpc_port_proxy_mmi_focus_event_cb_create(&focus_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create focus callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_focus_event_cb_set_callback(focus_cb_h, _focus_event_cb, NULL);
+       rpc_port_proxy_mmi_focus_event_cb_set_once(focus_cb_h, false);
+
+       r = rpc_port_proxy_mmi_state_change_event_cb_create(&state_change_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create state callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_state_change_event_cb_set_callback(state_change_cb_h, _state_change_event_cb, NULL);
+       rpc_port_proxy_mmi_state_change_event_cb_set_once(state_change_cb_h, false);
+
+       r = rpc_port_proxy_mmi_wakeup_event_cb_create(&wakeup_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_wakeup_event_cb_set_callback(wakeup_cb_h, _wakeup_event_cb, NULL);
+       rpc_port_proxy_mmi_wakeup_event_cb_set_once(wakeup_cb_h, false);
+
+       r = rpc_port_proxy_mmi_key_event_cb_create(&key_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_key_event_cb_set_callback(key_cb_h, _key_event_cb, NULL);
+       rpc_port_proxy_mmi_key_event_cb_set_once(key_cb_h, false);
+
+       r = rpc_port_proxy_mmi_gesture_event_cb_create(&gesture_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_gesture_event_cb_set_callback(gesture_cb_h, _gesture_event_cb, NULL);
+       rpc_port_proxy_mmi_gesture_event_cb_set_once(gesture_cb_h, false);
+
+       r = rpc_port_proxy_mmi_voice_event_cb_create(&voice_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_voice_event_cb_set_callback(voice_cb_h, _voice_event_cb, NULL);
+       rpc_port_proxy_mmi_voice_event_cb_set_once(voice_cb_h, false);
+
+       r = rpc_port_proxy_mmi_action_event_cb_create(&action_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_action_event_cb_set_callback(action_cb_h, _action_event_cb, NULL);
+       rpc_port_proxy_mmi_action_event_cb_set_once(action_cb_h, false);
+
+       r = rpc_port_proxy_mmi_feedback_event_cb_create(&feedback_cb_h);
+       if (r)
+       {
+               LOGE("Failed to create callback handle (error:%d)\n", r);
+               goto err;
+       }
+       rpc_port_proxy_mmi_feedback_event_cb_set_callback(feedback_cb_h, _feedback_event_cb, NULL);
+       rpc_port_proxy_mmi_feedback_event_cb_set_once(feedback_cb_h, false);
+
+       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_mmi_h
+               goto err;
+       }
+
+       r = rpc_port_proxy_mmi_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_mmi_h
+               goto err;
+       }
+
+       _connected = 1;
+       ev->connected = true;
+       ecore_event_add(MMI_EVENT_CONNECTION, ev, NULL, user_data);
+
+       LOGI("...");
+       return;
+err:
+       if (ev)
+               free(ev);
+       if (focus_cb_h)
+               rpc_port_proxy_mmi_focus_event_cb_destroy(focus_cb_h);
+       if (state_change_cb_h)
+               rpc_port_proxy_mmi_state_change_event_cb_destroy(state_change_cb_h);
+       if (wakeup_cb_h)
+               rpc_port_proxy_mmi_wakeup_event_cb_destroy(wakeup_cb_h);
+       if (key_cb_h)
+               rpc_port_proxy_mmi_key_event_cb_destroy(key_cb_h);
+       if (gesture_cb_h)
+               rpc_port_proxy_mmi_gesture_event_cb_destroy(gesture_cb_h);
+       if (voice_cb_h)
+               rpc_port_proxy_mmi_voice_event_cb_destroy(voice_cb_h);
+       if (action_cb_h)
+               rpc_port_proxy_mmi_action_event_cb_destroy(action_cb_h);
+       if (feedback_cb_h)
+               rpc_port_proxy_mmi_feedback_event_cb_destroy(feedback_cb_h);
+}
+
+static void _on_disconnected(rpc_port_proxy_mmi_h h, void *user_data)
+{
+       mmi_event_connection *ev = NULL;
+
+       ev = (mmi_event_connection *)calloc(1, sizeof(mmi_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_mmi_h h, void *user_data)
+{
+       LOGI("...");
+       _connected = 0;
+}
+
+int
+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);
+
+       rpc_port_set_target_uid(_uid);
+
+       int r = rpc_port_register_proc_info(appid, NULL);
+       if (r != RPC_PORT_ERROR_NONE)
+       {
+               LOGE("Failed to register proc info ! (error:%d)\n", r);
+               goto err;
+       }
+
+       _appid = appid;
+
+       rpc_port_proxy_mmi_callback_s callback = {
+               .connected = _on_connected,
+               .disconnected = _on_disconnected,
+               .rejected = _on_rejected
+       };
+
+       r = rpc_port_proxy_mmi_create(_stub_appid, &callback, NULL, &_rpc_h);
+       if (r != RPC_PORT_ERROR_NONE)
+       {
+               LOGE("Failed to create mmi proxy handle ! (error:%d)\n", r);
+               goto err;
+       }
+
+       r = rpc_port_proxy_mmi_connect(_rpc_h);
+       if (r != RPC_PORT_ERROR_NONE)
+       {
+               LOGE("Failed to connect to %s ! (error:%d)\n", _stub_appid, r);
+               goto err;
+       }
+
+       return 0;
+err:
+       if (_rpc_h)
+               rpc_port_proxy_destroy(_rpc_h);
+
+       rpc_port_deregister_proc_info();
+
+       _rpc_h = NULL;
+       _uid = -1;
+       return -1;
+}
+
+void
+mmi_ipc_shutdown(void)
+{
+       if (!_rpc_h)
+               return;
+
+       rpc_port_proxy_mmi_invoke_deregister_cb(_rpc_h);
+
+       rpc_port_proxy_mmi_destroy(_rpc_h);
+       rpc_port_deregister_proc_info();
+       _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;
+
+       _appid = "";
+       _uid = -1;
+       _state = MMI_STATE_NONE;
+       _connected = 0;
+}
diff --git a/src/mmi-ipc.h b/src/mmi-ipc.h
new file mode 100644 (file)
index 0000000..95d2539
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_IPC_H__
+#define __MMI_IPC_H__
+
+#include "mmi_proxy.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mmi_ipc_init(const char *appid);
+void mmi_ipc_shutdown(void);
+
+rpc_port_proxy_mmi_h mmi_ipc_get_rpc_h(void);
+mmi_state mmi_ipc_get_state(void);
+int mmi_ipc_get_uid(void);
+bool mmi_ipc_is_connected(void);
+const char *mmi_ipc_get_appid(void);
+const char *mmi_ipc_get_stub_appid(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_IPC_H__
diff --git a/src/mmi.c b/src/mmi.c
new file mode 100644 (file)
index 0000000..bf71ebc
--- /dev/null
+++ b/src/mmi.c
@@ -0,0 +1,251 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmi.h"
+#include "mmi-ipc.h"
+#include "mmi-dbg.h"
+
+#define ERR(x)
+
+int MMI_EVENT_CONNECTION;
+int MMI_EVENT_FOCUS;
+int MMI_EVENT_STATE_CHANGE;
+int MMI_EVENT_WAKE_UP;
+int MMI_EVENT_KEY;
+int MMI_EVENT_GESTURE;
+int MMI_EVENT_VOICE;
+int MMI_EVENT_ACTION;
+int MMI_EVENT_FEEDBACK;
+
+static int _mmi_init_count = 0;
+Eina_List *listener_list = NULL;
+
+MMI_API int
+mmi_init(void)
+{
+       if (++_mmi_init_count != 1)
+               return _mmi_init_count;
+
+       ecore_init();
+
+       Eina_List *l = NULL;
+       mmi_event_listener *listener = NULL;
+
+       if (listener_list)
+       {
+               EINA_LIST_FOREACH(listener_list, l, listener)
+                       ecore_event_handler_del(listener);
+
+               listener_list = eina_list_free(listener_list);
+               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();
+       MMI_EVENT_KEY = ecore_event_type_new();
+       MMI_EVENT_GESTURE = ecore_event_type_new();
+       MMI_EVENT_VOICE = ecore_event_type_new();
+       MMI_EVENT_ACTION = ecore_event_type_new();
+       MMI_EVENT_FEEDBACK = ecore_event_type_new();
+
+       return _mmi_init_count;
+}
+
+MMI_API int
+mmi_shutdown(void)
+{
+       if (_mmi_init_count <= 0)
+       {
+               ERR("Init count must be greater than 0.");
+               return 0;
+       }
+
+       _mmi_init_count--;
+
+       MMI_EVENT_CONNECTION = -1;
+       MMI_EVENT_FOCUS = -1;
+       MMI_EVENT_STATE_CHANGE = -1;
+       MMI_EVENT_WAKE_UP = -1;
+       MMI_EVENT_KEY = -1;
+       MMI_EVENT_GESTURE = -1;
+       MMI_EVENT_VOICE = -1;
+       MMI_EVENT_ACTION = -1;
+       MMI_EVENT_FEEDBACK = -1;
+
+       Eina_List *l = NULL;
+       mmi_event_listener *listener = NULL;
+
+       if (listener_list)
+       {
+               EINA_LIST_FOREACH(listener_list, l, listener)
+                       ecore_event_handler_del(listener);
+
+               listener_list = eina_list_free(listener_list);
+               listener_list = NULL;
+       }
+
+       ecore_main_loop_quit();
+       return _mmi_init_count;
+}
+
+MMI_API mmi_handle
+mmi_instance_create(const char *app_id)
+{
+       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 mmi ipc !\n");
+               goto err;
+       }
+
+       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;
+}
+
+MMI_API mmi_event_listener *
+mmi_event_add_listener(mmi_handle h, int ev_type, mmi_event_handler_cb func, const void *data)
+{
+       mmi_event_listener *listener;
+
+       (void) h;
+
+       listener = ecore_event_handler_add(ev_type, func, data);
+       listener_list = eina_list_append(listener_list, listener);
+       return listener;
+}
+
+MMI_API mmi_result
+mmi_request_send_get_focus(mmi_handle h)
+{
+       mmi_result res = MMI_RESULT_SUCCESS;
+
+       if (!h)
+       {
+               ERR("Given mmi_handle is invalid !\n");
+               return MMI_RESULT_FAIL;
+       }
+
+       if (mmi_ipc_is_connected())
+               rpc_port_proxy_mmi_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;
+}
+
+MMI_API mmi_state
+mmi_state_get_current_state(mmi_handle h)
+{
+       if (!h)
+       {
+               ERR("Given mmi_handle is invalid !\n");
+               return MMI_STATE_NONE;
+       }
+
+       h->state = mmi_ipc_get_state();
+       return h->state;
+}
+
+MMI_API mmi_result
+mmi_request_send_set_state(mmi_handle h, mmi_state state)
+{
+       mmi_result res = MMI_RESULT_SUCCESS;
+
+       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_mmi_invoke_set_state(h->rpc_h, state);
+       return res;
+}
+
+MMI_API void
+mmi_event_remove_listener(mmi_handle h, mmi_event_listener *listener)
+{
+       (void) h;
+
+       if (listener_list)
+               listener_list = eina_list_remove(listener_list, listener);
+       if (listener)
+               ecore_event_handler_del(listener);
+}
+
+MMI_API void
+mmi_event_remove_all_listeners(mmi_handle h)
+{
+       Eina_List *l = NULL;
+       mmi_event_listener *listener = NULL;
+
+       (void) h;
+
+       EINA_LIST_FOREACH(listener_list, l, listener)
+               ecore_event_handler_del(listener);
+
+       listener_list = eina_list_free(listener_list);
+       listener_list = NULL;
+}
+
+MMI_API void
+mmi_instance_destroy(mmi_handle *h)
+{
+       if (!h)
+               return;
+
+       mmi_ipc_shutdown();
+       free(*h);
+       *h = NULL;
+}
+
diff --git a/src/mmi.h b/src/mmi.h
new file mode 100644 (file)
index 0000000..6a15eef
--- /dev/null
+++ b/src/mmi.h
@@ -0,0 +1,97 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_H__
+#define __MMI_H__
+
+#include <Ecore.h>
+#include <mmi-event-types.h>
+
+#define MMI_API __attribute__ ((visibility("default")))
+
+MMI_API extern int MMI_EVENT_CONNECTION;
+MMI_API extern int MMI_EVENT_FOCUS;
+MMI_API extern int MMI_EVENT_STATE_CHANGE;
+MMI_API extern int MMI_EVENT_WAKE_UP;
+MMI_API extern int MMI_EVENT_KEY;
+MMI_API extern int MMI_EVENT_GESTURE;
+MMI_API extern int MMI_EVENT_VOICE;
+MMI_API extern int MMI_EVENT_ACTION;
+MMI_API extern int MMI_EVENT_FEEDBACK;
+
+typedef void* mmi_rpc_h;
+typedef Eina_Bool mmi_bool;
+typedef Ecore_Event_Handler mmi_event_listener;
+typedef Ecore_Event_Handler_Cb mmi_evnt_handler_cb;
+typedef mmi_bool (*mmi_event_handler_cb)(void *data, int ev_type, void *event);
+
+typedef enum
+{
+       MMI_RESULT_NONE,
+       MMI_RESULT_FAIL,
+       MMI_RESULT_SUCCESS
+} mmi_result;
+
+typedef enum
+{
+       MMI_STATE_NONE,
+       MMI_STATE_INITIATION,
+       MMI_STATE_EXPLORATION,
+       MMI_STATE_EXECUTION,
+       MMI_STATE_FEEDBACK,
+       MMI_STATE_OBSERVATION,
+       MMI_STATE_TERMINATION
+} mmi_state;
+
+typedef struct
+{
+       mmi_rpc_h rpc_h;
+       const char *app_id;
+       const char *stub_appid;
+       int uid;
+       int state;
+} mmi_struct;
+
+typedef mmi_struct* mmi_handle;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+MMI_API int mmi_init(void);
+MMI_API int mmi_shutdown(void);
+MMI_API mmi_handle mmi_instance_create(const char *app_id);
+MMI_API void mmi_instance_destroy(mmi_handle *h);
+
+MMI_API mmi_event_listener *mmi_event_add_listener(mmi_handle h, int ev_type, mmi_event_handler_cb func, const void *data);
+MMI_API mmi_result mmi_request_send_get_focus(mmi_handle h);
+MMI_API mmi_state mmi_state_get_current_state(mmi_handle h);
+MMI_API mmi_result mmi_request_send_set_state(mmi_handle h, mmi_state state);
+MMI_API void mmi_event_remove_listener(mmi_handle h, mmi_event_listener *listener);
+MMI_API void mmi_event_remove_all_listeners(mmi_handle h);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMIFW_H__
diff --git a/src/mmifw-dbg.h b/src/mmifw-dbg.h
deleted file mode 100644 (file)
index 0a5cf12..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef __MMIFW_DBG_H__
-#define __MMIFW_DBG_H__
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "MMIFW"
-
-#ifndef _E
-#define _E LOGE
-#endif
-
-#ifndef _D
-#define _D LOGD
-#endif
-
-#ifndef _I
-#define _I LOGI
-#endif
-
-#ifndef _W
-#define _W LOGW
-#endif
-
-#endif // __MMIFW_DBG_H__ 
diff --git a/src/mmifw-event-types.h b/src/mmifw-event-types.h
deleted file mode 100644 (file)
index 2b13355..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef __MMIFW_EVENT_TYPES_H__
-#define __MMIFW_EVENT_TYPES_H__
-
-#include <stdbool.h>
-
-typedef struct
-{
-   bool connected;
-} mmifw_event_connection;
-
-typedef struct
-{
-   int type;//focus in/out
-   int timestamp;
-   bool focus_in;
-} mmifw_event_focus;
-
-typedef struct {
-   int type;//state change
-   int timestamp;
-   int state;
-   int old_state;
-} mmifw_event_state_change;
-
-typedef struct {
-   int type;
-   int timestamp;
-   char *source;//event source information like voice, gesture, key, vision, and so on
-} mmifw_event_wakeup;
-
-typedef struct
-{
-   int type;//up, down, left, right, select, back, ...
-   int timestamp;
-   int keycode;
-   bool key_down;
-   char *keyname;
-   char *source;//event source information
-} mmifw_event_key;
-
-typedef struct {
-   int type;//swipe up, down, left, right, yes, ...
-   int timestamp;
-   char *source;//event source information
-} mmifw_event_gesture;
-
-typedef struct {
-   int type;//voice up, down, left, right, select, back, ...
-   int timestamp;
-   char *source;//event source information
-} mmifw_event_voice;
-
-typedef struct {
-   int type;//action play/pause/resume/stop/execute/launch/revoke/volume ...
-   int timestamp;
-   char *cmd;
-   char **args;
-   int nargs;
-   char *source;//event source information
-} mmifw_event_action;
-
-typedef struct
-{
-   int type;//feedback positive, feedback negative, feedback comment
-   int timestamp;
-   char *feedback;
-   char *comment;
-} mmifw_event_feedback;
-
-#endif //__MMIFW_EVENT_TYPES_H__
diff --git a/src/mmifw-ipc.c b/src/mmifw-ipc.c
deleted file mode 100644 (file)
index a625c4b..0000000
+++ /dev/null
@@ -1,798 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#include "mmifw.h"
-#include "mmifw-ipc.h"
-#include "mmifw-dbg.h"
-
-#include <tzplatform_config.h>
-#include <unistd.h>
-#include <rpc-port.h>
-#include <rpc-port-internal.h>
-
-static rpc_port_proxy_mmifw_h _rpc_h;
-static const char* _appid = "";
-static const char* _stub_appid = "mmi-manager";
-static uid_t _uid = -1;
-static int _connected = 0;
-static mmi_state _state = MMI_STATE_NONE;
-
-rpc_port_proxy_mmifw_focus_event_cb_h focus_cb_h;
-rpc_port_proxy_mmifw_state_change_event_cb_h state_change_cb_h;
-rpc_port_proxy_mmifw_wakeup_event_cb_h wakeup_cb_h;
-rpc_port_proxy_mmifw_key_event_cb_h key_cb_h;
-rpc_port_proxy_mmifw_gesture_event_cb_h gesture_cb_h;
-rpc_port_proxy_mmifw_voice_event_cb_h voice_cb_h;
-rpc_port_proxy_mmifw_action_event_cb_h action_cb_h;
-rpc_port_proxy_mmifw_feedback_event_cb_h feedback_cb_h;
-
-rpc_port_proxy_mmifw_h
-mmi_ipc_get_rpc_h(void)
-{
-       return _rpc_h;
-}
-
-mmi_state
-mmi_ipc_get_state(void)
-{
-       return _state;
-}
-
-int
-mmi_ipc_get_uid(void)
-{
-       return _uid;
-}
-
-bool
-mmi_ipc_is_connected(void)
-{
-       return _connected ? true : false;
-}
-
-const char *
-mmi_ipc_get_appid(void)
-{
-       return _appid;
-}
-
-const char *
-mmi_ipc_get_stub_appid(void)
-{
-       return _stub_appid;
-}
-
-static void _focus_event_cb(void *user_data, rpc_port_proxy_focus_event_h args)
-{
-       int r;
-       mmifw_event_focus *ev = NULL;
-
-       ev = (mmifw_event_focus *)calloc(1, sizeof(mmifw_event_focus));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory focus event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_focus_event_get_type(args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_focus_event_get_timestamp(args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_focus_event_get_focus_in(args, &ev->focus_in);
-       if (r)
-       {
-               LOGE("Failed to get focus_in (error:%d)\n", r);
-               goto err;
-       }
-
-       ecore_event_add(MMI_EVENT_FOCUS, ev, NULL, user_data);
-       return;
-err:
-       if (ev)
-               free(ev);
-}
-
-static void _state_change_event_cb(void *user_data, rpc_port_proxy_state_change_event_h args)
-{
-       int r;
-       mmifw_event_state_change *ev = NULL;
-
-       ev = (mmifw_event_state_change *)calloc(1, sizeof(mmifw_event_state_change));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory state_change event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_state_change_event_get_type(args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_state_change_event_get_timestamp(args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_state_change_event_get_state(args, &ev->state);
-       if (r)
-       {
-               LOGE("Failed to get state (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_state_change_event_get_old_state(args, &ev->old_state);
-       if (r)
-       {
-               LOGE("Failed to get old_state (error:%d)\n", r);
-               goto err;
-       }
-
-       _state = ev->state;
-       ecore_event_add(MMI_EVENT_STATE_CHANGE, ev, NULL, user_data);
-       return;
-err:
-       if (ev)
-               free(ev);
-}
-
-static void
-_wakeup_event_free(void *data, void *ev)
-{
-       mmifw_event_wakeup *e = (mmifw_event_wakeup *)ev;
-
-       if (e->source)
-               free(e->source);
-       free(e);
-}
-
-static void _wakeup_event_cb(void *user_data, rpc_port_proxy_wakeup_event_h args)
-{
-       int r;
-       mmifw_event_wakeup *ev = NULL;
-
-       ev = (mmifw_event_wakeup *)calloc(1, sizeof(mmifw_event_wakeup));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory wakeup event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_wakeup_event_get_type(args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_wakeup_event_get_timestamp(args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_wakeup_event_get_source(args, &ev->source);
-       if (r)
-       {
-               LOGE("Failed to get source (error:%d)\n", r);
-               goto err;
-       }
-
-       ecore_event_add(MMI_EVENT_WAKE_UP, ev, _wakeup_event_free, user_data);
-       return;
-err:
-       if (ev)
-               _wakeup_event_free(NULL, ev);
-}
-
-static void
-_key_event_free(void *data, void *ev)
-{
-       mmifw_event_key *e = (mmifw_event_key *)ev;
-
-       if (e->keyname)
-               free(e->keyname);
-       if (e->source)
-               free(e->source);
-       free(e);
-}
-
-static void _key_event_cb(void *user_data, rpc_port_proxy_key_event_h args)
-{
-       int r;
-       mmifw_event_key *ev = NULL;
-
-       ev = (mmifw_event_key *)calloc(1, sizeof(mmifw_event_key));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory key event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_key_event_get_type(args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_key_event_get_timestamp(args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_key_event_get_keycode(args, &ev->keycode);
-       if (r)
-       {
-               LOGE("Failed to get keycode (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_key_event_get_key_down(args, &ev->key_down);
-       if (r)
-       {
-               LOGE("Failed to get key_down (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_key_event_get_keyname(args, &ev->keyname);
-       if (r)
-       {
-               LOGE("Failed to get keyname (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_key_event_get_source(args, &ev->source);
-       if (r)
-       {
-               LOGE("Failed to get source (error:%d)\n", r);
-               goto err;
-       }
-
-       ecore_event_add(MMI_EVENT_KEY, ev, _key_event_free, user_data);
-       return;
-err:
-       if (ev)
-               _key_event_free(NULL, ev);
-}
-
-static void
-_gesture_event_free(void *data, void *ev)
-{
-        mmifw_event_gesture *e = (mmifw_event_gesture *)ev;
-
-        if (e->source)
-                free(e->source);
-        free(e);
-}
-
-static void _gesture_event_cb(void *user_data, rpc_port_proxy_gesture_event_h args)
-{
-       int r;
-       mmifw_event_gesture *ev = NULL;
-
-       ev = (mmifw_event_gesture *)calloc(1, sizeof(mmifw_event_gesture));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory gesture event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_gesture_event_get_type(args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_gesture_event_get_timestamp(args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_gesture_event_get_source(args, &ev->source);
-       if (r)
-       {
-               LOGE("Failed to get source (error:%d)\n", r);
-               goto err;
-       }
-
-       ecore_event_add(MMI_EVENT_GESTURE, ev, _gesture_event_free, user_data);
-       return;
-err:
-       if (ev)
-               _gesture_event_free(NULL, ev);
-}
-
-static void
-_voice_event_free(void *data, void *ev)
-{
-        mmifw_event_voice *e = (mmifw_event_voice *)ev;
-
-        if (e->source)
-                free(e->source);
-        free(e);
-}
-
-static void _voice_event_cb(void *user_data, rpc_port_proxy_voice_event_h args)
-{
-       int r;
-       mmifw_event_voice *ev = NULL;
-
-       ev = (mmifw_event_voice *)calloc(1, sizeof(mmifw_event_voice));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory voice event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_voice_event_get_type(args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_voice_event_get_timestamp(args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_voice_event_get_source(args, &ev->source);
-       if (r)
-       {
-               LOGE("Failed to get source (error:%d)\n", r);
-               goto err;
-       }
-
-       ecore_event_add(MMI_EVENT_VOICE, ev, _voice_event_free, user_data);
-       return;
-err:
-       if (ev)
-               _voice_event_free(NULL, ev);
-}
-
-static void
-_action_event_free(void *data, void *ev)
-{
-       mmifw_event_action *e = (mmifw_event_action *)ev;
-
-       if (e->cmd)
-               free(e->cmd);
-       if (e->source)
-               free(e->source);
-       if (e->args)
-       {
-               for(int n = 0; n < e->nargs; ++n)
-                       if (e->args[n])
-                               free(e->args[n]);
-
-       }
-       free(e);
-}
-
-static void _action_event_cb(void *user_data, rpc_port_proxy_action_event_h ev_args)
-{
-       int r;
-       int args_size;
-       mmifw_event_action *ev = NULL;
-       rpc_port_proxy_array_string_h array_string_h = NULL;
-
-       ev = (mmifw_event_action *)calloc(1, sizeof(mmifw_event_action));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory action event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_action_event_get_type(ev_args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_action_event_get_timestamp(ev_args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_action_event_get_cmd(ev_args, &ev->cmd);
-       if (r)
-       {
-               LOGE("Failed to get cmd (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_action_event_get_nargs(ev_args, &ev->nargs);
-       if (r)
-       {
-               LOGE("Failed to get nargs (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_action_event_get_args(ev_args, &array_string_h);
-       if (r)
-       {
-               LOGE("Failed to get array_string_h ! (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_array_string_get(array_string_h, &ev->args, &args_size);
-       if (r)
-       {
-               LOGE("Failed to get array string (error:%d)\n", r);
-               goto err;
-       }
-
-       if (args_size != ev->nargs)
-       {
-               LOGE("Invalid args_size in event (args_size=%d, nargs=%d) !\n", args_size, ev->nargs);
-               goto err;
-       }
-
-       r = rpc_port_proxy_action_event_get_source(ev_args, &ev->source);
-       if (r)
-       {
-               LOGE("Failed to get source (error:%d)\n", r);
-               goto err;
-       }
-
-       ecore_event_add(MMI_EVENT_ACTION, ev, _action_event_free, user_data);
-       return;
-err:
-       if (ev)
-               _action_event_free(NULL, ev);
-       if (array_string_h)
-               rpc_port_proxy_array_string_destroy(array_string_h);
-}
-
-static void
-_feedback_event_free(void *data, void *ev)
-{
-       mmifw_event_feedback *e = (mmifw_event_feedback *)ev;
-
-       if (e->feedback)
-               free(e->feedback);
-       if (e->comment)
-               free(e->comment);
-       free(e);
-}
-
-static void _feedback_event_cb(void *user_data, rpc_port_proxy_feedback_event_h args)
-{
-       int r;
-       mmifw_event_feedback *ev = NULL;
-
-       ev = (mmifw_event_feedback *)calloc(1, sizeof(mmifw_event_feedback));
-
-       if (!ev)
-       {
-               LOGE("Failed to allocate memory feedback event !\n");
-               return;
-       }
-
-       r = rpc_port_proxy_feedback_event_get_type(args, &ev->type);
-       if (r)
-       {
-               LOGE("Failed to get type (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_feedback_event_get_timestamp(args, &ev->timestamp);
-       if (r)
-       {
-               LOGE("Failed to get timestamp (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_feedback_event_get_feedback(args, &ev->feedback);
-       if (r)
-       {
-               LOGE("Failed to get feedback (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_feedback_event_get_comment(args, &ev->comment);
-       if (r)
-       {
-               LOGE("Failed to get comment (error:%d)\n", r);
-               goto err;
-       }
-
-       ecore_event_add(MMI_EVENT_FEEDBACK, ev, _feedback_event_free, user_data);
-       return;
-err:
-       if (ev)
-               _feedback_event_free(NULL, ev);
-}
-
-static void _on_connected(rpc_port_proxy_mmifw_h h, void *user_data)
-{
-       int r;
-       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;
-       }
-
-       r = rpc_port_proxy_mmifw_focus_event_cb_create(&focus_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create focus callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_focus_event_cb_set_callback(focus_cb_h, _focus_event_cb, NULL);
-       rpc_port_proxy_mmifw_focus_event_cb_set_once(focus_cb_h, false);
-
-       r = rpc_port_proxy_mmifw_state_change_event_cb_create(&state_change_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create state callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_state_change_event_cb_set_callback(state_change_cb_h, _state_change_event_cb, NULL);
-       rpc_port_proxy_mmifw_state_change_event_cb_set_once(state_change_cb_h, false);
-
-       r = rpc_port_proxy_mmifw_wakeup_event_cb_create(&wakeup_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_wakeup_event_cb_set_callback(wakeup_cb_h, _wakeup_event_cb, NULL);
-       rpc_port_proxy_mmifw_wakeup_event_cb_set_once(wakeup_cb_h, false);
-
-       r = rpc_port_proxy_mmifw_key_event_cb_create(&key_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_key_event_cb_set_callback(key_cb_h, _key_event_cb, NULL);
-       rpc_port_proxy_mmifw_key_event_cb_set_once(key_cb_h, false);
-
-       r = rpc_port_proxy_mmifw_gesture_event_cb_create(&gesture_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_gesture_event_cb_set_callback(gesture_cb_h, _gesture_event_cb, NULL);
-       rpc_port_proxy_mmifw_gesture_event_cb_set_once(gesture_cb_h, false);
-
-       r = rpc_port_proxy_mmifw_voice_event_cb_create(&voice_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_voice_event_cb_set_callback(voice_cb_h, _voice_event_cb, NULL);
-       rpc_port_proxy_mmifw_voice_event_cb_set_once(voice_cb_h, false);
-
-       r = rpc_port_proxy_mmifw_action_event_cb_create(&action_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_action_event_cb_set_callback(action_cb_h, _action_event_cb, NULL);
-       rpc_port_proxy_mmifw_action_event_cb_set_once(action_cb_h, false);
-
-       r = rpc_port_proxy_mmifw_feedback_event_cb_create(&feedback_cb_h);
-       if (r)
-       {
-               LOGE("Failed to create callback handle (error:%d)\n", r);
-               goto err;
-       }
-       rpc_port_proxy_mmifw_feedback_event_cb_set_callback(feedback_cb_h, _feedback_event_cb, NULL);
-       rpc_port_proxy_mmifw_feedback_event_cb_set_once(feedback_cb_h, false);
-
-       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
-               goto err;
-       }
-
-       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
-               goto err;
-       }
-
-       _connected = 1;
-       ev->connected = true;
-       ecore_event_add(MMI_EVENT_CONNECTION, ev, NULL, user_data);
-
-       LOGI("...");
-       return;
-err:
-       if (ev)
-               free(ev);
-       if (focus_cb_h)
-               rpc_port_proxy_mmifw_focus_event_cb_destroy(focus_cb_h);
-       if (state_change_cb_h)
-               rpc_port_proxy_mmifw_state_change_event_cb_destroy(state_change_cb_h);
-       if (wakeup_cb_h)
-               rpc_port_proxy_mmifw_wakeup_event_cb_destroy(wakeup_cb_h);
-       if (key_cb_h)
-               rpc_port_proxy_mmifw_key_event_cb_destroy(key_cb_h);
-       if (gesture_cb_h)
-               rpc_port_proxy_mmifw_gesture_event_cb_destroy(gesture_cb_h);
-       if (voice_cb_h)
-               rpc_port_proxy_mmifw_voice_event_cb_destroy(voice_cb_h);
-       if (action_cb_h)
-               rpc_port_proxy_mmifw_action_event_cb_destroy(action_cb_h);
-       if (feedback_cb_h)
-               rpc_port_proxy_mmifw_feedback_event_cb_destroy(feedback_cb_h);
-}
-
-static void _on_disconnected(rpc_port_proxy_mmifw_h h, void *user_data)
-{
-       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)
-{
-       LOGI("...");
-       _connected = 0;
-}
-
-int
-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);
-
-       rpc_port_set_target_uid(_uid);
-
-       int r = rpc_port_register_proc_info(appid, NULL);
-       if (r != RPC_PORT_ERROR_NONE)
-       {
-               LOGE("Failed to register proc info ! (error:%d)\n", r);
-               goto err;
-       }
-
-       _appid = appid;
-
-       rpc_port_proxy_mmifw_callback_s callback = {
-               .connected = _on_connected,
-               .disconnected = _on_disconnected,
-               .rejected = _on_rejected
-       };
-
-       r = rpc_port_proxy_mmifw_create(_stub_appid, &callback, NULL, &_rpc_h);
-       if (r != RPC_PORT_ERROR_NONE)
-       {
-               LOGE("Failed to create mmifw proxy handle ! (error:%d)\n", r);
-               goto err;
-       }
-
-       r = rpc_port_proxy_mmifw_connect(_rpc_h);
-       if (r != RPC_PORT_ERROR_NONE)
-       {
-               LOGE("Failed to connect to %s ! (error:%d)\n", _stub_appid, r);
-               goto err;
-       }
-
-       return 0;
-err:
-       if (_rpc_h)
-               rpc_port_proxy_destroy(_rpc_h);
-
-       rpc_port_deregister_proc_info();
-
-       _rpc_h = NULL;
-       _uid = -1;
-       return -1;
-}
-
-void
-mmi_ipc_shutdown(void)
-{
-       if (!_rpc_h)
-               return;
-
-       rpc_port_proxy_mmifw_invoke_deregister_cb(_rpc_h);
-
-       rpc_port_proxy_mmifw_destroy(_rpc_h);
-       rpc_port_deregister_proc_info();
-       _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;
-
-       _appid = "";
-       _uid = -1;
-       _state = MMI_STATE_NONE;
-       _connected = 0;
-}
diff --git a/src/mmifw-ipc.h b/src/mmifw-ipc.h
deleted file mode 100644 (file)
index 8d68d81..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef __MMIFW_IPC_H__
-#define __MMIFW_IPC_H__
-
-#include "mmifw_proxy.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int mmi_ipc_init(const char *appid);
-void mmi_ipc_shutdown(void);
-
-rpc_port_proxy_mmifw_h mmi_ipc_get_rpc_h(void);
-mmi_state mmi_ipc_get_state(void);
-int mmi_ipc_get_uid(void);
-bool mmi_ipc_is_connected(void);
-const char *mmi_ipc_get_appid(void);
-const char *mmi_ipc_get_stub_appid(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__MMIFW_IPC_H__
diff --git a/src/mmifw.c b/src/mmifw.c
deleted file mode 100644 (file)
index 5c8666a..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#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;
-int MMI_EVENT_KEY;
-int MMI_EVENT_GESTURE;
-int MMI_EVENT_VOICE;
-int MMI_EVENT_ACTION;
-int MMI_EVENT_FEEDBACK;
-
-static int _mmi_init_count = 0;
-Eina_List *listener_list = NULL;
-
-MMIFW_API int
-mmi_init(void)
-{
-       if (++_mmi_init_count != 1)
-               return _mmi_init_count;
-
-       ecore_init();
-
-       Eina_List *l = NULL;
-       mmi_event_listener *listener = NULL;
-
-       if (listener_list)
-       {
-               EINA_LIST_FOREACH(listener_list, l, listener)
-                       ecore_event_handler_del(listener);
-
-               listener_list = eina_list_free(listener_list);
-               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();
-       MMI_EVENT_KEY = ecore_event_type_new();
-       MMI_EVENT_GESTURE = ecore_event_type_new();
-       MMI_EVENT_VOICE = ecore_event_type_new();
-       MMI_EVENT_ACTION = ecore_event_type_new();
-       MMI_EVENT_FEEDBACK = ecore_event_type_new();
-
-       return _mmi_init_count;
-}
-
-MMIFW_API int
-mmi_shutdown(void)
-{
-       if (_mmi_init_count <= 0)
-       {
-               ERR("Init count must be greater than 0.");
-               return 0;
-       }
-
-       _mmi_init_count--;
-
-       MMI_EVENT_CONNECTION = -1;
-       MMI_EVENT_FOCUS = -1;
-       MMI_EVENT_STATE_CHANGE = -1;
-       MMI_EVENT_WAKE_UP = -1;
-       MMI_EVENT_KEY = -1;
-       MMI_EVENT_GESTURE = -1;
-       MMI_EVENT_VOICE = -1;
-       MMI_EVENT_ACTION = -1;
-       MMI_EVENT_FEEDBACK = -1;
-
-       Eina_List *l = NULL;
-       mmi_event_listener *listener = NULL;
-
-       if (listener_list)
-       {
-               EINA_LIST_FOREACH(listener_list, l, listener)
-                       ecore_event_handler_del(listener);
-
-               listener_list = eina_list_free(listener_list);
-               listener_list = NULL;
-       }
-
-       ecore_main_loop_quit();
-       return _mmi_init_count;
-}
-
-MMIFW_API mmi_handle
-mmi_instance_create(const char *app_id)
-{
-       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;
-       }
-
-       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 *
-mmi_event_add_listener(mmi_handle h, int ev_type, mmi_event_handler_cb func, const void *data)
-{
-       mmi_event_listener *listener;
-
-       (void) h;
-
-       listener = ecore_event_handler_add(ev_type, func, data);
-       listener_list = eina_list_append(listener_list, listener);
-       return listener;
-}
-
-MMIFW_API mmi_result
-mmi_request_send_get_focus(mmi_handle h)
-{
-       mmi_result res = MMI_RESULT_SUCCESS;
-
-       if (!h)
-       {
-               ERR("Given mmi_handle is invalid !\n");
-               return MMI_RESULT_FAIL;
-       }
-
-       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;
-}
-
-MMIFW_API mmi_state
-mmi_state_get_current_state(mmi_handle h)
-{
-       if (!h)
-       {
-               ERR("Given mmi_handle is invalid !\n");
-               return MMI_STATE_NONE;
-       }
-
-       h->state = mmi_ipc_get_state();
-       return h->state;
-}
-
-MMIFW_API mmi_result
-mmi_request_send_set_state(mmi_handle h, mmi_state state)
-{
-       mmi_result res = MMI_RESULT_SUCCESS;
-
-       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, state);
-       return res;
-}
-
-MMIFW_API void
-mmi_event_remove_listener(mmi_handle h, mmi_event_listener *listener)
-{
-       (void) h;
-
-       if (listener_list)
-               listener_list = eina_list_remove(listener_list, listener);
-       if (listener)
-               ecore_event_handler_del(listener);
-}
-
-MMIFW_API void
-mmi_event_remove_all_listeners(mmi_handle h)
-{
-       Eina_List *l = NULL;
-       mmi_event_listener *listener = NULL;
-
-       (void) h;
-
-       EINA_LIST_FOREACH(listener_list, l, listener)
-               ecore_event_handler_del(listener);
-
-       listener_list = eina_list_free(listener_list);
-       listener_list = NULL;
-}
-
-MMIFW_API void
-mmi_instance_destroy(mmi_handle *h)
-{
-       if (!h)
-               return;
-
-       mmi_ipc_shutdown();
-       free(*h);
-       *h = NULL;
-}
-
diff --git a/src/mmifw.h b/src/mmifw.h
deleted file mode 100644 (file)
index 1ae3a93..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef __MMIFW_H__
-#define __MMIFW_H__
-
-#include <Ecore.h>
-#include <mmifw-event-types.h>
-
-#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;
-MMIFW_API extern int MMI_EVENT_KEY;
-MMIFW_API extern int MMI_EVENT_GESTURE;
-MMIFW_API extern int MMI_EVENT_VOICE;
-MMIFW_API extern int MMI_EVENT_ACTION;
-MMIFW_API extern int MMI_EVENT_FEEDBACK;
-
-typedef void* mmifw_rpc_h;
-typedef Eina_Bool mmi_bool;
-typedef Ecore_Event_Handler mmi_event_listener;
-typedef Ecore_Event_Handler_Cb mmi_evnt_handler_cb;
-typedef mmi_bool (*mmi_event_handler_cb)(void *data, int ev_type, void *event);
-
-typedef enum
-{
-       MMI_RESULT_NONE,
-       MMI_RESULT_FAIL,
-       MMI_RESULT_SUCCESS
-} mmi_result;
-
-typedef enum
-{
-       MMI_STATE_NONE,
-       MMI_STATE_INITIATION,
-       MMI_STATE_EXPLORATION,
-       MMI_STATE_EXECUTION,
-       MMI_STATE_FEEDBACK,
-       MMI_STATE_OBSERVATION,
-       MMI_STATE_TERMINATION
-} mmi_state;
-
-typedef struct
-{
-       mmifw_rpc_h rpc_h;
-       const char *app_id;
-       const char *stub_appid;
-       int uid;
-       int state;
-} mmi_struct;
-
-typedef mmi_struct* mmi_handle;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-MMIFW_API int mmi_init(void);
-MMIFW_API int mmi_shutdown(void);
-MMIFW_API mmi_handle mmi_instance_create(const char *app_id);
-MMIFW_API void mmi_instance_destroy(mmi_handle *h);
-
-MMIFW_API mmi_event_listener *mmi_event_add_listener(mmi_handle h, int ev_type, mmi_event_handler_cb func, const void *data);
-MMIFW_API mmi_result mmi_request_send_get_focus(mmi_handle h);
-MMIFW_API mmi_state mmi_state_get_current_state(mmi_handle h);
-MMIFW_API mmi_result mmi_request_send_set_state(mmi_handle h, mmi_state state);
-MMIFW_API void mmi_event_remove_listener(mmi_handle h, mmi_event_listener *listener);
-MMIFW_API void mmi_event_remove_all_listeners(mmi_handle h);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__MMIFW_H__
index 92268f168c62eac3acf13165352a3c0332ee57ba..4cc2d4978a992806bba9ef98fb79bbfed405c2d8 100644 (file)
@@ -1,7 +1,7 @@
-mmifw_tests_srcs = [
-       'mmifw-tests.cpp',
-       'mmifw-main-test.cpp',
-       'mmifw-ipc-test.cpp',
+mmi_tests_srcs = [
+       'mmi-tests.cpp',
+       'mmi-main-test.cpp',
+       'mmi-ipc-test.cpp',
        'wait-helper.cpp'
        ]
 
@@ -9,9 +9,9 @@ gmock_dep = dependency('gmock', method : 'pkg-config')
 ecore_dep = dependency('ecore', method : 'pkg-config')
 
 executable(
-       'mmifw-tests',
-       mmifw_tests_srcs,
-       dependencies : [mmifw_declared_dep, gmock_dep, ecore_dep],
-       install_dir : mmifw_prefix_bindir,
+       'mmi-tests',
+       mmi_tests_srcs,
+       dependencies : [mmi_declared_dep, gmock_dep, ecore_dep],
+       install_dir : mmi_prefix_bindir,
        install : true
        )
diff --git a/tests/mmi-ipc-test.cpp b/tests/mmi-ipc-test.cpp
new file mode 100644 (file)
index 0000000..5a023ce
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmi.h"
+#include "mmi-tests.h"
+#include "mmi-ipc.h"
+
+#include <Ecore.h>
+#include <rpc-port-internal.h>
+
+class MMIIpcTest : public ::testing::Test
+{
+public:
+       void SetUp(void) override
+       {
+       }
+
+       void TearDown(void) override
+       {
+       }
+};
+
+TEST_F(MMIIpcTest, MMIFWIpcInitSuccess)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       int ipc_init_res = mmi_ipc_init(app_id);
+
+       EXPECT_EQ(ipc_init_res, 0);
+
+       if(ipc_init_res == 0)
+       {
+               mmi_ipc_shutdown();
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIIpcTest, MMIIpcInitFail)
+{
+       int res = mmi_init();
+       const char *app_id = NULL;
+       int ipc_init_res = mmi_ipc_init(app_id);
+
+       EXPECT_NE(ipc_init_res, 0);
+
+       if(ipc_init_res == 0)
+       {
+               mmi_ipc_shutdown();
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIIpcTest, MMIIpcGetVariableBeforeInit)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+
+       EXPECT_FALSE(mmi_ipc_is_connected());
+
+       rpc_port_proxy_mmi_h rpc_res = mmi_ipc_get_rpc_h();
+       EXPECT_EQ(rpc_res, nullptr);
+
+       mmi_state state_res = mmi_ipc_get_state();
+       EXPECT_EQ(state_res, MMI_STATE_NONE);
+
+       int uid_res = mmi_ipc_get_uid();
+       EXPECT_EQ(uid_res, -1);
+
+       EXPECT_NE(mmi_ipc_get_appid(), app_id);
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIIpcTest, MMIFWIpcGetVariableAfterInit)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+
+       EXPECT_NE(h, nullptr);
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       if(h)
+       {
+               rpc_port_proxy_mmi_h rpc_res = mmi_ipc_get_rpc_h();
+               EXPECT_NE(rpc_res, nullptr);
+               EXPECT_EQ(rpc_res, h->rpc_h);
+
+               mmi_state state_res = mmi_ipc_get_state();
+               EXPECT_EQ(state_res, h->state);
+
+               int uid_res = mmi_ipc_get_uid();
+               EXPECT_NE(uid_res, -1);
+               EXPECT_EQ(uid_res, h->uid);
+
+               EXPECT_EQ(mmi_ipc_get_appid(), app_id);
+               EXPECT_EQ(mmi_ipc_get_appid(), h->app_id);
+               EXPECT_EQ(mmi_ipc_get_stub_appid(), h->stub_appid);
+       }
+
+       if(h)
+       {
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
diff --git a/tests/mmi-main-test.cpp b/tests/mmi-main-test.cpp
new file mode 100644 (file)
index 0000000..e10d35d
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmi.h"
+#include "mmi-tests.h"
+#include "mmi-ipc.h"
+
+#include <Ecore.h>
+#include <rpc-port-internal.h>
+
+class MMIMainTest : public ::testing::Test
+{
+public:
+       void SetUp(void) override
+       {
+       }
+
+       void TearDown(void) override
+       {
+       }
+};
+
+void wait_for_state_change(mmi_handle h, mmi_state state)
+{
+       int timer = 0;
+       while (state != mmi_state_get_current_state(h) && timer < MAX_WAIT_TIME)
+       {
+               ecore_main_loop_iterate();
+               timer++;
+       }
+}
+
+TEST_F(MMIMainTest, MMIMainInit)
+{
+       int res = mmi_init();
+
+       EXPECT_EQ(res, 1);
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainInstanceCreateDestroySuccess)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+
+       EXPECT_NE(h, nullptr);
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainInstanceCreateAndConnectSuccess)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+
+       EXPECT_NE(h, nullptr);
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainInstanceCreateFail)
+{
+       int res = mmi_init();
+       const char *app_id = NULL;
+       mmi_handle h = mmi_instance_create(app_id);
+
+       EXPECT_EQ(h, nullptr);
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+static Eina_Bool
+_cb_focus(void *data, int type, void *event)
+{
+       if (!event)
+               return ECORE_CALLBACK_PASS_ON;
+
+       EXPECT_TRUE(true);
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_cb_connection(void *data, int type, void *event)
+{
+       if (!event)
+               return ECORE_CALLBACK_PASS_ON;
+
+       EXPECT_TRUE(true);
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+TEST_F(MMIMainTest, MMIMainEventAddSingleListener)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+       mmi_event_listener * handler = NULL;
+
+       EXPECT_NE(h, nullptr);
+
+       if(h){
+               handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, _cb_connection, h);
+       }
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       EXPECT_NE(handler, nullptr);
+
+       if(handler)
+               mmi_event_remove_listener(h, handler);
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainEventAddSingleListenerFail)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+       mmi_event_listener * handler =NULL;
+
+       EXPECT_NE(h, nullptr);
+
+       if(h){
+               handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, NULL, NULL);
+       }
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       EXPECT_EQ(handler, nullptr);
+
+       if(handler)
+               mmi_event_remove_listener(h, handler);
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainEventAddSingleListenerSecondFail)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+       mmi_event_listener * handler =NULL;
+
+       EXPECT_NE(h, nullptr);
+
+       if(h){
+               handler = mmi_event_add_listener(h, 100, _cb_connection, NULL);
+       }
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       EXPECT_EQ(handler, nullptr);
+
+       if(handler)
+               mmi_event_remove_listener(h, handler);
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainRequestSendGetFocus)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+
+       EXPECT_NE(h, nullptr);
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       if(h){
+               mmi_result mmi_res = mmi_request_send_get_focus(h);
+               EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
+       }
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainRequestSendSetGetState)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+
+       EXPECT_NE(h, nullptr);
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       if(h){
+               mmi_result mmi_res = mmi_request_send_get_focus(h);
+               EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
+
+               mmi_state state = MMI_STATE_INITIATION;
+               mmi_res  = mmi_request_send_set_state(h, state);
+               EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
+
+               wait_for_state_change(h, MMI_STATE_INITIATION);
+
+               state = mmi_state_get_current_state(h);
+               EXPECT_EQ(state, MMI_STATE_INITIATION);
+       }
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MMIMainEventRemoveAllListener)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+       mmi_event_listener * handler = NULL;
+       mmi_event_listener * handler2 = NULL;
+
+       EXPECT_NE(h, nullptr);
+       EXPECT_EQ(handler, nullptr);
+
+       wait_for_connect();
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       if(h){
+               handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, _cb_connection, h);
+               handler2 = mmi_event_add_listener(h, MMI_EVENT_FOCUS, _cb_focus, h);
+       }
+
+       EXPECT_NE(handler, nullptr);
+       EXPECT_NE(handler2, nullptr);
+
+       if(handler) {
+               mmi_event_remove_all_listeners(h);
+       }
+
+       if(h){
+               mmi_instance_destroy(&h);
+               EXPECT_EQ(h, nullptr);
+       }
+
+       if(res)
+               mmi_shutdown();
+}
\ No newline at end of file
diff --git a/tests/mmi-tests.cpp b/tests/mmi-tests.cpp
new file mode 100644 (file)
index 0000000..a74ee9a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmi-tests.h"
+
+int main(int argc, char **argv)
+{
+       auto testResults = false;
+
+#ifdef TIZEN_TEST_GCOV
+       setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+       try
+       {
+               ::testing::InitGoogleMock(&argc, argv);
+               ::testing::FLAGS_gtest_death_test_style = "fast";
+       }
+       catch ( ... )
+       {
+               PRINT("Error occurred while trying to initialize GoogleTest.\n");
+               exit(EXIT_FAILURE);
+       }
+
+       try
+       {
+               testResults = (RUN_ALL_TESTS() == 0) ? true : false;
+       }
+       catch (const ::testing::internal::GoogleTestFailureException &e)
+       {
+               testResults = false;
+               PRINT("GoogleTestFailureException has been thrown: %s\n", e.what());
+       }
+
+#ifdef TIZEN_TEST_GCOV
+       __gcov_flush();
+#endif
+       return testResults;
+}
+
diff --git a/tests/mmi-tests.h b/tests/mmi-tests.h
new file mode 100644 (file)
index 0000000..85b01d9
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+* 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"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_TESTS_H__
+#define __MMI_TESTS_H__
+
+#include <stdio.h>
+#include <gmock/gmock.h>
+#include <Ecore.h>
+
+#define PRINT printf
+
+#define MAX_WAIT_TIME 300000
+
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
+extern void wait_for_connect();
+
+using ::testing::TestWithParam;
+using ::testing::Bool;
+using ::testing::Values;
+using ::testing::Combine;
+
+#endif //__MMI_TESTS_H__
diff --git a/tests/mmifw-ipc-test.cpp b/tests/mmifw-ipc-test.cpp
deleted file mode 100644 (file)
index cf52486..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#include "mmifw.h"
-#include "mmifw-tests.h"
-#include "mmifw-ipc.h"
-
-#include <Ecore.h>
-#include <rpc-port-internal.h>
-
-class MMIFWIpcTest : public ::testing::Test
-{
-public:
-       void SetUp(void) override
-       {
-       }
-
-       void TearDown(void) override
-       {
-       }
-};
-
-TEST_F(MMIFWIpcTest, MMIFWIpcInitSuccess)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       int ipc_init_res = mmi_ipc_init(app_id);
-
-       EXPECT_EQ(ipc_init_res, 0);
-
-       if(ipc_init_res == 0)
-       {
-               mmi_ipc_shutdown();
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWIpcTest, MMIFWIpcInitFail)
-{
-       int res = mmi_init();
-       const char *app_id = NULL;
-       int ipc_init_res = mmi_ipc_init(app_id);
-
-       EXPECT_NE(ipc_init_res, 0);
-
-       if(ipc_init_res == 0)
-       {
-               mmi_ipc_shutdown();
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWIpcTest, MMIFWIpcGetVariableBeforeInit)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-
-       EXPECT_FALSE(mmi_ipc_is_connected());
-
-       rpc_port_proxy_mmifw_h rpc_res = mmi_ipc_get_rpc_h();
-       EXPECT_EQ(rpc_res, nullptr);
-
-       mmi_state state_res = mmi_ipc_get_state();
-       EXPECT_EQ(state_res, MMI_STATE_NONE);
-
-       int uid_res = mmi_ipc_get_uid();
-       EXPECT_EQ(uid_res, -1);
-
-       EXPECT_NE(mmi_ipc_get_appid(), app_id);
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWIpcTest, MMIFWIpcGetVariableAfterInit)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-
-       EXPECT_NE(h, nullptr);
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       if(h)
-       {
-               rpc_port_proxy_mmifw_h rpc_res = mmi_ipc_get_rpc_h();
-               EXPECT_NE(rpc_res, nullptr);
-               EXPECT_EQ(rpc_res, h->rpc_h);
-
-               mmi_state state_res = mmi_ipc_get_state();
-               EXPECT_EQ(state_res, h->state);
-
-               int uid_res = mmi_ipc_get_uid();
-               EXPECT_NE(uid_res, -1);
-               EXPECT_EQ(uid_res, h->uid);
-
-               EXPECT_EQ(mmi_ipc_get_appid(), app_id);
-               EXPECT_EQ(mmi_ipc_get_appid(), h->app_id);
-               EXPECT_EQ(mmi_ipc_get_stub_appid(), h->stub_appid);
-       }
-
-       if(h)
-       {
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
diff --git a/tests/mmifw-main-test.cpp b/tests/mmifw-main-test.cpp
deleted file mode 100644 (file)
index 69f62f4..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#include "mmifw.h"
-#include "mmifw-tests.h"
-#include "mmifw-ipc.h"
-
-#include <Ecore.h>
-#include <rpc-port-internal.h>
-
-class MMIFWMainTest : public ::testing::Test
-{
-public:
-       void SetUp(void) override
-       {
-       }
-
-       void TearDown(void) override
-       {
-       }
-};
-
-void wait_for_state_change(mmi_handle h, mmi_state state)
-{
-       int timer = 0;
-       while (state != mmi_state_get_current_state(h) && timer < MAX_WAIT_TIME)
-       {
-               ecore_main_loop_iterate();
-               timer++;
-       }
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainInit)
-{
-       int res = mmi_init();
-
-       EXPECT_EQ(res, 1);
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainInstanceCreateDestroySuccess)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-
-       EXPECT_NE(h, nullptr);
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainInstanceCreateAndConnectSuccess)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-
-       EXPECT_NE(h, nullptr);
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainInstanceCreateFail)
-{
-       int res = mmi_init();
-       const char *app_id = NULL;
-       mmi_handle h = mmi_instance_create(app_id);
-
-       EXPECT_EQ(h, nullptr);
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-static Eina_Bool
-_cb_focus(void *data, int type, void *event)
-{
-       if (!event)
-               return ECORE_CALLBACK_PASS_ON;
-
-       EXPECT_TRUE(true);
-       return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_cb_connection(void *data, int type, void *event)
-{
-       if (!event)
-               return ECORE_CALLBACK_PASS_ON;
-
-       EXPECT_TRUE(true);
-       return ECORE_CALLBACK_PASS_ON;
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainEventAddSingleListener)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-       mmi_event_listener * handler = NULL;
-
-       EXPECT_NE(h, nullptr);
-
-       if(h){
-               handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, _cb_connection, h);
-       }
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       EXPECT_NE(handler, nullptr);
-
-       if(handler)
-               mmi_event_remove_listener(h, handler);
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainEventAddSingleListenerFail)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-       mmi_event_listener * handler =NULL;
-
-       EXPECT_NE(h, nullptr);
-
-       if(h){
-               handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, NULL, NULL);
-       }
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       EXPECT_EQ(handler, nullptr);
-
-       if(handler)
-               mmi_event_remove_listener(h, handler);
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainEventAddSingleListenerSecondFail)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-       mmi_event_listener * handler =NULL;
-
-       EXPECT_NE(h, nullptr);
-
-       if(h){
-               handler = mmi_event_add_listener(h, 100, _cb_connection, NULL);
-       }
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       EXPECT_EQ(handler, nullptr);
-
-       if(handler)
-               mmi_event_remove_listener(h, handler);
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainRequestSendGetFocus)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-
-       EXPECT_NE(h, nullptr);
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       if(h){
-               mmi_result mmi_res = mmi_request_send_get_focus(h);
-               EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
-       }
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainRequestSendSetGetState)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-
-       EXPECT_NE(h, nullptr);
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       if(h){
-               mmi_result mmi_res = mmi_request_send_get_focus(h);
-               EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
-
-               mmi_state state = MMI_STATE_INITIATION;
-               mmi_res  = mmi_request_send_set_state(h, state);
-               EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
-
-               wait_for_state_change(h, MMI_STATE_INITIATION);
-
-               state = mmi_state_get_current_state(h);
-               EXPECT_EQ(state, MMI_STATE_INITIATION);
-       }
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
-
-TEST_F(MMIFWMainTest, MMIFWMainEventRemoveAllListener)
-{
-       int res = mmi_init();
-       const char *app_id = "org.tizen.mmi-system-ux-test";
-       mmi_handle h = mmi_instance_create(app_id);
-       mmi_event_listener * handler = NULL;
-       mmi_event_listener * handler2 = NULL;
-
-       EXPECT_NE(h, nullptr);
-       EXPECT_EQ(handler, nullptr);
-
-       wait_for_connect();
-
-       EXPECT_TRUE(mmi_ipc_is_connected());
-
-       if(h){
-               handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, _cb_connection, h);
-               handler2 = mmi_event_add_listener(h, MMI_EVENT_FOCUS, _cb_focus, h);
-       }
-
-       EXPECT_NE(handler, nullptr);
-       EXPECT_NE(handler2, nullptr);
-
-       if(handler) {
-               mmi_event_remove_all_listeners(h);
-       }
-
-       if(h){
-               mmi_instance_destroy(&h);
-               EXPECT_EQ(h, nullptr);
-       }
-
-       if(res)
-               mmi_shutdown();
-}
\ No newline at end of file
diff --git a/tests/mmifw-tests.cpp b/tests/mmifw-tests.cpp
deleted file mode 100644 (file)
index c9659e1..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#include "mmifw-tests.h"
-
-int main(int argc, char **argv)
-{
-       auto testResults = false;
-
-#ifdef TIZEN_TEST_GCOV
-       setenv("GCOV_PREFIX", "/tmp", 1);
-#endif
-       try
-       {
-               ::testing::InitGoogleMock(&argc, argv);
-               ::testing::FLAGS_gtest_death_test_style = "fast";
-       }
-       catch ( ... )
-       {
-               PRINT("Error occurred while trying to initialize GoogleTest.\n");
-               exit(EXIT_FAILURE);
-       }
-
-       try
-       {
-               testResults = (RUN_ALL_TESTS() == 0) ? true : false;
-       }
-       catch (const ::testing::internal::GoogleTestFailureException &e)
-       {
-               testResults = false;
-               PRINT("GoogleTestFailureException has been thrown: %s\n", e.what());
-       }
-
-#ifdef TIZEN_TEST_GCOV
-       __gcov_flush();
-#endif
-       return testResults;
-}
-
diff --git a/tests/mmifw-tests.h b/tests/mmifw-tests.h
deleted file mode 100644 (file)
index 121c9da..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-* 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"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice (including the next
-* paragraph) shall be included in all copies or substantial portions of the
-* Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-* DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef __MMIFW_TESTS_H__
-#define __MMIFW_TESTS_H__
-
-#include <stdio.h>
-#include <gmock/gmock.h>
-#include <Ecore.h>
-
-#define PRINT printf
-
-#define MAX_WAIT_TIME 300000
-
-#ifdef TIZEN_TEST_GCOV
-extern "C" void __gcov_flush(void);
-#endif
-extern void wait_for_connect();
-
-using ::testing::TestWithParam;
-using ::testing::Bool;
-using ::testing::Values;
-using ::testing::Combine;
-
-#endif //__MMIFW_TESTS_H__
index 10ac03ead504a0acf9d048d620ed3a973d01b53b..d5a387b69fcdcf81daa4f422f0a0003c1583b70a 100644 (file)
@@ -1,6 +1,6 @@
-#include "mmifw.h"
-#include "mmifw-tests.h"
-#include "mmifw-ipc.h"
+#include "mmi.h"
+#include "mmi-tests.h"
+#include "mmi-ipc.h"
 
 #include <Ecore.h>
 
diff --git a/tidl/mmi.tidl b/tidl/mmi.tidl
new file mode 100644 (file)
index 0000000..165e688
--- /dev/null
@@ -0,0 +1,79 @@
+struct focus_event {
+   int type;
+   int timestamp;
+   bool focus_in;
+}
+
+struct state_change_event {
+   int type;
+   int timestamp;
+   int state;
+   int old_state;
+}
+
+struct wakeup_event {
+   int type;
+   int timestamp;
+   string source;
+}
+
+struct key_event {
+   int type;
+   int timestamp;
+   bool key_down;
+   int keycode;
+   string keyname;
+   string source;
+}
+
+struct gesture_event {
+   int type;
+   int timestamp;
+   string source;
+}
+
+struct voice_event {
+   int type;
+   int timestamp;
+   string source;
+}
+
+struct action_event {
+   int type;
+   int timestamp;
+   string cmd;
+   array<string> args;
+   int nargs;
+   string source;
+}
+
+struct feedback_event {
+   int type;
+   int timestamp;
+   string feedback;
+   string comment;
+}
+
+interface mmi {
+   void focus_event_cb(focus_event args) delegate;
+   void state_change_event_cb(state_change_event args) delegate;
+   void wakeup_event_cb(wakeup_event args) delegate;
+   void key_event_cb(key_event args) delegate;
+   void gesture_event_cb(gesture_event args) delegate;
+   void voice_event_cb(voice_event args) delegate;
+   void action_event_cb(action_event args) delegate;
+   void feedback_event_cb(feedback_event args) delegate;
+
+   int register_cb(focus_event_cb focus_cb,
+                   state_change_event_cb state_cb,
+                   wakeup_event_cb wakeup_cb,
+                   key_event_cb key_cb,
+                   gesture_event_cb gesture_cb,
+                   voice_event_cb voice_cb,
+                   action_event_cb action_cb,
+                   feedback_event_cb feedback_cb);
+   void deregister_cb() async;
+   void get_focus() async;
+   void set_state(int state) async;
+}
+
diff --git a/tidl/mmifw.tidl b/tidl/mmifw.tidl
deleted file mode 100644 (file)
index 9c49b2b..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-struct focus_event {
-   int type;
-   int timestamp;
-   bool focus_in;
-}
-
-struct state_change_event {
-   int type;
-   int timestamp;
-   int state;
-   int old_state;
-}
-
-struct wakeup_event {
-   int type;
-   int timestamp;
-   string source;
-}
-
-struct key_event {
-   int type;
-   int timestamp;
-   bool key_down;
-   int keycode;
-   string keyname;
-   string source;
-}
-
-struct gesture_event {
-   int type;
-   int timestamp;
-   string source;
-}
-
-struct voice_event {
-   int type;
-   int timestamp;
-   string source;
-}
-
-struct action_event {
-   int type;
-   int timestamp;
-   string cmd;
-   array<string> args;
-   int nargs;
-   string source;
-}
-
-struct feedback_event {
-   int type;
-   int timestamp;
-   string feedback;
-   string comment;
-}
-
-interface mmifw {
-   void focus_event_cb(focus_event args) delegate;
-   void state_change_event_cb(state_change_event args) delegate;
-   void wakeup_event_cb(wakeup_event args) delegate;
-   void key_event_cb(key_event args) delegate;
-   void gesture_event_cb(gesture_event args) delegate;
-   void voice_event_cb(voice_event args) delegate;
-   void action_event_cb(action_event args) delegate;
-   void feedback_event_cb(feedback_event args) delegate;
-
-   int register_cb(focus_event_cb focus_cb,
-                   state_change_event_cb state_cb,
-                   wakeup_event_cb wakeup_cb,
-                   key_event_cb key_cb,
-                   gesture_event_cb gesture_cb,
-                   voice_event_cb voice_cb,
-                   action_event_cb action_cb,
-                   feedback_event_cb feedback_cb);
-   void deregister_cb() async;
-   void get_focus() async;
-   void set_state(int state) async;
-}
-