pkgconfig = import('pkgconfig')
-subdir('src')
+subdir('src/mmimgr')
+subdir('src/bin')
+subdir('src/modules/ref_fusion')
+subdir('src/modules/modality_keyboard')
subdir('tests')
subdir('tests/iu')
#generate mmi-stub using TIDL Compiler
tidlc -s -l C -i tidl/mmifw.tidl -o mmifw_stub
-cp -af mmifw_stub.* ./src/interface/
+cp -af mmifw_stub.* ./src/mmimgr/interface/
%build
meson setup --prefix=/usr \
%defattr(-,root,root,-)
%license COPYING
%{_bindir}/mmi-manager
+%{_libdir}/libmmi*.so*
+%{_datadir}/iu/*
%{_libdir}/provider/libmmi*.so
%{_libdir}/fusion/libmmi*.so
-%{_datadir}/iu/*
%files devel
%manifest %{name}.manifest
--- /dev/null
+/*
+* 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-manager.h"
+
+int main(int argc, char *argv[])
+{
+ mmi_manager_init();
+ mmi_manager_loop_begin();
+ mmi_manager_shutdown();
+
+ return 0;
+}
+
--- /dev/null
+mmi_manager_srcs = [
+ 'main.c'
+ ]
+
+mmi_manager_deps = [
+ mmimgr_declared_dep
+ ]
+
+executable('mmi-manager',
+ mmi_manager_srcs,
+ dependencies : [mmi_manager_deps],
+ install_dir : mmi_manager_prefix_bindir,
+ install : true,
+ pie : true
+ )
+++ /dev/null
-/*
- * Generated by tidlc 1.4.9.
- */
-
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <libgen.h>
-#include <glib.h>
-#include <dlog.h>
-#include <rpc-port.h>
-#include <rpc-port-parcel.h>
-
-#include "mmifw_stub.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RPC_PORT_STUB"
-
-#ifdef _E
-#undef _E
-#endif
-
-#ifdef _W
-#undef _W
-#endif
-
-#ifdef _I
-#undef _I
-#endif
-
-#ifdef _D
-#undef _D
-#endif
-
-#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
-#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
-#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
-#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
-
-typedef int (*stub_method)(rpc_port_h, rpc_port_parcel_h, void *data);
-
-struct focus_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- bool focus_in;
-};
-
-static void __focus_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_focus_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_bool(parcel, h->focus_in);
-}
-
-static void __focus_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_focus_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_bool(parcel, &h->focus_in);
-}
-
-int rpc_port_focus_event_create(rpc_port_focus_event_h *h)
-{
- struct focus_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct focus_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __focus_event_to;
- handle->parcelable.from = __focus_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_focus_event_destroy(rpc_port_focus_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_focus_event_clone(rpc_port_focus_event_h h, rpc_port_focus_event_h *clone)
-{
- rpc_port_focus_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_focus_event_create(&handle);
- if (!handle) {
- _E("Failed to create focus_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- handle->focus_in = h->focus_in;
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_focus_event_set_type(rpc_port_focus_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_focus_event_set_timestamp(rpc_port_focus_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_focus_event_set_focus_in(rpc_port_focus_event_h h, bool focus_in)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->focus_in = focus_in;
- return 0;
-}
-
-int rpc_port_focus_event_get_type(rpc_port_focus_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_focus_event_get_timestamp(rpc_port_focus_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_focus_event_get_focus_in(rpc_port_focus_event_h h, bool *focus_in)
-{
- if (!h || !focus_in) {
- _E("Invalid parameter");
- return -1;
- }
-
- *focus_in = h->focus_in;
- return 0;
-}
-
-struct state_change_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- int state;
- int old_state;
-};
-
-static void __state_change_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_state_change_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_int32(parcel, h->state);
- rpc_port_parcel_write_int32(parcel, h->old_state);
-}
-
-static void __state_change_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_state_change_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_int32(parcel, &h->state);
- rpc_port_parcel_read_int32(parcel, &h->old_state);
-}
-
-int rpc_port_state_change_event_create(rpc_port_state_change_event_h *h)
-{
- struct state_change_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct state_change_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __state_change_event_to;
- handle->parcelable.from = __state_change_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_state_change_event_destroy(rpc_port_state_change_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_state_change_event_clone(rpc_port_state_change_event_h h, rpc_port_state_change_event_h *clone)
-{
- rpc_port_state_change_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_state_change_event_create(&handle);
- if (!handle) {
- _E("Failed to create state_change_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- handle->state = h->state;
- handle->old_state = h->old_state;
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_state_change_event_set_type(rpc_port_state_change_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_state_change_event_set_timestamp(rpc_port_state_change_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_state_change_event_set_state(rpc_port_state_change_event_h h, int state)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->state = state;
- return 0;
-}
-
-int rpc_port_state_change_event_set_old_state(rpc_port_state_change_event_h h, int old_state)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->old_state = old_state;
- return 0;
-}
-
-int rpc_port_state_change_event_get_type(rpc_port_state_change_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_state_change_event_get_timestamp(rpc_port_state_change_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_state_change_event_get_state(rpc_port_state_change_event_h h, int *state)
-{
- if (!h || !state) {
- _E("Invalid parameter");
- return -1;
- }
-
- *state = h->state;
- return 0;
-}
-
-int rpc_port_state_change_event_get_old_state(rpc_port_state_change_event_h h, int *old_state)
-{
- if (!h || !old_state) {
- _E("Invalid parameter");
- return -1;
- }
-
- *old_state = h->old_state;
- return 0;
-}
-
-struct wakeup_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- char *source;
-};
-
-static void __wakeup_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_wakeup_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
-}
-
-static void __wakeup_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_wakeup_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_string(parcel, &h->source);
-}
-
-int rpc_port_wakeup_event_create(rpc_port_wakeup_event_h *h)
-{
- struct wakeup_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct wakeup_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __wakeup_event_to;
- handle->parcelable.from = __wakeup_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_wakeup_event_destroy(rpc_port_wakeup_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source)
- free(h->source);
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_wakeup_event_clone(rpc_port_wakeup_event_h h, rpc_port_wakeup_event_h *clone)
-{
- rpc_port_wakeup_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_wakeup_event_create(&handle);
- if (!handle) {
- _E("Failed to create wakeup_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- if (h->source) {
- handle->source = strdup(h->source);
- if (!handle->source) {
- _E("Failed to duplicate h->source");
- rpc_port_wakeup_event_destroy(handle);
- return -1;
- }
- }
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_wakeup_event_set_type(rpc_port_wakeup_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_wakeup_event_set_timestamp(rpc_port_wakeup_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_wakeup_event_set_source(rpc_port_wakeup_event_h h, const char *source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source) {
- free(h->source);
- h->source = NULL;
- }
-
- h->source = strdup(source);
- if (!h->source) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_wakeup_event_get_type(rpc_port_wakeup_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_wakeup_event_get_timestamp(rpc_port_wakeup_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_wakeup_event_get_source(rpc_port_wakeup_event_h h, char **source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->source) {
- _E("Invalid parameter: h->source is NULL");
- return -1;
- }
-
- *source = strdup(h->source);
- if (*source == NULL) {
- _E("Failed to duplicate source");
- return -1;
- }
-
- return 0;
-}
-
-struct key_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- bool key_down;
- int keycode;
- char *keyname;
- char *source;
-};
-
-static void __key_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_key_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_bool(parcel, h->key_down);
- rpc_port_parcel_write_int32(parcel, h->keycode);
- rpc_port_parcel_write_string(parcel, h->keyname ? h->keyname : "");
- rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
-}
-
-static void __key_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_key_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_bool(parcel, &h->key_down);
- rpc_port_parcel_read_int32(parcel, &h->keycode);
- rpc_port_parcel_read_string(parcel, &h->keyname);
- rpc_port_parcel_read_string(parcel, &h->source);
-}
-
-int rpc_port_key_event_create(rpc_port_key_event_h *h)
-{
- struct key_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct key_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __key_event_to;
- handle->parcelable.from = __key_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_key_event_destroy(rpc_port_key_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->keyname)
- free(h->keyname);
-
- if (h->source)
- free(h->source);
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_key_event_clone(rpc_port_key_event_h h, rpc_port_key_event_h *clone)
-{
- rpc_port_key_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_key_event_create(&handle);
- if (!handle) {
- _E("Failed to create key_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- handle->key_down = h->key_down;
- handle->keycode = h->keycode;
- if (h->keyname) {
- handle->keyname = strdup(h->keyname);
- if (!handle->keyname) {
- _E("Failed to duplicate h->keyname");
- rpc_port_key_event_destroy(handle);
- return -1;
- }
- }
-
- if (h->source) {
- handle->source = strdup(h->source);
- if (!handle->source) {
- _E("Failed to duplicate h->source");
- rpc_port_key_event_destroy(handle);
- return -1;
- }
- }
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_key_event_set_type(rpc_port_key_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_key_event_set_timestamp(rpc_port_key_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_key_event_set_key_down(rpc_port_key_event_h h, bool key_down)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->key_down = key_down;
- return 0;
-}
-
-int rpc_port_key_event_set_keycode(rpc_port_key_event_h h, int keycode)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->keycode = keycode;
- return 0;
-}
-
-int rpc_port_key_event_set_keyname(rpc_port_key_event_h h, const char *keyname)
-{
- if (!h || !keyname) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->keyname) {
- free(h->keyname);
- h->keyname = NULL;
- }
-
- h->keyname = strdup(keyname);
- if (!h->keyname) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_key_event_set_source(rpc_port_key_event_h h, const char *source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source) {
- free(h->source);
- h->source = NULL;
- }
-
- h->source = strdup(source);
- if (!h->source) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_key_event_get_type(rpc_port_key_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_key_event_get_timestamp(rpc_port_key_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_key_event_get_key_down(rpc_port_key_event_h h, bool *key_down)
-{
- if (!h || !key_down) {
- _E("Invalid parameter");
- return -1;
- }
-
- *key_down = h->key_down;
- return 0;
-}
-
-int rpc_port_key_event_get_keycode(rpc_port_key_event_h h, int *keycode)
-{
- if (!h || !keycode) {
- _E("Invalid parameter");
- return -1;
- }
-
- *keycode = h->keycode;
- return 0;
-}
-
-int rpc_port_key_event_get_keyname(rpc_port_key_event_h h, char **keyname)
-{
- if (!h || !keyname) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->keyname) {
- _E("Invalid parameter: h->keyname is NULL");
- return -1;
- }
-
- *keyname = strdup(h->keyname);
- if (*keyname == NULL) {
- _E("Failed to duplicate keyname");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_key_event_get_source(rpc_port_key_event_h h, char **source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->source) {
- _E("Invalid parameter: h->source is NULL");
- return -1;
- }
-
- *source = strdup(h->source);
- if (*source == NULL) {
- _E("Failed to duplicate source");
- return -1;
- }
-
- return 0;
-}
-
-struct gesture_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- char *source;
-};
-
-static void __gesture_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_gesture_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
-}
-
-static void __gesture_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_gesture_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_string(parcel, &h->source);
-}
-
-int rpc_port_gesture_event_create(rpc_port_gesture_event_h *h)
-{
- struct gesture_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct gesture_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __gesture_event_to;
- handle->parcelable.from = __gesture_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_gesture_event_destroy(rpc_port_gesture_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source)
- free(h->source);
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_gesture_event_clone(rpc_port_gesture_event_h h, rpc_port_gesture_event_h *clone)
-{
- rpc_port_gesture_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_gesture_event_create(&handle);
- if (!handle) {
- _E("Failed to create gesture_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- if (h->source) {
- handle->source = strdup(h->source);
- if (!handle->source) {
- _E("Failed to duplicate h->source");
- rpc_port_gesture_event_destroy(handle);
- return -1;
- }
- }
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_gesture_event_set_type(rpc_port_gesture_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_gesture_event_set_timestamp(rpc_port_gesture_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_gesture_event_set_source(rpc_port_gesture_event_h h, const char *source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source) {
- free(h->source);
- h->source = NULL;
- }
-
- h->source = strdup(source);
- if (!h->source) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_gesture_event_get_type(rpc_port_gesture_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_gesture_event_get_timestamp(rpc_port_gesture_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_gesture_event_get_source(rpc_port_gesture_event_h h, char **source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->source) {
- _E("Invalid parameter: h->source is NULL");
- return -1;
- }
-
- *source = strdup(h->source);
- if (*source == NULL) {
- _E("Failed to duplicate source");
- return -1;
- }
-
- return 0;
-}
-
-struct voice_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- char *source;
-};
-
-static void __voice_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_voice_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
-}
-
-static void __voice_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_voice_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_string(parcel, &h->source);
-}
-
-int rpc_port_voice_event_create(rpc_port_voice_event_h *h)
-{
- struct voice_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct voice_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __voice_event_to;
- handle->parcelable.from = __voice_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_voice_event_destroy(rpc_port_voice_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source)
- free(h->source);
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_voice_event_clone(rpc_port_voice_event_h h, rpc_port_voice_event_h *clone)
-{
- rpc_port_voice_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_voice_event_create(&handle);
- if (!handle) {
- _E("Failed to create voice_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- if (h->source) {
- handle->source = strdup(h->source);
- if (!handle->source) {
- _E("Failed to duplicate h->source");
- rpc_port_voice_event_destroy(handle);
- return -1;
- }
- }
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_voice_event_set_type(rpc_port_voice_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_voice_event_set_timestamp(rpc_port_voice_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_voice_event_set_source(rpc_port_voice_event_h h, const char *source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source) {
- free(h->source);
- h->source = NULL;
- }
-
- h->source = strdup(source);
- if (!h->source) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_voice_event_get_type(rpc_port_voice_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_voice_event_get_timestamp(rpc_port_voice_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_voice_event_get_source(rpc_port_voice_event_h h, char **source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->source) {
- _E("Invalid parameter: h->source is NULL");
- return -1;
- }
-
- *source = strdup(h->source);
- if (*source == NULL) {
- _E("Failed to duplicate source");
- return -1;
- }
-
- return 0;
-}
-
-struct action_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- char *cmd;
- char **args;
- int args_size;
- int nargs;
- char *source;
-};
-
-static void __action_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_action_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_string(parcel, h->cmd ? h->cmd : "");
- rpc_port_parcel_write_array_count(parcel, h->args_size);
- do {
- for (int i = 0; i < h->args_size; i++) {
- rpc_port_parcel_write_string(parcel, h->args[i] ? h->args[i] : "");
- }
- } while (0);
-
- rpc_port_parcel_write_int32(parcel, h->nargs);
- rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
-}
-
-static void __action_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_action_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_string(parcel, &h->cmd);
-
- do {
- rpc_port_parcel_read_array_count(parcel, &h->args_size);
-
- h->args = calloc(h->args_size, sizeof(*h->args));
- if (!h->args) {
- _E("Out of memory");
- return;
- }
-
- for (int i = 0; i < h->args_size; i++) {
- char *value = NULL;
-
- rpc_port_parcel_read_string(parcel, &value);
- h->args[i] = value;
- }
- } while (0);
-
- rpc_port_parcel_read_int32(parcel, &h->nargs);
- rpc_port_parcel_read_string(parcel, &h->source);
-}
-
-int rpc_port_action_event_create(rpc_port_action_event_h *h)
-{
- struct action_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct action_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __action_event_to;
- handle->parcelable.from = __action_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_action_event_destroy(rpc_port_action_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->cmd)
- free(h->cmd);
-
- do {
- for (int j = 0; j < h->args_size; j++) {
- if (h->args[j])
- free(h->args[j]);
- }
- free(h->args);
- } while (0);
- if (h->source)
- free(h->source);
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_action_event_clone(rpc_port_action_event_h h, rpc_port_action_event_h *clone)
-{
- rpc_port_action_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_action_event_create(&handle);
- if (!handle) {
- _E("Failed to create action_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- if (h->cmd) {
- handle->cmd = strdup(h->cmd);
- if (!handle->cmd) {
- _E("Failed to duplicate h->cmd");
- rpc_port_action_event_destroy(handle);
- return -1;
- }
- }
-
- do {
- if (h->args_size == 0) {
- _W("args is empty");
- break;
- }
-
- handle->args = calloc(h->args_size, sizeof(*h->args));
- if (!handle->args) {
- _E("Out of memory");
- rpc_port_action_event_destroy(handle);
- return -1;
- }
- handle->args_size = h->args_size;
-
- for (int i = 0; i < h->args_size; i++) {
- handle->args[i] = strdup(h->args[i]);
- }
- } while (0);
-
- handle->nargs = h->nargs;
- if (h->source) {
- handle->source = strdup(h->source);
- if (!handle->source) {
- _E("Failed to duplicate h->source");
- rpc_port_action_event_destroy(handle);
- return -1;
- }
- }
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_action_event_set_type(rpc_port_action_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_action_event_set_timestamp(rpc_port_action_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_action_event_set_cmd(rpc_port_action_event_h h, const char *cmd)
-{
- if (!h || !cmd) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->cmd) {
- free(h->cmd);
- h->cmd = NULL;
- }
-
- h->cmd = strdup(cmd);
- if (!h->cmd) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_action_event_set_args(rpc_port_action_event_h h, char **args, int args_size)
-{
- if (!h || !args) {
- _E("Invalid parameter");
- return -1;
- }
-
- do {
- for (int j = 0; j < h->args_size; j++) {
- if (h->args[j])
- free(h->args[j]);
- }
- free(h->args);
- } while (0);
-
- h->args = NULL;
-
- do {
- h->args = calloc(args_size, sizeof(*args));
- if (!h->args) {
- _E("Out of memory");
- return -1;
- }
- h->args_size = args_size;
-
- for (int i = 0; i < h->args_size; i++) {
- h->args[i] = strdup(args[i]);
- }
- } while (0);
-
- return 0;
-}
-
-int rpc_port_action_event_set_nargs(rpc_port_action_event_h h, int nargs)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->nargs = nargs;
- return 0;
-}
-
-int rpc_port_action_event_set_source(rpc_port_action_event_h h, const char *source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->source) {
- free(h->source);
- h->source = NULL;
- }
-
- h->source = strdup(source);
- if (!h->source) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_action_event_get_type(rpc_port_action_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_action_event_get_timestamp(rpc_port_action_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_action_event_get_cmd(rpc_port_action_event_h h, char **cmd)
-{
- if (!h || !cmd) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->cmd) {
- _E("Invalid parameter: h->cmd is NULL");
- return -1;
- }
-
- *cmd = strdup(h->cmd);
- if (*cmd == NULL) {
- _E("Failed to duplicate cmd");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_action_event_get_args(rpc_port_action_event_h h, char ***args, int *args_size)
-{
- if (!h || !args || !args_size) {
- _E("Invalid parameter");
- return -1;
- }
-
- do {
- if (h->args_size == 0) {
- _W("args is empty");
- break;
- }
-
- *args = calloc(h->args_size, sizeof(*h->args));
- if (!*args) {
- _E("Out of memory");
- return -1;
- }
- *args_size = h->args_size;
-
- for (int i = 0; i < h->args_size; i++) {
- (*args)[i] = strdup(h->args[i]);
- }
- } while (0);
-
- return 0;
-}
-
-int rpc_port_action_event_get_nargs(rpc_port_action_event_h h, int *nargs)
-{
- if (!h || !nargs) {
- _E("Invalid parameter");
- return -1;
- }
-
- *nargs = h->nargs;
- return 0;
-}
-
-int rpc_port_action_event_get_source(rpc_port_action_event_h h, char **source)
-{
- if (!h || !source) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->source) {
- _E("Invalid parameter: h->source is NULL");
- return -1;
- }
-
- *source = strdup(h->source);
- if (*source == NULL) {
- _E("Failed to duplicate source");
- return -1;
- }
-
- return 0;
-}
-
-struct feedback_event_s {
- rpc_port_parcelable_t parcelable;
- int type;
- int timestamp;
- char *feedback;
- char *comment;
-};
-
-static void __feedback_event_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_feedback_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, h->type);
- rpc_port_parcel_write_int32(parcel, h->timestamp);
- rpc_port_parcel_write_string(parcel, h->feedback ? h->feedback : "");
- rpc_port_parcel_write_string(parcel, h->comment ? h->comment : "");
-}
-
-static void __feedback_event_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_feedback_event_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &h->type);
- rpc_port_parcel_read_int32(parcel, &h->timestamp);
- rpc_port_parcel_read_string(parcel, &h->feedback);
- rpc_port_parcel_read_string(parcel, &h->comment);
-}
-
-int rpc_port_feedback_event_create(rpc_port_feedback_event_h *h)
-{
- struct feedback_event_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct feedback_event_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __feedback_event_to;
- handle->parcelable.from = __feedback_event_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_feedback_event_destroy(rpc_port_feedback_event_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->feedback)
- free(h->feedback);
-
- if (h->comment)
- free(h->comment);
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_feedback_event_clone(rpc_port_feedback_event_h h, rpc_port_feedback_event_h *clone)
-{
- rpc_port_feedback_event_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_feedback_event_create(&handle);
- if (!handle) {
- _E("Failed to create feedback_event handle");
- return -1;
- }
-
- handle->type = h->type;
- handle->timestamp = h->timestamp;
- if (h->feedback) {
- handle->feedback = strdup(h->feedback);
- if (!handle->feedback) {
- _E("Failed to duplicate h->feedback");
- rpc_port_feedback_event_destroy(handle);
- return -1;
- }
- }
-
- if (h->comment) {
- handle->comment = strdup(h->comment);
- if (!handle->comment) {
- _E("Failed to duplicate h->comment");
- rpc_port_feedback_event_destroy(handle);
- return -1;
- }
- }
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_feedback_event_set_type(rpc_port_feedback_event_h h, int type)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->type = type;
- return 0;
-}
-
-int rpc_port_feedback_event_set_timestamp(rpc_port_feedback_event_h h, int timestamp)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->timestamp = timestamp;
- return 0;
-}
-
-int rpc_port_feedback_event_set_feedback(rpc_port_feedback_event_h h, const char *feedback)
-{
- if (!h || !feedback) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->feedback) {
- free(h->feedback);
- h->feedback = NULL;
- }
-
- h->feedback = strdup(feedback);
- if (!h->feedback) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_feedback_event_set_comment(rpc_port_feedback_event_h h, const char *comment)
-{
- if (!h || !comment) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->comment) {
- free(h->comment);
- h->comment = NULL;
- }
-
- h->comment = strdup(comment);
- if (!h->comment) {
- _E("Failed to duplicate data");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_feedback_event_get_type(rpc_port_feedback_event_h h, int *type)
-{
- if (!h || !type) {
- _E("Invalid parameter");
- return -1;
- }
-
- *type = h->type;
- return 0;
-}
-
-int rpc_port_feedback_event_get_timestamp(rpc_port_feedback_event_h h, int *timestamp)
-{
- if (!h || !timestamp) {
- _E("Invalid parameter");
- return -1;
- }
-
- *timestamp = h->timestamp;
- return 0;
-}
-
-int rpc_port_feedback_event_get_feedback(rpc_port_feedback_event_h h, char **feedback)
-{
- if (!h || !feedback) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->feedback) {
- _E("Invalid parameter: h->feedback is NULL");
- return -1;
- }
-
- *feedback = strdup(h->feedback);
- if (*feedback == NULL) {
- _E("Failed to duplicate feedback");
- return -1;
- }
-
- return 0;
-}
-
-int rpc_port_feedback_event_get_comment(rpc_port_feedback_event_h h, char **comment)
-{
- if (!h || !comment) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!h->comment) {
- _E("Invalid parameter: h->comment is NULL");
- return -1;
- }
-
- *comment = strdup(h->comment);
- if (*comment == NULL) {
- _E("Failed to duplicate comment");
- return -1;
- }
-
- return 0;
-}
-
-struct array_string_s {
- rpc_port_parcelable_t parcelable;
- char **array_strings;
- int array_strings_size;
-};
-
-static void __array_string_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_array_string_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_array_count(parcel, h->array_strings_size);
- do {
- for (int i = 0; i < h->array_strings_size; i++) {
- rpc_port_parcel_write_string(parcel, h->array_strings[i] ? h->array_strings[i] : "");
- }
- } while (0);
-}
-
-static void __array_string_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_array_string_h h = data;
-
- if (!parcel || !h) {
- _E("Invalid parameter");
- return;
- }
-
- do {
- rpc_port_parcel_read_array_count(parcel, &h->array_strings_size);
-
- h->array_strings = calloc(h->array_strings_size, sizeof(*h->array_strings));
- if (!h->array_strings) {
- _E("Out of memory");
- return;
- }
-
- for (int i = 0; i < h->array_strings_size; i++) {
- char *value = NULL;
-
- rpc_port_parcel_read_string(parcel, &value);
- h->array_strings[i] = value;
- }
- } while (0);
-}
-
-int rpc_port_array_string_create(rpc_port_array_string_h *h)
-{
- struct array_string_s *handle;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct array_string_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __array_string_to;
- handle->parcelable.from = __array_string_from;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_array_string_destroy(rpc_port_array_string_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- do {
- for (int j = 0; j < h->array_strings_size; j++) {
- if (h->array_strings[j])
- free(h->array_strings[j]);
- }
- free(h->array_strings);
- } while (0);
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_array_string_clone(rpc_port_array_string_h h, rpc_port_array_string_h *clone)
-{
- rpc_port_array_string_h handle = NULL;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- rpc_port_array_string_create(&handle);
- if (!handle) {
- _E("Failed to create array_string handle");
- return -1;
- }
-
- do {
- if (h->array_strings_size == 0) {
- _W("array_strings is empty");
- break;
- }
-
- handle->array_strings = calloc(h->array_strings_size, sizeof(*h->array_strings));
- if (!handle->array_strings) {
- _E("Out of memory");
- rpc_port_array_string_destroy(handle);
- return -1;
- }
- handle->array_strings_size = h->array_strings_size;
-
- for (int i = 0; i < h->array_strings_size; i++) {
- handle->array_strings[i] = strdup(h->array_strings[i]);
- }
- } while (0);
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_array_string_set_array_strings(rpc_port_array_string_h h, char **array_strings, int array_strings_size)
-{
- if (!h || !array_strings) {
- _E("Invalid parameter");
- return -1;
- }
-
- do {
- for (int j = 0; j < h->array_strings_size; j++) {
- if (h->array_strings[j])
- free(h->array_strings[j]);
- }
- free(h->array_strings);
- } while (0);
-
- h->array_strings = NULL;
-
- do {
- h->array_strings = calloc(array_strings_size, sizeof(*array_strings));
- if (!h->array_strings) {
- _E("Out of memory");
- return -1;
- }
- h->array_strings_size = array_strings_size;
-
- for (int i = 0; i < h->array_strings_size; i++) {
- h->array_strings[i] = strdup(array_strings[i]);
- }
- } while (0);
-
- return 0;
-}
-
-int rpc_port_array_string_get_array_strings(rpc_port_array_string_h h, char ***array_strings, int *array_strings_size)
-{
- if (!h || !array_strings || !array_strings_size) {
- _E("Invalid parameter");
- return -1;
- }
-
- do {
- if (h->array_strings_size == 0) {
- _W("array_strings is empty");
- break;
- }
-
- *array_strings = calloc(h->array_strings_size, sizeof(*h->array_strings));
- if (!*array_strings) {
- _E("Out of memory");
- return -1;
- }
- *array_strings_size = h->array_strings_size;
-
- for (int i = 0; i < h->array_strings_size; i++) {
- (*array_strings)[i] = strdup(h->array_strings[i]);
- }
- } while (0);
-
- return 0;
-}
-
-enum mmifw_method_e {
- mmifw_METHOD_Result,
- mmifw_METHOD_Callback,
- mmifw_METHOD_register_cb,
- mmifw_METHOD_deregister_cb,
- mmifw_METHOD_get_focus,
- mmifw_METHOD_set_state,
-};
-
-enum mmifw_delegate_e {
- mmifw_DELEGATE_focus_event_cb = 1,
- mmifw_DELEGATE_state_change_event_cb = 2,
- mmifw_DELEGATE_wakeup_event_cb = 3,
- mmifw_DELEGATE_key_event_cb = 4,
- mmifw_DELEGATE_gesture_event_cb = 5,
- mmifw_DELEGATE_voice_event_cb = 6,
- mmifw_DELEGATE_action_event_cb = 7,
- mmifw_DELEGATE_feedback_event_cb = 8,
-};
-
-static rpc_port_stub_h __mmifw_stub;
-static rpc_port_stub_mmifw_callback_s __mmifw_callback;
-static void *__mmifw_user_data;
-static GList *__mmifw_contexts;
-
-struct mmifw_context_s {
- char *sender;
- char *instance;
- rpc_port_h port;
- void *tag;
- rpc_port_stub_mmifw_callback_s callback;
- void *user_data;
-};
-
-static struct mmifw_context_s *__create_mmifw_context(const char *sender, const char *instance)
-{
- struct mmifw_context_s *handle;
-
- handle = calloc(1, sizeof(struct mmifw_context_s));
- if (!handle) {
- _E("Out of memory");
- return NULL;
- }
-
- handle->sender = strdup(sender);
- if (!handle->sender) {
- _E("Out of memory");
- free(handle);
- return NULL;
- }
-
- handle->instance = strdup(instance);
- if (!handle->instance) {
- _E("Out of memory");
- free(handle->sender);
- free(handle);
- return NULL;
- }
-
- handle->callback = __mmifw_callback;
- handle->user_data = __mmifw_user_data;
-
- return handle;
-}
-
-static void __destroy_mmifw_context(gpointer data)
-{
- struct mmifw_context_s *handle = data;
-
- if (!handle) {
- _E("Critical error!");
- return;
- }
-
- free(handle->instance);
- free(handle->sender);
-
- free(handle);
-}
-
-static struct mmifw_context_s *__find_mmifw_context(const char *instance)
-{
- struct mmifw_context_s *handle;
- GList *iter;
-
- iter = __mmifw_contexts;
- while (iter) {
- handle = (struct mmifw_context_s *)iter->data;
- if (!strcmp(handle->instance, instance))
- return handle;
- iter = g_list_next(iter);
- }
-
- return NULL;
-}
-
-int rpc_port_stub_mmifw_context_set_tag(rpc_port_stub_mmifw_context_h ctx, void *tag)
-{
- if (!ctx) {
- _E("Invalid parameter");
- return -1;
- }
-
- ctx->tag = tag;
-
- return 0;
-}
-
-int rpc_port_stub_mmifw_context_get_tag(rpc_port_stub_mmifw_context_h ctx, void **tag)
-{
- if (!ctx || !tag) {
- _E("Invalid parameter");
- return -1;
- }
-
- *tag = ctx->tag;
-
- return 0;
-}
-
-int rpc_port_stub_mmifw_context_get_sender(rpc_port_stub_mmifw_context_h ctx, char **sender)
-{
- if (!ctx || !sender) {
- _E("Invalid parameter");
- return -1;
- }
-
- *sender = strdup(ctx->sender);
- if (*sender == NULL) {
- _E("Out of memory");
- return -1;
- }
-
- return 0;
-}
-
-struct mmifw_focus_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_focus_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_focus_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_focus_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_focus_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_focus_event_cb_create(rpc_port_mmifw_focus_event_cb_h *h)
-{
- struct mmifw_focus_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_focus_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_focus_event_cb_to;
- handle->parcelable.from = __mmifw_focus_event_cb_from;
- handle->id = mmifw_DELEGATE_focus_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_focus_event_cb_destroy(rpc_port_mmifw_focus_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_focus_event_cb_clone(rpc_port_mmifw_focus_event_cb_h h, rpc_port_mmifw_focus_event_cb_h *clone)
-{
- rpc_port_mmifw_focus_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_focus_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_focus_event_cb_invoke(rpc_port_mmifw_focus_event_cb_h h, rpc_port_focus_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_focus_event_cb_set_port(rpc_port_mmifw_focus_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-struct mmifw_state_change_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_state_change_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_state_change_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_state_change_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_state_change_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_state_change_event_cb_create(rpc_port_mmifw_state_change_event_cb_h *h)
-{
- struct mmifw_state_change_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_state_change_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_state_change_event_cb_to;
- handle->parcelable.from = __mmifw_state_change_event_cb_from;
- handle->id = mmifw_DELEGATE_state_change_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_state_change_event_cb_destroy(rpc_port_mmifw_state_change_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_state_change_event_cb_clone(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_mmifw_state_change_event_cb_h *clone)
-{
- rpc_port_mmifw_state_change_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_state_change_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_state_change_event_cb_invoke(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_state_change_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_state_change_event_cb_set_port(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-struct mmifw_wakeup_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_wakeup_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_wakeup_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_wakeup_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_wakeup_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_wakeup_event_cb_create(rpc_port_mmifw_wakeup_event_cb_h *h)
-{
- struct mmifw_wakeup_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_wakeup_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_wakeup_event_cb_to;
- handle->parcelable.from = __mmifw_wakeup_event_cb_from;
- handle->id = mmifw_DELEGATE_wakeup_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_wakeup_event_cb_destroy(rpc_port_mmifw_wakeup_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_wakeup_event_cb_clone(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_mmifw_wakeup_event_cb_h *clone)
-{
- rpc_port_mmifw_wakeup_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_wakeup_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_wakeup_event_cb_invoke(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_wakeup_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_wakeup_event_cb_set_port(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-struct mmifw_key_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_key_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_key_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_key_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_key_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_key_event_cb_create(rpc_port_mmifw_key_event_cb_h *h)
-{
- struct mmifw_key_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_key_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_key_event_cb_to;
- handle->parcelable.from = __mmifw_key_event_cb_from;
- handle->id = mmifw_DELEGATE_key_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_key_event_cb_destroy(rpc_port_mmifw_key_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_key_event_cb_clone(rpc_port_mmifw_key_event_cb_h h, rpc_port_mmifw_key_event_cb_h *clone)
-{
- rpc_port_mmifw_key_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_key_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_key_event_cb_invoke(rpc_port_mmifw_key_event_cb_h h, rpc_port_key_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_key_event_cb_set_port(rpc_port_mmifw_key_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-struct mmifw_gesture_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_gesture_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_gesture_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_gesture_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_gesture_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_gesture_event_cb_create(rpc_port_mmifw_gesture_event_cb_h *h)
-{
- struct mmifw_gesture_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_gesture_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_gesture_event_cb_to;
- handle->parcelable.from = __mmifw_gesture_event_cb_from;
- handle->id = mmifw_DELEGATE_gesture_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_gesture_event_cb_destroy(rpc_port_mmifw_gesture_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_gesture_event_cb_clone(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_mmifw_gesture_event_cb_h *clone)
-{
- rpc_port_mmifw_gesture_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_gesture_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_gesture_event_cb_invoke(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_gesture_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_gesture_event_cb_set_port(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-struct mmifw_voice_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_voice_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_voice_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_voice_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_voice_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_voice_event_cb_create(rpc_port_mmifw_voice_event_cb_h *h)
-{
- struct mmifw_voice_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_voice_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_voice_event_cb_to;
- handle->parcelable.from = __mmifw_voice_event_cb_from;
- handle->id = mmifw_DELEGATE_voice_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_voice_event_cb_destroy(rpc_port_mmifw_voice_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_voice_event_cb_clone(rpc_port_mmifw_voice_event_cb_h h, rpc_port_mmifw_voice_event_cb_h *clone)
-{
- rpc_port_mmifw_voice_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_voice_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_voice_event_cb_invoke(rpc_port_mmifw_voice_event_cb_h h, rpc_port_voice_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_voice_event_cb_set_port(rpc_port_mmifw_voice_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-struct mmifw_action_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_action_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_action_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_action_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_action_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_action_event_cb_create(rpc_port_mmifw_action_event_cb_h *h)
-{
- struct mmifw_action_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_action_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_action_event_cb_to;
- handle->parcelable.from = __mmifw_action_event_cb_from;
- handle->id = mmifw_DELEGATE_action_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_action_event_cb_destroy(rpc_port_mmifw_action_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_action_event_cb_clone(rpc_port_mmifw_action_event_cb_h h, rpc_port_mmifw_action_event_cb_h *clone)
-{
- rpc_port_mmifw_action_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_action_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_action_event_cb_invoke(rpc_port_mmifw_action_event_cb_h h, rpc_port_action_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_action_event_cb_set_port(rpc_port_mmifw_action_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-struct mmifw_feedback_event_cb_s {
- rpc_port_parcelable_t parcelable;
- rpc_port_h port;
- int id;
- int seq_id;
- bool once;
- bool valid;
-};
-
-static void __mmifw_feedback_event_cb_to(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_feedback_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_write_int32(parcel, handle->id);
- rpc_port_parcel_write_int32(parcel, handle->seq_id);
- rpc_port_parcel_write_bool(parcel, handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static void __mmifw_feedback_event_cb_from(rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_mmifw_feedback_event_cb_h handle = data;
-
- if (!handle) {
- _E("Invalid parameter");
- return;
- }
-
- rpc_port_parcel_read_int32(parcel, &handle->id);
- rpc_port_parcel_read_int32(parcel, &handle->seq_id);
- rpc_port_parcel_read_bool(parcel, &handle->once);
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-}
-
-static int rpc_port_mmifw_feedback_event_cb_create(rpc_port_mmifw_feedback_event_cb_h *h)
-{
- struct mmifw_feedback_event_cb_s *handle;
- static int seq_num;
-
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_feedback_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable.to = __mmifw_feedback_event_cb_to;
- handle->parcelable.from = __mmifw_feedback_event_cb_from;
- handle->id = mmifw_DELEGATE_feedback_event_cb;
- handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
- handle->once = false;
- handle->valid = true;
-
- *h = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_feedback_event_cb_destroy(rpc_port_mmifw_feedback_event_cb_h h)
-{
- if (!h) {
- _E("Invalid parameter");
- return -1;
- }
-
- free(h);
-
- return 0;
-}
-
-int rpc_port_mmifw_feedback_event_cb_clone(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_mmifw_feedback_event_cb_h *clone)
-{
- rpc_port_mmifw_feedback_event_cb_h handle;
-
- if (!h || !clone) {
- _E("Invalid parameter");
- return -1;
- }
-
- handle = calloc(1, sizeof(struct mmifw_feedback_event_cb_s));
- if (!handle) {
- _E("Out of memory");
- return -1;
- }
-
- handle->parcelable = h->parcelable;
- handle->port = h->port;
- handle->id = h->id;
- handle->seq_id = h->seq_id;
- handle->once = h->once;
- handle->valid = h->valid;
- _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
-
- *clone = handle;
-
- return 0;
-}
-
-int rpc_port_mmifw_feedback_event_cb_invoke(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_feedback_event_h args)
-{
- rpc_port_parcel_h parcel = NULL;
- int r;
-
- if (!h || !h->port) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (h->once && !h->valid) {
- _E("Invalid callback");
- return -1;
- }
-
- rpc_port_parcel_create(&parcel);
- if (!parcel) {
- _E("Failed to create parcel");
- return -1;
- }
-
- rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
- rpc_port_parcel_write(parcel, &h->parcelable, h);
- rpc_port_parcel_write(parcel, &args->parcelable, args);
-
- r = rpc_port_parcel_send(parcel, h->port);
- rpc_port_parcel_destroy(parcel);
- h->valid = false;
-
- return r;
-}
-
-int rpc_port_mmifw_feedback_event_cb_set_port(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_h port)
-{
- if (!h || !port) {
- _E("Invalid parameter");
- return -1;
- }
-
- h->port = port;
-
- return 0;
-}
-
-static int __mmifw_method_register_cb(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_stub_mmifw_context_h context = data;
- rpc_port_h callback_port;
- int r;
-
- r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
- if (r != 0) {
- _E("Failed to get callback port");
- return -1;
- }
-
- rpc_port_mmifw_focus_event_cb_h focus_cb = NULL;
- rpc_port_mmifw_state_change_event_cb_h state_cb = NULL;
- rpc_port_mmifw_wakeup_event_cb_h wakeup_cb = NULL;
- rpc_port_mmifw_key_event_cb_h key_cb = NULL;
- rpc_port_mmifw_gesture_event_cb_h gesture_cb = NULL;
- rpc_port_mmifw_voice_event_cb_h voice_cb = NULL;
- rpc_port_mmifw_action_event_cb_h action_cb = NULL;
- rpc_port_mmifw_feedback_event_cb_h feedback_cb = NULL;
-
- rpc_port_mmifw_focus_event_cb_create(&focus_cb);
-
- if (!focus_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_focus_event_cb_set_port(focus_cb, callback_port);
- rpc_port_parcel_read(parcel, &focus_cb->parcelable, focus_cb);
- rpc_port_mmifw_state_change_event_cb_create(&state_cb);
-
- if (!state_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_state_change_event_cb_set_port(state_cb, callback_port);
- rpc_port_parcel_read(parcel, &state_cb->parcelable, state_cb);
- rpc_port_mmifw_wakeup_event_cb_create(&wakeup_cb);
-
- if (!wakeup_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_wakeup_event_cb_set_port(wakeup_cb, callback_port);
- rpc_port_parcel_read(parcel, &wakeup_cb->parcelable, wakeup_cb);
- rpc_port_mmifw_key_event_cb_create(&key_cb);
-
- if (!key_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_key_event_cb_set_port(key_cb, callback_port);
- rpc_port_parcel_read(parcel, &key_cb->parcelable, key_cb);
- rpc_port_mmifw_gesture_event_cb_create(&gesture_cb);
-
- if (!gesture_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_gesture_event_cb_set_port(gesture_cb, callback_port);
- rpc_port_parcel_read(parcel, &gesture_cb->parcelable, gesture_cb);
- rpc_port_mmifw_voice_event_cb_create(&voice_cb);
-
- if (!voice_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_voice_event_cb_set_port(voice_cb, callback_port);
- rpc_port_parcel_read(parcel, &voice_cb->parcelable, voice_cb);
- rpc_port_mmifw_action_event_cb_create(&action_cb);
-
- if (!action_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_action_event_cb_set_port(action_cb, callback_port);
- rpc_port_parcel_read(parcel, &action_cb->parcelable, action_cb);
- rpc_port_mmifw_feedback_event_cb_create(&feedback_cb);
-
- if (!feedback_cb) {
- _E("Failed to create handle");
- return -1;
- }
-
- rpc_port_mmifw_feedback_event_cb_set_port(feedback_cb, callback_port);
- rpc_port_parcel_read(parcel, &feedback_cb->parcelable, feedback_cb);
-
- int ret = context->callback.register_cb(context, focus_cb, state_cb, wakeup_cb, key_cb, gesture_cb, voice_cb, action_cb, feedback_cb, context->user_data);
- do {
- rpc_port_parcel_h result;
-
- rpc_port_parcel_create(&result);
- rpc_port_parcel_write_int32(result, mmifw_METHOD_Result);
- rpc_port_parcel_write_int32(result, ret);
- r = rpc_port_parcel_send(result, port);
- rpc_port_parcel_destroy(result);
- } while (0);
-
- rpc_port_mmifw_focus_event_cb_destroy(focus_cb);
- rpc_port_mmifw_state_change_event_cb_destroy(state_cb);
- rpc_port_mmifw_wakeup_event_cb_destroy(wakeup_cb);
- rpc_port_mmifw_key_event_cb_destroy(key_cb);
- rpc_port_mmifw_gesture_event_cb_destroy(gesture_cb);
- rpc_port_mmifw_voice_event_cb_destroy(voice_cb);
- rpc_port_mmifw_action_event_cb_destroy(action_cb);
- rpc_port_mmifw_feedback_event_cb_destroy(feedback_cb);
- return r;
-}
-
-static int __mmifw_method_deregister_cb(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_stub_mmifw_context_h context = data;
- rpc_port_h callback_port;
- int r;
-
- r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
- if (r != 0) {
- _E("Failed to get callback port");
- return -1;
- }
-
- context->callback.deregister_cb(context, context->user_data);
-
- return r;
-}
-
-static int __mmifw_method_get_focus(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_stub_mmifw_context_h context = data;
- rpc_port_h callback_port;
- int r;
-
- r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
- if (r != 0) {
- _E("Failed to get callback port");
- return -1;
- }
-
- context->callback.get_focus(context, context->user_data);
-
- return r;
-}
-
-static int __mmifw_method_set_state(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
-{
- rpc_port_stub_mmifw_context_h context = data;
- rpc_port_h callback_port;
- int r;
-
- r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
- if (r != 0) {
- _E("Failed to get callback port");
- return -1;
- }
-
- int state;
-
- rpc_port_parcel_read_int32(parcel, &state);
-
- context->callback.set_state(context, state, context->user_data);
-
- return r;
-}
-
-static stub_method __mmifw_method_table[] = {
- [mmifw_METHOD_register_cb] = __mmifw_method_register_cb,
- [mmifw_METHOD_deregister_cb] = __mmifw_method_deregister_cb,
- [mmifw_METHOD_get_focus] = __mmifw_method_get_focus,
- [mmifw_METHOD_set_state] = __mmifw_method_set_state,
-};
-
-static void __mmifw_on_connected(const char *sender, const char *instance, void *data)
-{
- rpc_port_stub_mmifw_context_h context;
-
- _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance);
- context = __create_mmifw_context(sender, instance);
- if (!context)
- return;
-
- if (context->callback.create)
- context->callback.create(context, context->user_data);
- __mmifw_contexts = g_list_append(__mmifw_contexts, context);
-}
-
-static void __mmifw_on_disconnected(const char *sender, const char *instance, void *data)
-{
- rpc_port_stub_mmifw_context_h context;
-
- _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance);
- context = __find_mmifw_context(instance);
- if (!context)
- return;
-
- if (context->callback.terminate)
- context->callback.terminate(context, context->user_data);
- __mmifw_contexts = g_list_remove(__mmifw_contexts, context);
- __destroy_mmifw_context(context);
-}
-
-static int __mmifw_on_received(const char *sender, const char *instance, rpc_port_h port, void *data)
-{
- rpc_port_stub_mmifw_context_h context;
- rpc_port_parcel_h parcel;
- int cmd = -1;
- int r;
-
- _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance);
- context = __find_mmifw_context(instance);
- if (!context) {
- _E("Failed to find mmifw context(%s)", instance);
- return -1;
- }
-
- context->port = port;
- r = rpc_port_parcel_create_from_port(&parcel, port);
- if (r != 0) {
- _E("Failed to create parcel from port");
- return r;
- }
-
- rpc_port_parcel_read_int32(parcel, &cmd);
- if (cmd > 1 && cmd < (sizeof(__mmifw_method_table) / sizeof(__mmifw_method_table[0]))) {
- if (__mmifw_method_table[cmd])
- r = __mmifw_method_table[cmd](port, parcel, context);
- } else {
- _E("Unknown Command(%d)", cmd);
- r = -1;
- }
-
- rpc_port_parcel_destroy(parcel);
-
- return r;
-}
-
-static int __mmifw_add_privileges(void)
-{
-
- return 0;
-}
-
-int rpc_port_stub_mmifw_register(rpc_port_stub_mmifw_callback_s *callback, void *user_data)
-{
- int r;
-
- if (__mmifw_stub) {
- _W("Already exists");
- return -1;
- }
-
- if (!callback) {
- _E("Invalid parameter");
- return -1;
- }
-
- __mmifw_callback = *callback;
- __mmifw_user_data = user_data;
- r = rpc_port_stub_create(&__mmifw_stub, "mmifw");
- if (r != 0) {
- _E("Failed to create stub handle");
- return r;
- }
-
- r = rpc_port_stub_add_received_event_cb(__mmifw_stub, __mmifw_on_received, NULL);
- if (r != 0) {
- _E("Failed to add received event callback");
- rpc_port_stub_destroy(__mmifw_stub);
- __mmifw_stub = NULL;
- return r;
- }
-
- r = rpc_port_stub_add_connected_event_cb(__mmifw_stub, __mmifw_on_connected, NULL);
- if (r != 0) {
- _E("Failed to add connected event callback");
- rpc_port_stub_destroy(__mmifw_stub);
- __mmifw_stub = NULL;
- return r;
- }
-
- r = rpc_port_stub_add_disconnected_event_cb(__mmifw_stub, __mmifw_on_disconnected, NULL);
- if (r != 0) {
- _E("Failed to add disconnected event callback");
- rpc_port_stub_destroy(__mmifw_stub);
- __mmifw_stub = NULL;
- return r;
- }
-
- r = __mmifw_add_privileges();
- if (r != 0) {
- _E("Failed to add privileges");
- rpc_port_stub_destroy(__mmifw_stub);
- __mmifw_stub = NULL;
- return r;
- }
-
- r = rpc_port_stub_listen(__mmifw_stub);
- if (r != 0) {
- _E("Failed to listen stub");
- rpc_port_stub_destroy(__mmifw_stub);
- __mmifw_stub = NULL;
- return r;
- }
-
- return 0;
-}
-
-int rpc_port_stub_mmifw_unregister(void)
-{
- int r;
-
- if (!__mmifw_stub)
- return -1;
-
- if (__mmifw_contexts) {
- g_list_free_full(__mmifw_contexts, __destroy_mmifw_context);
- __mmifw_contexts = NULL;
- }
-
- r = rpc_port_stub_destroy(__mmifw_stub);
- __mmifw_stub = NULL;
-
- return r;
-}
-
-int rpc_port_stub_mmifw_get_client_number(unsigned int *n)
-{
- if (!n) {
- _E("Invalid parameter");
- return -1;
- }
-
- if (!__mmifw_stub) {
- _E("mmifw Stub is not ready");
- return -1;
- }
-
- *n = g_list_length(__mmifw_contexts);
-
- return 0;
-}
+++ /dev/null
-/*
- * Generated by tidlc 1.4.9.
- */
-
-#pragma once
-
-#include <stdbool.h>
-#include <bundle.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct focus_event_s *rpc_port_focus_event_h;
-
-int rpc_port_focus_event_create(rpc_port_focus_event_h *h);
-
-int rpc_port_focus_event_destroy(rpc_port_focus_event_h h);
-
-int rpc_port_focus_event_clone(rpc_port_focus_event_h h, rpc_port_focus_event_h *clone);
-
-int rpc_port_focus_event_set_type(rpc_port_focus_event_h h, int type);
-
-int rpc_port_focus_event_set_timestamp(rpc_port_focus_event_h h, int timestamp);
-
-int rpc_port_focus_event_set_focus_in(rpc_port_focus_event_h h, bool focus_in);
-
-int rpc_port_focus_event_get_type(rpc_port_focus_event_h h, int *type);
-
-int rpc_port_focus_event_get_timestamp(rpc_port_focus_event_h h, int *timestamp);
-
-int rpc_port_focus_event_get_focus_in(rpc_port_focus_event_h h, bool *focus_in);
-
-typedef struct state_change_event_s *rpc_port_state_change_event_h;
-
-int rpc_port_state_change_event_create(rpc_port_state_change_event_h *h);
-
-int rpc_port_state_change_event_destroy(rpc_port_state_change_event_h h);
-
-int rpc_port_state_change_event_clone(rpc_port_state_change_event_h h, rpc_port_state_change_event_h *clone);
-
-int rpc_port_state_change_event_set_type(rpc_port_state_change_event_h h, int type);
-
-int rpc_port_state_change_event_set_timestamp(rpc_port_state_change_event_h h, int timestamp);
-
-int rpc_port_state_change_event_set_state(rpc_port_state_change_event_h h, int state);
-
-int rpc_port_state_change_event_set_old_state(rpc_port_state_change_event_h h, int old_state);
-
-int rpc_port_state_change_event_get_type(rpc_port_state_change_event_h h, int *type);
-
-int rpc_port_state_change_event_get_timestamp(rpc_port_state_change_event_h h, int *timestamp);
-
-int rpc_port_state_change_event_get_state(rpc_port_state_change_event_h h, int *state);
-
-int rpc_port_state_change_event_get_old_state(rpc_port_state_change_event_h h, int *old_state);
-
-typedef struct wakeup_event_s *rpc_port_wakeup_event_h;
-
-int rpc_port_wakeup_event_create(rpc_port_wakeup_event_h *h);
-
-int rpc_port_wakeup_event_destroy(rpc_port_wakeup_event_h h);
-
-int rpc_port_wakeup_event_clone(rpc_port_wakeup_event_h h, rpc_port_wakeup_event_h *clone);
-
-int rpc_port_wakeup_event_set_type(rpc_port_wakeup_event_h h, int type);
-
-int rpc_port_wakeup_event_set_timestamp(rpc_port_wakeup_event_h h, int timestamp);
-
-int rpc_port_wakeup_event_set_source(rpc_port_wakeup_event_h h, const char *source);
-
-int rpc_port_wakeup_event_get_type(rpc_port_wakeup_event_h h, int *type);
-
-int rpc_port_wakeup_event_get_timestamp(rpc_port_wakeup_event_h h, int *timestamp);
-
-int rpc_port_wakeup_event_get_source(rpc_port_wakeup_event_h h, char **source);
-
-typedef struct key_event_s *rpc_port_key_event_h;
-
-int rpc_port_key_event_create(rpc_port_key_event_h *h);
-
-int rpc_port_key_event_destroy(rpc_port_key_event_h h);
-
-int rpc_port_key_event_clone(rpc_port_key_event_h h, rpc_port_key_event_h *clone);
-
-int rpc_port_key_event_set_type(rpc_port_key_event_h h, int type);
-
-int rpc_port_key_event_set_timestamp(rpc_port_key_event_h h, int timestamp);
-
-int rpc_port_key_event_set_key_down(rpc_port_key_event_h h, bool key_down);
-
-int rpc_port_key_event_set_keycode(rpc_port_key_event_h h, int keycode);
-
-int rpc_port_key_event_set_keyname(rpc_port_key_event_h h, const char *keyname);
-
-int rpc_port_key_event_set_source(rpc_port_key_event_h h, const char *source);
-
-int rpc_port_key_event_get_type(rpc_port_key_event_h h, int *type);
-
-int rpc_port_key_event_get_timestamp(rpc_port_key_event_h h, int *timestamp);
-
-int rpc_port_key_event_get_key_down(rpc_port_key_event_h h, bool *key_down);
-
-int rpc_port_key_event_get_keycode(rpc_port_key_event_h h, int *keycode);
-
-int rpc_port_key_event_get_keyname(rpc_port_key_event_h h, char **keyname);
-
-int rpc_port_key_event_get_source(rpc_port_key_event_h h, char **source);
-
-typedef struct gesture_event_s *rpc_port_gesture_event_h;
-
-int rpc_port_gesture_event_create(rpc_port_gesture_event_h *h);
-
-int rpc_port_gesture_event_destroy(rpc_port_gesture_event_h h);
-
-int rpc_port_gesture_event_clone(rpc_port_gesture_event_h h, rpc_port_gesture_event_h *clone);
-
-int rpc_port_gesture_event_set_type(rpc_port_gesture_event_h h, int type);
-
-int rpc_port_gesture_event_set_timestamp(rpc_port_gesture_event_h h, int timestamp);
-
-int rpc_port_gesture_event_set_source(rpc_port_gesture_event_h h, const char *source);
-
-int rpc_port_gesture_event_get_type(rpc_port_gesture_event_h h, int *type);
-
-int rpc_port_gesture_event_get_timestamp(rpc_port_gesture_event_h h, int *timestamp);
-
-int rpc_port_gesture_event_get_source(rpc_port_gesture_event_h h, char **source);
-
-typedef struct voice_event_s *rpc_port_voice_event_h;
-
-int rpc_port_voice_event_create(rpc_port_voice_event_h *h);
-
-int rpc_port_voice_event_destroy(rpc_port_voice_event_h h);
-
-int rpc_port_voice_event_clone(rpc_port_voice_event_h h, rpc_port_voice_event_h *clone);
-
-int rpc_port_voice_event_set_type(rpc_port_voice_event_h h, int type);
-
-int rpc_port_voice_event_set_timestamp(rpc_port_voice_event_h h, int timestamp);
-
-int rpc_port_voice_event_set_source(rpc_port_voice_event_h h, const char *source);
-
-int rpc_port_voice_event_get_type(rpc_port_voice_event_h h, int *type);
-
-int rpc_port_voice_event_get_timestamp(rpc_port_voice_event_h h, int *timestamp);
-
-int rpc_port_voice_event_get_source(rpc_port_voice_event_h h, char **source);
-
-typedef struct action_event_s *rpc_port_action_event_h;
-
-int rpc_port_action_event_create(rpc_port_action_event_h *h);
-
-int rpc_port_action_event_destroy(rpc_port_action_event_h h);
-
-int rpc_port_action_event_clone(rpc_port_action_event_h h, rpc_port_action_event_h *clone);
-
-int rpc_port_action_event_set_type(rpc_port_action_event_h h, int type);
-
-int rpc_port_action_event_set_timestamp(rpc_port_action_event_h h, int timestamp);
-
-int rpc_port_action_event_set_cmd(rpc_port_action_event_h h, const char *cmd);
-
-int rpc_port_action_event_set_args(rpc_port_action_event_h h, char **args, int args_size);
-
-int rpc_port_action_event_set_nargs(rpc_port_action_event_h h, int nargs);
-
-int rpc_port_action_event_set_source(rpc_port_action_event_h h, const char *source);
-
-int rpc_port_action_event_get_type(rpc_port_action_event_h h, int *type);
-
-int rpc_port_action_event_get_timestamp(rpc_port_action_event_h h, int *timestamp);
-
-int rpc_port_action_event_get_cmd(rpc_port_action_event_h h, char **cmd);
-
-int rpc_port_action_event_get_args(rpc_port_action_event_h h, char ***args, int *args_size);
-
-int rpc_port_action_event_get_nargs(rpc_port_action_event_h h, int *nargs);
-
-int rpc_port_action_event_get_source(rpc_port_action_event_h h, char **source);
-
-typedef struct feedback_event_s *rpc_port_feedback_event_h;
-
-int rpc_port_feedback_event_create(rpc_port_feedback_event_h *h);
-
-int rpc_port_feedback_event_destroy(rpc_port_feedback_event_h h);
-
-int rpc_port_feedback_event_clone(rpc_port_feedback_event_h h, rpc_port_feedback_event_h *clone);
-
-int rpc_port_feedback_event_set_type(rpc_port_feedback_event_h h, int type);
-
-int rpc_port_feedback_event_set_timestamp(rpc_port_feedback_event_h h, int timestamp);
-
-int rpc_port_feedback_event_set_feedback(rpc_port_feedback_event_h h, const char *feedback);
-
-int rpc_port_feedback_event_set_comment(rpc_port_feedback_event_h h, const char *comment);
-
-int rpc_port_feedback_event_get_type(rpc_port_feedback_event_h h, int *type);
-
-int rpc_port_feedback_event_get_timestamp(rpc_port_feedback_event_h h, int *timestamp);
-
-int rpc_port_feedback_event_get_feedback(rpc_port_feedback_event_h h, char **feedback);
-
-int rpc_port_feedback_event_get_comment(rpc_port_feedback_event_h h, char **comment);
-
-typedef struct array_string_s *rpc_port_array_string_h;
-
-int rpc_port_array_string_create(rpc_port_array_string_h *h);
-
-int rpc_port_array_string_destroy(rpc_port_array_string_h h);
-
-int rpc_port_array_string_clone(rpc_port_array_string_h h, rpc_port_array_string_h *clone);
-
-int rpc_port_array_string_set_array_strings(rpc_port_array_string_h h, char **array_strings, int array_strings_size);
-
-int rpc_port_array_string_get_array_strings(rpc_port_array_string_h h, char ***array_strings, int *array_strings_size);
-
-typedef struct mmifw_context_s* rpc_port_stub_mmifw_context_h;
-
-int rpc_port_stub_mmifw_context_set_tag(rpc_port_stub_mmifw_context_h ctx, void *tag);
-
-int rpc_port_stub_mmifw_context_get_tag(rpc_port_stub_mmifw_context_h ctx, void **tag);
-
-int rpc_port_stub_mmifw_context_get_sender(rpc_port_stub_mmifw_context_h ctx, char **sender);
-
-typedef struct mmifw_focus_event_cb_s *rpc_port_mmifw_focus_event_cb_h;
-
-int rpc_port_mmifw_focus_event_cb_destroy(rpc_port_mmifw_focus_event_cb_h h);
-
-int rpc_port_mmifw_focus_event_cb_clone(rpc_port_mmifw_focus_event_cb_h h, rpc_port_mmifw_focus_event_cb_h *clone);
-
-int rpc_port_mmifw_focus_event_cb_invoke(rpc_port_mmifw_focus_event_cb_h h, rpc_port_focus_event_h args);
-
-typedef struct mmifw_state_change_event_cb_s *rpc_port_mmifw_state_change_event_cb_h;
-
-int rpc_port_mmifw_state_change_event_cb_destroy(rpc_port_mmifw_state_change_event_cb_h h);
-
-int rpc_port_mmifw_state_change_event_cb_clone(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_mmifw_state_change_event_cb_h *clone);
-
-int rpc_port_mmifw_state_change_event_cb_invoke(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_state_change_event_h args);
-
-typedef struct mmifw_wakeup_event_cb_s *rpc_port_mmifw_wakeup_event_cb_h;
-
-int rpc_port_mmifw_wakeup_event_cb_destroy(rpc_port_mmifw_wakeup_event_cb_h h);
-
-int rpc_port_mmifw_wakeup_event_cb_clone(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_mmifw_wakeup_event_cb_h *clone);
-
-int rpc_port_mmifw_wakeup_event_cb_invoke(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_wakeup_event_h args);
-
-typedef struct mmifw_key_event_cb_s *rpc_port_mmifw_key_event_cb_h;
-
-int rpc_port_mmifw_key_event_cb_destroy(rpc_port_mmifw_key_event_cb_h h);
-
-int rpc_port_mmifw_key_event_cb_clone(rpc_port_mmifw_key_event_cb_h h, rpc_port_mmifw_key_event_cb_h *clone);
-
-int rpc_port_mmifw_key_event_cb_invoke(rpc_port_mmifw_key_event_cb_h h, rpc_port_key_event_h args);
-
-typedef struct mmifw_gesture_event_cb_s *rpc_port_mmifw_gesture_event_cb_h;
-
-int rpc_port_mmifw_gesture_event_cb_destroy(rpc_port_mmifw_gesture_event_cb_h h);
-
-int rpc_port_mmifw_gesture_event_cb_clone(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_mmifw_gesture_event_cb_h *clone);
-
-int rpc_port_mmifw_gesture_event_cb_invoke(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_gesture_event_h args);
-
-typedef struct mmifw_voice_event_cb_s *rpc_port_mmifw_voice_event_cb_h;
-
-int rpc_port_mmifw_voice_event_cb_destroy(rpc_port_mmifw_voice_event_cb_h h);
-
-int rpc_port_mmifw_voice_event_cb_clone(rpc_port_mmifw_voice_event_cb_h h, rpc_port_mmifw_voice_event_cb_h *clone);
-
-int rpc_port_mmifw_voice_event_cb_invoke(rpc_port_mmifw_voice_event_cb_h h, rpc_port_voice_event_h args);
-
-typedef struct mmifw_action_event_cb_s *rpc_port_mmifw_action_event_cb_h;
-
-int rpc_port_mmifw_action_event_cb_destroy(rpc_port_mmifw_action_event_cb_h h);
-
-int rpc_port_mmifw_action_event_cb_clone(rpc_port_mmifw_action_event_cb_h h, rpc_port_mmifw_action_event_cb_h *clone);
-
-int rpc_port_mmifw_action_event_cb_invoke(rpc_port_mmifw_action_event_cb_h h, rpc_port_action_event_h args);
-
-typedef struct mmifw_feedback_event_cb_s *rpc_port_mmifw_feedback_event_cb_h;
-
-int rpc_port_mmifw_feedback_event_cb_destroy(rpc_port_mmifw_feedback_event_cb_h h);
-
-int rpc_port_mmifw_feedback_event_cb_clone(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_mmifw_feedback_event_cb_h *clone);
-
-int rpc_port_mmifw_feedback_event_cb_invoke(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_feedback_event_h args);
-
-typedef struct {
- void (*create)(rpc_port_stub_mmifw_context_h context, void *user_data);
- void (*terminate)(rpc_port_stub_mmifw_context_h context, void *user_data);
-
- int (*register_cb)(rpc_port_stub_mmifw_context_h context, rpc_port_mmifw_focus_event_cb_h focus_cb, rpc_port_mmifw_state_change_event_cb_h state_cb, rpc_port_mmifw_wakeup_event_cb_h wakeup_cb, rpc_port_mmifw_key_event_cb_h key_cb, rpc_port_mmifw_gesture_event_cb_h gesture_cb, rpc_port_mmifw_voice_event_cb_h voice_cb, rpc_port_mmifw_action_event_cb_h action_cb, rpc_port_mmifw_feedback_event_cb_h feedback_cb, void *user_data);
- void (*deregister_cb)(rpc_port_stub_mmifw_context_h context, void *user_data);
- void (*get_focus)(rpc_port_stub_mmifw_context_h context, void *user_data);
- void (*set_state)(rpc_port_stub_mmifw_context_h context, int state, void *user_data);
-} rpc_port_stub_mmifw_callback_s;
-
-int rpc_port_stub_mmifw_register(rpc_port_stub_mmifw_callback_s *callback, void *user_data);
-
-int rpc_port_stub_mmifw_unregister(void);
-
-int rpc_port_stub_mmifw_get_client_number(unsigned int *n);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-{
- "IURule" : [
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressMicButton"
- }
- ],
- "MMIStatus" : "Initiation",
- "OutputIntent": {
- "Action" : "WakeUp"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "ShowPalm"
- }
- ],
- "MMIStatus": "Initiation",
- "OutputIntent": {
- "Action" : "WakeUp"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressUpButton"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveUp"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressDownButton"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveDown"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressRightButton"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveRight"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressLeftButton"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveLeft"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "MoveUp"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveUp"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "MoveDown"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveDown"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "MoveRight"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveRight"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "MoveLeft"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveLeft"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "HandUp"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveUp"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "HandDown"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveDown"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "HandRight"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveRight"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "HandLeft"
- }
- ],
- "MMIStatus": "Exploration",
- "OutputIntent": {
- "Action" : "MoveLeft"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressOkButton"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Execute"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Execute"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Execute"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Play"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Play"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Yes"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Yes"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Yes"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Execute"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Yes"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Execute"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "HandPush"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Execute"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressOkButton"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Execute"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressBackButton"
- }
- ],
- "MMIStatus": "Execution",
- "OutputIntent": {
- "Action" : "Cancel"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressBackButton"
- }
- ],
- "MMIStatus": "Initiation",
- "OutputIntent": {
- "Action" : "Cancel"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressBackButton"
- }
- ],
- "MMIStatus": "Feedback",
- "OutputIntent": {
- "Action" : "Cancel"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Cancel"
- }
- ],
- "MMIStatus": "Feedback",
- "OutputIntent": {
- "Action" : "Cancel"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Back"
- }
- ],
- "MMIStatus": "Feedback",
- "OutputIntent": {
- "Action" : "Cancel"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "WaveHandX"
- }
- ],
- "MMIStatus": "Feedback",
- "OutputIntent": {
- "Action" : "Cancel"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Vision",
- "Action" : "OutOfVision"
- }
- ],
- "MMIStatus": "Observation",
- "OutputIntent": {
- "Action" : "Pause"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "KeyInput",
- "Action" : "PressBackButton"
- }
- ],
- "MMIStatus": "Termination",
- "OutputIntent": {
- "Action" : "Exit"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Exit"
- }
- ],
- "MMIStatus": "Termination",
- "OutputIntent": {
- "Action" : "Exit"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Stop"
- }
- ],
- "MMIStatus": "Termination",
- "OutputIntent": {
- "Action" : "Stop"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Voice",
- "Action" : "Terminate"
- }
- ],
- "MMIStatus": "Termination",
- "OutputIntent": {
- "Action" : "Terminate"
- }
- },
- {
- "InputIntents" : [
- {
- "Modality" : "Gesture",
- "Action" : "FlipPalm"
- }
- ],
- "MMIStatus": "Termination",
- "OutputIntent": {
- "Action" : "Exit"
- }
- }
- ]
-}
-
+++ /dev/null
-/*
- * 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 <unistd.h>
-#include <string>
-
-#include "input_intent.h"
-
-using namespace std;
-
-InputIntent::InputIntent()
-{
-
-}
-
-InputIntent::~InputIntent()
-{
-
-}
-
-void InputIntent::set_modality(string modality)
-{
- this->modality = modality;
-}
-
-string InputIntent::get_modality()
-{
- return modality;
-}
-
-void InputIntent::set_action(string action)
-{
- this->action = action;
-}
-
-string InputIntent::get_action()
-{
- return action;
-}
-
-void InputIntent::set_input_time(int time)
-{
- input_time = time;
-}
-
-int InputIntent::get_input_time()
-{
- return input_time;
-}
-
-void InputIntent::set_input_duration(int duration)
-{
- input_duration = duration;
-}
-
-int InputIntent::get_input_duration()
-{
- return input_duration;
-}
-
-bool InputIntent::match_intent(const InputIntent &other)
-{
- if (this->modality == other.modality &&
- this->action == other.action)
- return true;
-
- return false;
-}
+++ /dev/null
-/*
- * 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 __INPUT_INTENT_H__
-#define __INPUT_INTENT_H__
-
-#include <unistd.h>
-#include <string>
-
-using namespace std;
-
-class InputIntent {
-public:
- InputIntent();
- virtual ~InputIntent();
-
- void set_modality(string modality);
- string get_modality();
-
- void set_action(string modality);
- string get_action();
-
- void set_input_time(int time);
- int get_input_time();
-
- void set_input_duration(int duration);
- int get_input_duration();
-
- bool match_intent(const InputIntent &other);
-
-private:
- string modality;
- string action;
- int input_time = 0;
- int input_duration = 0;
-};
-
-#endif /* __INPUT_INTENT_H__ */
+++ /dev/null
-/*
- * 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 <unistd.h>
-#include <string>
-#include <json-glib/json-glib.h>
-#include <unordered_map>
-
-#include "mmi_iu_log.h"
-#include "mmi_iu_event.h"
-#include "intent_understanding_engine.h"
-#include "input_intent.h"
-#include "output_intent.h"
-#include "mmi-common.h"
-
-using namespace std;
-
-static unordered_map<string, string> key_action_map
- = { { "UP", "Up" },
- { "DOWN", "Down" },
- { "LEFT", "Left" },
- { "RIGHT", "Right" },
- { "RETURN", "Ok" },
- { "XF86Back", "Back" },
- { "I69", "Back" },
- };
-
-static unordered_map<int, string> voice_action_map
- = { { MMI_EVENT_VOICE_TYPE_UP, "MoveUp" },
- { MMI_EVENT_VOICE_TYPE_DOWN, "MoveDown" },
- { MMI_EVENT_VOICE_TYPE_LEFT, "MoveLeft" },
- { MMI_EVENT_VOICE_TYPE_RIGHT, "MoveRight" },
- { MMI_EVENT_VOICE_TYPE_CANCEL, "Cancel" },
- { MMI_EVENT_VOICE_TYPE_PLAY, "Play" },
- { MMI_EVENT_VOICE_TYPE_YES, "Yes" },
- { MMI_EVENT_VOICE_TYPE_EXECUTE, "Execute" },
- { MMI_EVENT_VOICE_TYPE_BACK, "Back" },
- { MMI_EVENT_VOICE_TYPE_EXIT, "Exit" },
- { MMI_EVENT_VOICE_TYPE_STOP, "Stop" },
- { MMI_EVENT_VOICE_TYPE_TERMINATE, "Terminate" },
- };
-
-static unordered_map<int, string> gesture_action_map
- = { { MMI_EVENT_GESTURE_TYPE_SWIPE_UP, "HandUp" },
- { MMI_EVENT_GESTURE_TYPE_SWIPE_DOWN, "HandDown" },
- { MMI_EVENT_GESTURE_TYPE_SWIPE_LEFT, "HandLeft" },
- { MMI_EVENT_GESTURE_TYPE_SWIPE_RIGHT, "HandRight" },
- { MMI_EVENT_GESTURE_TYPE_PUSH, "HandPush" },
- //{ MMI_EVENT_GESTURE_TYPE_WAVEHANDX, "WaveHandX" },
- //{ MMI_EVENT_GESTURE_TYPE_FLIPPALM, "FlipPalm" },
- //{ MMI_EVENT_GESTURE_TYPE_SHOWPALM, "ShowPalm" }
- };
-
-static unordered_map<int, string> vision_action_map
- = { { MMI_EVENT_VISION_TYPE_USER_MOVE_AWAY, "OutOfVision" }
- };
-
-IntentUnderstandingEngine::IntentUnderstandingEngine()
-{
-}
-
-IntentUnderstandingEngine::~IntentUnderstandingEngine()
-{
-
-}
-
-void IntentUnderstandingEngine::set_app_state(const char *state)
-{
- if (string(state) == "Initiation")
- application_state = MMI_STATE_INITIATION;
- else if (string(state) == "Exploration")
- application_state = MMI_STATE_EXPLORATION;
- else if (string(state) == "Execution")
- application_state = MMI_STATE_EXECUTION;
- else if (string(state) == "Feedback")
- application_state = MMI_STATE_FEEDBACK;
- else if (string(state) == "Observation")
- application_state = MMI_STATE_OBSERVATION;
- else if (string(state) == "Termination")
- application_state = MMI_STATE_TERMINATION;
-}
-
-void IntentUnderstandingEngine::set_app_state(mmi_state appstate)
-{
- application_state = appstate;
-}
-
-mmi_state IntentUnderstandingEngine::get_app_state()
-{
- return application_state;
-}
-
-bool IntentUnderstandingEngine::parse_json_data(JsonParser *parser)
-{
- JsonNode *root = NULL;
-
- JsonObject *root_obj = NULL;
- JsonObject *output_intent_obj = NULL;
- JsonObject *input_intent_obj = NULL;
- JsonObject *iu_rule_arr_obj = NULL;
-
- JsonArray *input_intent_array = NULL;
- JsonArray *iu_rule_array = NULL;
-
- const gchar *status = NULL;
- const gchar *output_action = NULL;
- const gchar *modality = NULL;
- const gchar *action = NULL;
-
- int arr_len = 0;
-
- root = json_parser_get_root(parser);
- if (root == NULL) {
- _E("failed to get root");
- return false;
- }
-
- root_obj = json_node_get_object(root);
- if (root_obj == NULL) {
- _E("failed to get object");
- return false;
- }
-
- iu_rule_array = json_object_get_array_member(root_obj, "IURule");
- if (iu_rule_array) {
- iu_rule_list.clear();
-
- arr_len = json_array_get_length(iu_rule_array);
-
- for (int i = 0; i < arr_len; i++) {
- IntentUnderstandingRule iu_rule;
- iu_rule_arr_obj = json_array_get_object_element(iu_rule_array, i);
- input_intent_array = json_object_get_array_member(iu_rule_arr_obj, "InputIntents");
-
- if (input_intent_array) {
- int input_intent_list_len = json_array_get_length(input_intent_array);
- for (int j = 0; j < input_intent_list_len; j++) {
- input_intent_obj = json_array_get_object_element(input_intent_array, j);
-
- modality = json_object_get_string_member(input_intent_obj, "Modality");
- action = json_object_get_string_member(input_intent_obj, "Action");
-
- InputIntent intent;
- intent.set_modality(string(modality));
- intent.set_action(string(action));
-
- iu_rule.add_input_intent(intent);
- }
- }
-
- status = json_object_get_string_member(iu_rule_arr_obj, "MMIStatus");
- iu_rule.set_app_state(status);
-
- output_intent_obj = json_object_get_object_member(iu_rule_arr_obj, "OutputIntent");
- output_action = json_object_get_string_member(output_intent_obj, "Action");
-
- OutputIntent oi;
- oi.set_action(output_action);
-
- iu_rule.set_output_intent(oi);
-
- iu_rule_list.push_back(iu_rule);
- }
- }
-
- return true;
-}
-
-bool IntentUnderstandingEngine::set_rule_json_file(const char *json_file_path)
-{
- if (!json_file_path)
- return false;
-
- JsonParser *parser = json_parser_new();
- GError *err_msg = NULL;
- bool ret = true;
-
- json_parser_load_from_file(parser, (char *)json_file_path, &err_msg);
- if (err_msg) {
- _E("failed to load json file. error message: %s", err_msg->message);
- ret = false;
- goto cleanup;
- }
-
- ret = parse_json_data(parser);
-
-cleanup:
- if (err_msg)
- g_error_free(err_msg);
-
- if (parser)
- g_object_unref(parser);
-
- return ret;
-}
-
-bool IntentUnderstandingEngine::set_rule_json_data(const char *json_data)
-{
- if (!json_data)
- return false;
-
- JsonParser *parser = json_parser_new();
- GError *err_msg = NULL;
- bool ret = true;
-
- json_parser_load_from_data(parser, (char *)json_data, -1, &err_msg);
- if (err_msg) {
- _E("failed to load json file. error message: %s", err_msg->message);
- ret = false;
- goto cleanup;
- }
-
- parse_json_data(parser);
-
-cleanup:
- if (err_msg)
- g_error_free(err_msg);
-
- if (parser)
- g_object_unref(parser);
-
- return ret;
-}
-
-bool IntentUnderstandingEngine::set_input_intent_json_data(const char *json_data)
-{
- JsonParser *parser = json_parser_new();
- GError *err_msg = NULL;
- JsonNode *root = NULL;
- JsonObject *root_obj = NULL;
- JsonArray *input_intent_array = NULL;
- JsonObject *arr_obj;
- const gchar *modality_type;
- const gchar *action;
-
- bool ret = true;
- int arr_len = 0;
- int input_time = 0, input_duration = 0;
-
- json_parser_load_from_data(parser, (char *)json_data, -1, &err_msg);
- if (err_msg) {
- _E("failed to load json file. error message: %s", err_msg->message);
- ret = false;
- goto cleanup;
- }
-
- root = json_parser_get_root(parser);
- if (root == NULL) {
- _E("failed to get root");
- ret = false;
- goto cleanup;
- }
-
- root_obj = json_node_get_object(root);
- if (root_obj == NULL) {
- _E("failed to get object");
- ret = false;
- goto cleanup;
- }
-
- input_intent_array = json_object_get_array_member(root_obj, "InputIntents");
- if (input_intent_array) {
- input_intent_list.clear();
-
- arr_len = json_array_get_length(input_intent_array);
-
- for (int i = 0; i < arr_len; i++) {
- input_time = 0, input_duration = 0;
- arr_obj = json_array_get_object_element(input_intent_array, i);
- modality_type = json_object_get_string_member(arr_obj, "Modality");
- action = json_object_get_string_member(arr_obj, "Action");
-
- if (json_object_has_member(arr_obj, "Time"))
- input_time = json_object_get_int_member(arr_obj, "Time");
-
- if (json_object_has_member(arr_obj, "Duration"))
- input_duration = json_object_get_int_member(arr_obj, "Duration");
-
- _I("### modality type: %s, action: %s, time: %d, duration: %d ###\n", modality_type, action, input_time, input_duration);
-
- InputIntent intent;
- intent.set_modality(string(modality_type));
- intent.set_action(string(action));
- intent.set_input_time(input_time);
- intent.set_input_duration(input_duration);
-
- input_intent_list.push_back(intent);
- }
- }
-
-cleanup:
- if (err_msg)
- g_error_free(err_msg);
-
- if (parser)
- g_object_unref(parser);
-
- return ret;
-}
-
-string IntentUnderstandingEngine::convert_key_event(int type, char *keyname)
-{
- string action;
- string button_name;
-
- if (!keyname)
- return string("");
-
- button_name = key_action_map[string(keyname)];
- if (!button_name.empty()) {
- action = "Press" + button_name + "Button";
- }
-
- return action;
-}
-
-string IntentUnderstandingEngine::convert_voice_event(int type)
-{
- string action = voice_action_map[type];
- return action;
-}
-
-string IntentUnderstandingEngine::convert_gesture_event(int type)
-{
- string action = gesture_action_map[type];
- return action;
-}
-
-string IntentUnderstandingEngine::convert_vision_event(int type)
-{
- string action = vision_action_map[type];
- return action;
-}
-
-bool IntentUnderstandingEngine::set_input_event(int type, void *event)
-{
- InputIntent intent;
- string modality_type;
- string action;
-
- mmi_provider_event_key *key_event;
- mmi_provider_event_voice *voice_event;
- mmi_provider_event_gesture *gesture_event;
- mmi_provider_event_vision *vision_event;
-
- if (type == MMI_PROVIDER_EVENT_KEY) {
- modality_type = "KeyInput";
- key_event = (mmi_provider_event_key *)event;
- action = convert_key_event(type, key_event->keyname);
- }
- else if (type == MMI_PROVIDER_EVENT_VOICE) {
- modality_type = "Voice";
- voice_event = (mmi_provider_event_voice *)event;
- action = convert_voice_event(voice_event->type);
- }
- else if (type == MMI_PROVIDER_EVENT_GESTURE) {
- modality_type = "Gesture";
- gesture_event = (mmi_provider_event_gesture *)event;
- action = convert_gesture_event(gesture_event->type);
- }
- else if (type == MMI_PROVIDER_EVENT_VISION) {
- modality_type = "Vision";
- vision_event = (mmi_provider_event_vision *)event;
- action = convert_vision_event(vision_event->type);
- }
-
- intent.set_modality(modality_type);
- intent.set_action(action);
-
- input_intent_list.push_back(intent);
-
- return !action.empty();
-}
-
-string IntentUnderstandingEngine::get_output_intent_json_data()
-{
- OutputIntent oi;
- string output_json_text;
-
- oi.set_action(get_output_intent_action());
-
- output_json_text = oi.get_output_intent_text();
-
- return output_json_text;
-}
-
-bool IntentUnderstandingEngine::match_input_intent(IntentUnderstandingRule iu_rule)
-{
- unsigned int input_intent_size = input_intent_list.size();
- unsigned int match_count = 0;
-
- if (iu_rule.get_input_intent_size() != input_intent_size)
- return false;
-
- for (InputIntent it : input_intent_list)
- {
- if (iu_rule.find_input_intent(it))
- {
- match_count++;
- break;
- }
- }
-
- return input_intent_size == match_count ? true : false;
-}
-
-string IntentUnderstandingEngine::get_output_intent_action()
-{
- if (iu_rule_list.empty()) {
- _E("No intent understanding rule data");
- return string("");
- }
-
- for (IntentUnderstandingRule iu_rule : iu_rule_list)
- {
- if (match_input_intent(iu_rule) && iu_rule.get_app_state() == application_state) {
- string output_action = iu_rule.get_output_intent().get_action();
- _D("Output action : %s\n", output_action.c_str());
- return output_action;
- }
- }
-
- return string("");
-}
-
-void IntentUnderstandingEngine::init_input_buffer()
-{
- input_intent_list.clear();
-}
+++ /dev/null
-/*
- * 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 __INTENT_UNDERSTANDING_ENGINE__
-#define __INTENT_UNDERSTANDING_ENGINE__
-
-#include <unistd.h>
-#include <string>
-#include <list>
-
-#include "input_intent.h"
-#include "mmi-common.h"
-#include "iu_rule.h"
-
-using namespace std;
-
-class IntentUnderstandingEngine {
-public:
- IntentUnderstandingEngine();
- virtual ~IntentUnderstandingEngine();
-
- bool set_rule_json_file(const char *json_file_path);
- bool set_rule_json_data(const char *json_data);
-
- bool set_input_intent_json_data(const char *json_data);
- bool set_input_event(int type, void *event);
-
- string get_output_intent_json_data();
- string get_output_intent_action();
-
- void set_app_state(mmi_state appstate);
- void set_app_state(const char *state);
-
- void init_input_buffer();
-
- mmi_state get_app_state();
-
-private:
- bool match_input_intent(IntentUnderstandingRule iu_rule);
-
- bool parse_json_data(JsonParser *parser);
-
- string convert_key_event(int type, char *keyname);
- string convert_voice_event(int type);
- string convert_gesture_event(int type);
- string convert_vision_event(int type);
-
- list<IntentUnderstandingRule> iu_rule_list;
- list<InputIntent> input_intent_list;
-
- mmi_state application_state = MMI_STATE_INITIATION;
-};
-
-#endif /* __INTENT_UNDERSTANDING_ENGINE__ */
+++ /dev/null
-/*
- * 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 <unistd.h>
-#include <string>
-
-#include "input_intent.h"
-#include "iu_rule.h"
-
-using namespace std;
-
-IntentUnderstandingRule::IntentUnderstandingRule()
-{
-
-}
-
-IntentUnderstandingRule::~IntentUnderstandingRule()
-{
-
-}
-
-void IntentUnderstandingRule::set_app_state(const char* state)
-{
- if (string(state) == "Initiation")
- app_state = MMI_STATE_INITIATION;
- else if (string(state) == "Exploration")
- app_state = MMI_STATE_EXPLORATION;
- else if (string(state) == "Execution")
- app_state = MMI_STATE_EXECUTION;
- else if (string(state) == "Feedback")
- app_state = MMI_STATE_FEEDBACK;
- else if (string(state) == "Observation")
- app_state = MMI_STATE_OBSERVATION;
- else if (string(state) == "Termination")
- app_state = MMI_STATE_TERMINATION;
-}
-
-mmi_state IntentUnderstandingRule::get_app_state()
-{
- return app_state;
-}
-
-void IntentUnderstandingRule::set_output_intent(const OutputIntent &output_intent)
-{
- this->output_intent = output_intent;
-}
-
-OutputIntent IntentUnderstandingRule::get_output_intent()
-{
- return this->output_intent;
-}
-
-void IntentUnderstandingRule::add_input_intent(const InputIntent &intent)
-{
- input_intent_list.push_back(intent);
-}
-
-bool IntentUnderstandingRule::find_input_intent(InputIntent intent)
-{
- for (InputIntent it : input_intent_list)
- {
- if (it.match_intent(intent))
- {
- return true;
- }
- }
-
- return false;
-}
-
-unsigned int IntentUnderstandingRule::get_input_intent_size()
-{
- return input_intent_list.size();
-}
+++ /dev/null
-/*
- * 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 __IU_RULE__
-#define __IU_RULE__
-
-#include <unistd.h>
-#include <string>
-#include <list>
-
-#include "input_intent.h"
-#include "output_intent.h"
-#include "mmi-common.h"
-
-using namespace std;
-
-class IntentUnderstandingRule {
-public:
- IntentUnderstandingRule();
- virtual ~IntentUnderstandingRule();
-
- void set_app_state(const char* state);
- mmi_state get_app_state();
-
- void set_output_intent(const OutputIntent &output_intent);
- OutputIntent get_output_intent();
-
- void add_input_intent(const InputIntent &intent);
- bool find_input_intent(InputIntent intent);
- unsigned int get_input_intent_size();
-
-private:
- list<InputIntent> input_intent_list;
-
- OutputIntent output_intent;
-
- mmi_state app_state = MMI_STATE_NONE;
-};
-
-#endif /* __IU_RULE__ */
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include <string>
-#include <list>
-#include <json-glib/json-glib.h>
-
-#include "mmi_iu.h"
-#include "mmi_iu_log.h"
-#include "output_intent.h"
-#include "input_intent.h"
-#include "intent_understanding_engine.h"
-#include "mmi-common.h"
-
-using namespace std;
-
-static mmi_state g_app_state = MMI_STATE_INITIATION;
-static mmi_iu_output_intent_received_cb iu_output_intent_received_callback = NULL;
-static void *iu_output_intent_user_data = NULL;
-
-static bool initialized = false;
-
-static string g_system_app_id;
-static string g_focus_app_id;
-
-static IntentUnderstandingEngine *iu_engine = NULL;
-
-#define DEFAULT_RULE_FILE "/usr/share/iu/default_rule.json"
-
-static void init()
-{
- initialized = true;
-
- g_app_state = MMI_STATE_INITIATION;
-
- iu_output_intent_received_callback = NULL;
-
- iu_output_intent_user_data = NULL;
-
- g_system_app_id = "";
- g_focus_app_id = "";
-}
-
-EXPORT_API int mmi_iu_init()
-{
- init();
-
- iu_engine = new IntentUnderstandingEngine();
-
- if (!iu_engine)
- return MMI_IU_ERROR_OUT_OF_MEMORY;
-
- int ret = mmi_iu_set_rule_filepath(DEFAULT_RULE_FILE);
-
- return ret;
-}
-
-EXPORT_API int mmi_iu_shutdown()
-{
- init();
-
- if (iu_engine) {
- delete iu_engine;
- iu_engine = NULL;
- }
-
- if (!initialized)
- return MMI_IU_ERROR_NOT_INITIALIZED;
-
- initialized = false;
-
- return MMI_IU_ERROR_NONE;
-}
-
-EXPORT_API int mmi_iu_set_rule_filepath(const char *filepath)
-{
- if (!initialized || !iu_engine)
- return MMI_IU_ERROR_NOT_INITIALIZED;
-
- if (!iu_engine->set_rule_json_file(filepath)) {
- _W("Failed to set rule data");
- return MMI_IU_ERROR_OPERATION_FAILED;
- }
-
- return MMI_IU_ERROR_NONE;
-}
-
-static void fire_output_intent_callback(const char *app_id, const char *output_intent)
-{
- if (iu_output_intent_received_callback)
- iu_output_intent_received_callback(app_id, output_intent, iu_output_intent_user_data);
- else
- _D("No output intent receive callback\n");
-}
-
-static void fire_output_intent(const char *app_id, const char *json_output_intent)
-{
- if (g_system_app_id == string(app_id)) {
- fire_output_intent_callback(app_id, json_output_intent);
- }
- else {
- if (g_focus_app_id.empty()) {
- fire_output_intent_callback(app_id, json_output_intent);
- }
- else {
- if (g_focus_app_id == string(app_id)) {
- fire_output_intent_callback(app_id, json_output_intent);
- }
- else {
- _I("different focus app\n");
- }
- }
- }
-}
-
-EXPORT_API int mmi_iu_feed_intent(const char *app_id, const char *json_data)
-{
- if (!app_id || !json_data) {
- _W("[ERROR] Invalid parameter");
- return MMI_IU_ERROR_INVALID_PARAMETER;
- }
-
- if (!initialized) {
- _W("[ERROR] Not initialized");
- return MMI_IU_ERROR_NOT_INITIALIZED;
- }
-
- if (iu_engine)
- if (!iu_engine->set_input_intent_json_data(json_data))
- return MMI_IU_ERROR_OPERATION_FAILED;
-
- _I("app state: %d\n", g_app_state);
-
- string json_output_intent;
- if (iu_engine) {
- iu_engine->set_app_state(g_app_state);
-
- json_output_intent = iu_engine->get_output_intent_json_data();
- _I("output intent : %s\n", json_output_intent.c_str());
- }
-
- if (json_output_intent.empty())
- return MMI_IU_ERROR_OPERATION_FAILED;
-
- fire_output_intent(app_id, json_output_intent.c_str());
-
- return MMI_IU_ERROR_NONE;
-}
-
-EXPORT_API int mmi_iu_feed_input_event(const char *app_id, int type, void *event)
-{
- if (!app_id || !event) {
- _W("[ERROR] Invalid parameter");
- return MMI_IU_ERROR_INVALID_PARAMETER;
- }
-
- if (!initialized) {
- _W("[ERROR] Not initialized");
- return MMI_IU_ERROR_NOT_INITIALIZED;
- }
-
- if (iu_engine)
- if (!iu_engine->set_input_event(type, event)) {
- LOGE("Failed to set input event");
- return MMI_IU_ERROR_OPERATION_FAILED;
- }
-
- _I("app state: %d\n", g_app_state);
-
- string json_output_intent;
- if (iu_engine) {
- iu_engine->set_app_state(g_app_state);
-
- json_output_intent = iu_engine->get_output_intent_json_data();
- _I("output intent : %s\n", json_output_intent.c_str());
- }
-
- if (json_output_intent.empty())
- return MMI_IU_ERROR_OPERATION_FAILED;
-
- fire_output_intent(app_id, json_output_intent.c_str());
-
- if (iu_engine)
- iu_engine->init_input_buffer();
-
- return MMI_IU_ERROR_NONE;
-}
-
-EXPORT_API int mmi_iu_set_output_intent_received_callback(mmi_iu_output_intent_received_cb callback, void *user_data)
-{
- if (!callback) {
- _W("[ERROR] Invalid parameter");
- return MMI_IU_ERROR_INVALID_PARAMETER;
- }
-
- if (!initialized) {
- _W("[ERROR] Not initialized");
- return MMI_IU_ERROR_NOT_INITIALIZED;
- }
-
- iu_output_intent_received_callback = callback;
- iu_output_intent_user_data = user_data;
-
- return MMI_IU_ERROR_NONE;
-}
-
-EXPORT_API int mmi_iu_unset_output_intent_received_callback()
-{
- if (!initialized) {
- _W("[ERROR] Not initialized");
- return MMI_IU_ERROR_NOT_INITIALIZED;
- }
-
- iu_output_intent_received_callback = NULL;
- iu_output_intent_user_data = NULL;
-
- return MMI_IU_ERROR_NONE;
-}
-
-EXPORT_API int mmi_iu_set_app_state(mmi_state app_state)
-{
- if (!initialized) {
- _W("[ERROR] Not initialized");
- return MMI_IU_ERROR_NOT_INITIALIZED;
- }
-
- g_app_state = app_state;
-
- return MMI_IU_ERROR_NONE;
-}
-
-EXPORT_API int mmi_iu_set_focus_app_id(const char *app_id)
-{
- if (!app_id) {
- _W("[ERROR] Invalid parameter");
- return MMI_IU_ERROR_INVALID_PARAMETER;
- }
-
- if (!initialized) {
- _W("[ERROR] Not initialized");
- return MMI_IU_ERROR_NOT_INITIALIZED;
- }
-
- g_focus_app_id = string(app_id);
-
- return MMI_IU_ERROR_NONE;
-}
-
-EXPORT_API int mmi_iu_set_system_app_id(const char *system_app_id)
-{
- if (!system_app_id) {
- _W("[ERROR] Invalid parameter");
- return MMI_IU_ERROR_INVALID_PARAMETER;
- }
-
- if (!initialized) {
- _W("[ERROR] Not initialized");
- return MMI_IU_ERROR_NOT_INITIALIZED;
- }
-
- g_system_app_id = string(system_app_id);
-
- return MMI_IU_ERROR_NONE;
-}
+++ /dev/null
-/*
- * 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 __TIZEN_UIX_MMI_IU_H__
-#define __TIZEN_UIX_MMI_IU_H__
-
-#include "mmi_iu_error.h"
-#include "mmi-common.h"
-
-/**
- * @file iu.h
- * @brief This file contains Intent Understanding APIs and related enumeration.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup UIX_MMI_IU_MODULE
- * @{
- */
-
-/**
- * @brief The callback function to receive output intent
- * @param[in] target_app_id The app ID to process output intent (focused app or system app id)
- * @param[in] json_data The output intent data with json format
- * @param[in] user_data The user data passed from the callback function
- */
-typedef void (*mmi_iu_output_intent_received_cb)(const char *target_app_id, const char *json_data, void *user_data);
-
-/**
- * @brief Initialize Intent Understanding library
- *
- * @return int MMI_IU_ERROR_NONE on success
- */
-int mmi_iu_init();
-
-/**
- * @brief Shutdown Intent Understanding library
- *
- * @return int MMI_IU_ERROR_NONE on success
- */
-int mmi_iu_shutdown();
-
-/**
- * @brief Set file path of json rule data
- * @param[in] filepath file path of json rule data
- *
- * @return int MMI_IU_ERROR_NONE on success
- */
-int mmi_iu_set_rule_filepath(const char *filepath);
-
-/**
- * @brief Feed input intent
- * @remark The result can be received by the callback registered by mmi_iu_set_output_intent_received_callback().
- * @param[in] app_id The app ID that input event occurred
- */
-int mmi_iu_feed_intent(const char *app_id, const char *json_data);
-
-/**
- * @brief Feed raw input event
- * @remark The result can be received by the callback registered by mmi_iu_set_output_intent_received_callback().
- * @param[in] app_id The app ID that input event occurred
- * @param[in] type The input event type (key, voice, gesture, ..)
- * @param[in] event The event information
- */
-int mmi_iu_feed_input_event(const char *app_id, int type, void *event);
-
-/**
- * @brief Register the callback function to receive output intent
- * @param callback The (callback) function to be called when output intent is generated.
- * @param data The data pointer to be passed to @p callback
- */
-int mmi_iu_set_output_intent_received_callback(mmi_iu_output_intent_received_cb callback, void *user_data);
-
-/**
- * @brief Unregister the callback function to receive output intent
- */
-int mmi_iu_unset_output_intent_received_callback();
-
-/**
- * @brief Set app state
- * @param app_state The application state
- */
-int mmi_iu_set_app_state(mmi_state app_state);
-
-/**
- * @brief Set system application ID
- * @param[in] system_app_id system application ID
- */
-int mmi_iu_set_system_app_id(const char *system_app_id);
-
-/**
- * @brief Set focus app ID
- * @param[in] app_id The focus application ID
- */
-int mmi_iu_set_focus_app_id(const char *app_id);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_UIX_MMI_IU_H__ */
+++ /dev/null
-/*
- * 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 __TIZEN_UIX_MMI_IU_ERROR_H__
-#define __TIZEN_UIX_MMI_IU_ERROR_H__
-
-#include <tizen.h>
-
-/**
- * @file MMI_IU_ERROR.h
- * @brief This file contains intent understanding error enumeration.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup UIX_IU_COMMON_MODULE
- * @{
- */
-
-/**
- * @brief Enumeration for intent understanding function error.
- *
- * @since_tizen 6.5
- */
-typedef enum {
- MMI_IU_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- MMI_IU_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- MMI_IU_ERROR_NOT_INITIALIZED = TIZEN_ERROR_UNKNOWN - 1, /**< Not initialized */
- MMI_IU_ERROR_OPERATION_FAILED = TIZEN_ERROR_UNKNOWN - 2, /**< Operation failed */
- MMI_IU_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
-} MMI_IU_ERROR_e;
-
-/**
- * @}
- */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_UIX_MMI_IU_ERROR_H__ */
+++ /dev/null
-/*
- * 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 __TIZEN_UIX_MMI_IU_EVENT_H__
-#define __TIZEN_UIX_MMI_IU_EVENT_H__
-
-#include <xkbcommon/xkbcommon.h>
-
-/* temporary definition */
-#define MMI_EVENT_KEYEVENT_MIC 0x8080
-
-#endif /* __TIZEN_UIX_MMI_IU_EVENT_H__ */
+++ /dev/null
-/*
- * 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 __TIZEN_UIX_MMI_IU_LOG_H__
-#define __TIZEN_UIX_MMI_IU_LOG_H__
-
-#include <dlog.h>
-#include <stdio.h>
-#include <libgen.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "MMI_IU"
-
-#ifdef _E
-#undef _E
-#endif
-
-#ifdef _W
-#undef _W
-#endif
-
-#ifdef _I
-#undef _I
-#endif
-
-#ifdef _D
-#undef _D
-#endif
-
-#define _D LOGD
-#define _E LOGE
-#define _I LOGI
-#define _W LOGW
-
-#endif /* __TIZEN_UIX_MMI_IU_LOG_H__ */
+++ /dev/null
-/*
- * 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 <unistd.h>
-#include <string>
-
-#include "output_intent.h"
-#include "mmi_iu_log.h"
-
-OutputIntent::OutputIntent()
-{
- json_object = json_object_new();
-}
-
-OutputIntent::~OutputIntent()
-{
- json_object = NULL;
-}
-
-string OutputIntent::get_action()
-{
- return action;
-}
-
-void OutputIntent::set_action(string action)
-{
- json_object_set_string_member(json_object, "Action", action.c_str());
- this->action = action;
-}
-
-void OutputIntent::add_member_value(string key, string value)
-{
- json_object_set_string_member(json_object, key.c_str(), value.c_str());
-}
-
-string OutputIntent::get_output_intent_text()
-{
- string json_output_text;
- JsonGenerator *j_generator = NULL;
- JsonNode *j_node = NULL;
- gsize size = 0;
- gchar *data = NULL;
-
- j_generator = json_generator_new();
- if (j_generator == NULL) {
- _E("json generator create error");
- goto cleanup;
- }
-
- j_node = json_node_new(JSON_NODE_OBJECT);
- if (j_node == NULL) {
- _E("json node create error");
- goto cleanup;
- }
-
- json_node_set_object(j_node, json_object);
- json_generator_set_root(j_generator, j_node);
-
- data = json_generator_to_data(j_generator, &size);
- if (data == NULL) {
- _E("Failed to get json data");
- goto cleanup;
- }
-
- json_output_text = string(data);
-
-cleanup:
- if (data)
- g_free(data);
-
- if (j_node)
- json_node_free(j_node);
-
- if (j_generator)
- g_object_unref(j_generator);
-
- return json_output_text;
-}
+++ /dev/null
-/*
- * 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 __OUTPUT_INTENT_H__
-#define __OUTPUT_INTENT_H__
-
-#include <unistd.h>
-#include <string>
-#include <json-glib/json-glib.h>
-
-using namespace std;
-
-class OutputIntent
-{
-public:
- OutputIntent();
- virtual ~OutputIntent();
-
- void add_member_value(string key, string value);
- void set_action(string action);
- string get_action();
-
- string get_output_intent_text();
-
-private:
- JsonObject *json_object = NULL;
- string action;
-};
-
-#endif /* __OUTPUT_INTENT_H__ */
+++ /dev/null
-/*
-* 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-manager.h"
-
-int main(int argc, char *argv[])
-{
- mmi_manager_init();
- mmi_manager_loop_begin();
- mmi_manager_shutdown();
-
- return 0;
-}
-
+++ /dev/null
-mmi_manager_srcs = [
- 'main.c',
- 'mmi-manager.h',
- 'mmi-manager.c',
- 'mmi-core.h',
- 'mmi-core.c',
- 'mmi-api-handler.h',
- 'mmi-api-handler.c',
- 'mmi-client.h',
- 'mmi-client.c',
- 'mmi-common.h',
- 'mmi-common.c',
- 'mmi-provider.c',
- 'mmi-provider.h',
- 'mmi-provider-iface.h',
- 'mmi-fusion.c',
- 'mmi-fusion.h',
- 'mmi-fusion-iface.h',
- 'mmi-manager-dbg.h',
- 'mmi-iu-bridge.c',
- 'mmi-iu-bridge.h',
- 'interface/mmifw_stub.h',
- 'interface/mmifw_stub.c',
- 'iu/input_intent.cpp',
- 'iu/input_intent.h',
- 'iu/intent_understanding_engine.cpp',
- 'iu/intent_understanding_engine.h',
- 'iu/iu_rule.cpp',
- 'iu/iu_rule.h',
- 'iu/mmi_iu.cpp',
- 'iu/output_intent.cpp',
- 'iu/output_intent.h'
- ]
-
-install_headers(
- 'mmi-manager.h',
- 'mmi-manager-dbg.h',
- 'mmi-common.h',
- 'mmi-provider-iface.h',
- 'mmi-fusion-iface.h'
- )
-
-install_data('iu/data/default_rule.json', install_dir : '/usr/share/iu/')
-
-glib_dep = dependency('glib-2.0')
-gio_dep = dependency('gio-2.0')
-bundle_dep = dependency('bundle')
-dlog_dep = dependency('dlog')
-ecore_dep = dependency('ecore', method : 'pkg-config')
-rpc_port_dep = dependency('rpc-port')
-json_glib_dep = dependency('json-glib-1.0')
-libtzplatform_config_dep = dependency('libtzplatform-config')
-xkbcommon_dep = dependency('xkbcommon')
-
-mmi_manager_deps = [
- ecore_dep,
- glib_dep,
- gio_dep,
- bundle_dep,
- dlog_dep,
- rpc_port_dep,
- json_glib_dep,
- libtzplatform_config_dep,
- xkbcommon_dep]
-
-executable('mmi-manager',
- mmi_manager_srcs,
- dependencies : [mmi_manager_deps],
- install_dir : mmi_manager_prefix_bindir,
- export_dynamic : true,
- install : true
- )
-
-mmi_manager_include_dirs = include_directories(
- '.'
- )
-
-mmi_manager_declared_dep = declare_dependency(
- dependencies : [mmi_manager_deps],
- include_directories : [mmi_manager_include_dirs]
- )
-
-pkgconfig.generate(
- filebase : 'mmi-manager',
- name : 'mmi-manager',
- description : 'Multi-modal Interaction Manager',
- version : meson.project_version(),
- )
-
-subdir('modules/modality_keyboard')
-subdir('modules/ref_fusion')
-
+++ /dev/null
-/*
-* 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-api-handler.h"
-#include "mmi-manager-dbg.h"
-#include "mmi-manager.h"
-#include "mmi-client.h"
-
-#include <stdlib.h>
-#include <rpc-port.h>
-#include <rpc-port-internal.h>
-
-static bool _init_done = false;
-
-static const char* _stub_appid = "mmi-manager";
-
-static void _on_create(rpc_port_stub_mmifw_context_h context, void *user_data)
-{
- int r;
- char *sender = NULL;
- mmi_client *mc = NULL;
-
- r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
- if (r || !sender)
- {
- LOGE("Failed to get sender from context ! (error:%d)\n", r);
- goto err;
- }
-
- LOGI("Client(%s) has been connected !\n", sender);
-
- mc = client_manager_add_client(sender);
-
- if (!mc)
- {
- LOGE("Failed to add client info to client hash !\n");
- goto err;
- }
-
- //TODO: set additional information of client
-
- free(sender);
- return;
-err:
- if (sender)
- free(sender);
-}
-
-static void _on_terminate(rpc_port_stub_mmifw_context_h context, void *user_data)
-{
- int r;
- char *sender = NULL;
-
- r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
- if (r || !sender)
- {
- LOGE("Failed to get sender from context ! (error:%d)\n", r);
- return;
- }
-
- LOGI("Client(%s) has been disconnected !\n", sender);
-
- client_manager_remove_client(sender);
- free(sender);
-}
-
-static int _register_cb(rpc_port_stub_mmifw_context_h context, rpc_port_mmifw_focus_event_cb_h focus_cb, rpc_port_mmifw_state_change_event_cb_h state_cb, rpc_port_mmifw_wakeup_event_cb_h wakeup_cb, rpc_port_mmifw_key_event_cb_h key_cb, rpc_port_mmifw_gesture_event_cb_h gesture_cb, rpc_port_mmifw_voice_event_cb_h voice_cb, rpc_port_mmifw_action_event_cb_h action_cb, rpc_port_mmifw_feedback_event_cb_h feedback_cb, void *user_data)
-{
- int r;
- char *sender = NULL;
- mmi_client *mc = NULL;
-
- r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
- if (r || !sender)
- {
- LOGE("Failed to get sender from context ! (error:%d)\n", r);
- return -1;
- }
-
- mc = client_manager_get_client(sender);
- if (!mc)
- {
- LOGE("Failed to get client information from sender !\n");
- goto err;
- }
-
- if (!client_manager_set_client_focus_cb_handle(mc, (void *)focus_cb))
- {
- LOGE("Failed to set focus event handler to client info !\n");
- goto err;
- }
-
- if (!client_manager_set_client_state_change_cb_handle(mc, (void *)state_cb))
- {
- LOGE("Failed to set state_change event handler to client info !\n");
- goto err;
- }
-
- if (!client_manager_set_client_wakeup_cb_handle(mc, (void *)wakeup_cb))
- {
- LOGE("Failed to set wakeup event handler to client info !\n");
- goto err;
- }
-
- if (!client_manager_set_client_key_cb_handle(mc, (void *)key_cb))
- {
- LOGE("Failed to set key event handler to client info !\n");
- goto err;
- }
-
- if (!client_manager_set_client_gesture_cb_handle(mc, (void *)gesture_cb))
- {
- LOGE("Failed to set gesture event handler to client info !\n");
- goto err;
- }
-
- if (!client_manager_set_client_voice_cb_handle(mc, (void *)voice_cb))
- {
- LOGE("Failed to set voice event handler to client info !\n");
- goto err;
- }
-
- if (!client_manager_set_client_action_cb_handle(mc, (void *)action_cb))
- {
- LOGE("Failed to set action event handler to client info !\n");
- goto err;
- }
-
- if (!client_manager_set_client_feedback_cb_handle(mc, (void *)feedback_cb))
- {
- LOGE("Failed to set feedback event handler to client info !\n");
- goto err;
- }
-
- free(sender);
- return 0;
-err:
- if (sender)
- free(sender);
- return -1;
-}
-
-static void _deregister_cb(rpc_port_stub_mmifw_context_h context, void *user_data)
-{
- int r;
- char *sender = NULL;
- mmi_client *mc = NULL;
-
- r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
- if (r || !sender)
- {
- LOGE("Failed to get sender from context ! (error:%d)\n", r);
- return;
- }
-
- mc = client_manager_get_client(sender);
- if (!mc)
- {
- LOGE("Failed to get client information from sender !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_focus_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset focus event handler of client !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_state_change_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset state_change event handler of client !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_wakeup_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset wakeup event handler of client !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_key_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset key event handler of client !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_gesture_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset gesture event handler of client !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_voice_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset voice event handler of client !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_action_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset action event handler of client !\n");
- goto err;
- }
-
- if (NULL != client_manager_set_client_feedback_cb_handle(mc, NULL))
- {
- LOGE("Failed to unset feedback event handler of client !\n");
- goto err;
- }
-
-
- free(sender);
- return;
-err:
- if (sender)
- free(sender);
- return;
-}
-
-static void _get_focus_cb(rpc_port_stub_mmifw_context_h context, void *user_data)
-{
- int r;
- char *sender = NULL;
- mmi_client *mc = NULL;
-
- r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
- if (r || !sender)
- {
- LOGE("Failed to get sender from context ! (error:%d)\n", r);
- goto err;
- }
-
- LOGI("Get focus request came from a client(%s) !\n", sender);
-
- mc = client_manager_get_client(sender);
- if (!mc)
- {
- LOGE("Failed to get client info from sender(=%s)]n", sender);
- goto err;
- }
-
- r = mmi_manager_set_focus_client(mc);
- if (r)
- {
- LOGE("Failed returned mmi_manager_set_focus_client ! (error:%d)\n", r);
- goto err;
- }
-
- free(sender);
- return;
-err:
- if (sender)
- free(sender);
- if (mc)
- free(mc);
-}
-
-static void _set_state_cb(rpc_port_stub_mmifw_context_h context, int state, void *user_data)
-{
- int r;
- char *sender = NULL;
- mmi_client *mc = NULL;
-
- r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
- if (r || !sender)
- {
- LOGE("Failed to get sender from context ! (error:%d)\n", r);
- goto err;
- }
-
- LOGI("Get focus request came from a client(%s) !\n", sender);
-
- mc = client_manager_get_client(sender);
- if (!mc)
- {
- LOGE("Failed to get client info from sender(=%s)]n", sender);
- goto err;
- }
-
- r = mmi_manager_set_state(mc, state);
- if (r)
- {
- LOGE("Failed returned mmi_manager_set_state(=%d) ! (error:%d)\n", state, r);
- goto err;
- }
-
- free(sender);
- return;
-err:
- if (sender)
- free(sender);
- if (mc)
- free(mc);
-}
-
-void
-mmi_api_handler_init(void)
-{
- int r;
-
- if (_init_done)
- return;
-
- r = rpc_port_register_proc_info(_stub_appid, NULL);
- if (r != RPC_PORT_ERROR_NONE)
- {
- LOGE("Failed to register proc info ! (error:%d)\n", r);
- goto err;
- }
-
- rpc_port_stub_mmifw_callback_s callback = {
- _on_create,
- _on_terminate,
- _register_cb,
- _deregister_cb,
- _get_focus_cb,
- _set_state_cb
- };
-
- r = rpc_port_stub_mmifw_register(&callback, NULL);
- if (r != 0)
- {
- LOGE("Failed to register callbacks (error:%d)\n", r);
- goto err;
- }
-
- _init_done = true;
-err:
- return;
-}
-
-void
-mmi_api_handler_shutdown(void)
-{
- if (!_init_done)
- return;
-
- rpc_port_stub_mmifw_unregister();
-
- _init_done = false;
-}
-
+++ /dev/null
-/*
-* 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_API_HANDLER_H__
-#define __MMI_API_HANDLER_H__
-
-#include "interface/mmifw_stub.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void mmi_api_handler_init(void);
-void mmi_api_handler_shutdown(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__MMI_API_HANDLER_H__
+++ /dev/null
-/*
-* 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-client.h"
-#include "mmi-common.h"
-#include "mmi-manager.h"
-#include "mmi-manager-dbg.h"
-#include "interface/mmifw_stub.h"
-
-#include <Eina.h>
-#include <stdlib.h>
-
-struct _mmi_client
-{
- char *sender;
- uid_t uid;
- pid_t pid;
- mmi_state state;
- bool has_focus;
-
- rpc_port_mmifw_focus_event_cb_h focus_cb_h;
- rpc_port_mmifw_state_change_event_cb_h state_change_cb_h;
- rpc_port_mmifw_wakeup_event_cb_h wakeup_cb_h;
- rpc_port_mmifw_key_event_cb_h key_cb_h;
- rpc_port_mmifw_gesture_event_cb_h gesture_cb_h;
- rpc_port_mmifw_voice_event_cb_h voice_cb_h;
- rpc_port_mmifw_action_event_cb_h action_cb_h;
- rpc_port_mmifw_feedback_event_cb_h feedback_cb_h;
-};
-
-Eina_Hash *_client_hash = NULL;
-static Eina_Bool _init_done = false;
-
-static Eina_Bool
-_client_hash_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
-{
- (void) hash;
- (void) key;
- (void) fdata;
-
- mmi_client *mc = (mmi_client *)data;
- if (mc && mc->sender)
- free(mc->sender);
-
- return 1;
-}
-
-mmi_client *
-client_manager_add_client(const char* sender)
-{
- mmi_client *mc = NULL;
-
- if (!sender)
- return NULL;
-
- mc = calloc(1, sizeof(mmi_client));
- if (!mc)
- {
- LOGE("Failed to allocate memory for client !\n");
- return NULL;
- }
-
- mc->sender = strdup(sender);
-
- if (!eina_hash_add(_client_hash, sender, mc))
- {
- LOGE("Failed to add client info to client hash !\n");
- goto err;
- }
-
- return mc;
-err:
- if (mc)
- free(mc);
- return NULL;
-}
-
-mmi_client *
-client_manager_get_client(const char* sender)
-{
- mmi_client *mc = NULL;
-
- if (!sender)
- return NULL;
-
- mc = eina_hash_find(_client_hash, sender);
-
- if (!mc)
- {
- LOGE("Failed to find client info from sender(=%s)\n", sender);
- return NULL;
- }
-
- return mc;
-}
-
-int
-client_manager_remove_client(const char *sender)
-{
- mmi_client *mc = NULL;
-
- if (!sender)
- return -1;
-
- mc = eina_hash_find(_client_hash, sender);
- if (!mc)
- {
- LOGE("Failed to find client info from sender(=%s)\n", sender);
- goto err;
- }
-
- if (mc->has_focus)
- mmi_manager_remove_focus_client(mc);
- else
- mmi_manager_remove_client_from_focus_candidates(mc);
-
- if (!eina_hash_del(_client_hash, sender, mc))
- {
- LOGE("Failed to remove client info using sender(=%s) !\n", sender);
- goto err;
- }
-
- if (mc->sender)
- free(mc->sender);
-
- rpc_port_mmifw_focus_event_cb_destroy(mc->focus_cb_h);
- rpc_port_mmifw_state_change_event_cb_destroy(mc->state_change_cb_h);
- rpc_port_mmifw_wakeup_event_cb_destroy(mc->wakeup_cb_h);
- rpc_port_mmifw_key_event_cb_destroy(mc->key_cb_h);
- rpc_port_mmifw_gesture_event_cb_destroy(mc->gesture_cb_h);
- rpc_port_mmifw_voice_event_cb_destroy(mc->voice_cb_h);
- rpc_port_mmifw_action_event_cb_destroy(mc->action_cb_h);
- rpc_port_mmifw_feedback_event_cb_destroy(mc->feedback_cb_h);
-
- mc->focus_cb_h = NULL;
- mc->state_change_cb_h = NULL;
- mc->wakeup_cb_h = NULL;
- mc->key_cb_h = NULL;
- mc->gesture_cb_h = NULL;
- mc->voice_cb_h = NULL;
- mc->action_cb_h = NULL;
- mc->feedback_cb_h = NULL;
-
- free(mc);
- mc = NULL;
-
- return 0;
-err:
- if (mc && mc->sender)
- free(mc->sender);
- if (mc)
- free(mc);
- mc = NULL;
- return -1;
-}
-
-int
-client_manager_set_client_uid(mmi_client *client, uid_t uid)
-{
- if (!client)
- return -1;
-
- client->uid = uid;
- return uid;
-}
-
-int
-client_manager_get_client_uid(mmi_client *client)
-{
- if (!client)
- return -1;
-
- return client->uid;
-}
-
-int
-client_manager_set_client_pid(mmi_client *client, pid_t pid)
-{
- if (!client)
- return -1;
-
- client->pid = pid;
- return pid;
-}
-
-int
-client_manager_get_client_pid(mmi_client *client)
-{
- if (!client)
- return -1;
-
- return client->pid;
-}
-
-mmi_state
-client_manager_set_client_state(mmi_client *client, mmi_state state)
-{
- if (!client)
- return MMI_STATE_NONE;
-
- client->state = state;
- return state;
-}
-
-mmi_state
-client_manager_get_client_state(mmi_client *client)
-{
- if (!client)
- return MMI_STATE_NONE;
-
- return client->state;
-}
-
-bool
-client_manager_set_client_has_focus(mmi_client *client, bool has_focus)
-{
- if (!client)
- return false;
-
- client->has_focus = has_focus;
- return client->has_focus;
-}
-
-bool
-client_manager_get_client_has_focus(mmi_client *client)
-{
- if (!client)
- return false;
-
- return client->has_focus;
-}
-
-const char *
-client_manager_get_client_sender(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->sender;
-}
-
-static void
-_cleanup_client_hash(void)
-{
- if (!_client_hash)
- return;
-
- eina_hash_foreach(_client_hash, _client_hash_free_cb, NULL);
- eina_hash_free(_client_hash);
- _client_hash = NULL;
-}
-
-void
-client_manager_init(void)
-{
- if (_init_done)
- return;
-
- if (_client_hash)
- _cleanup_client_hash();
-
- _init_done = true;
- _client_hash = eina_hash_string_superfast_new(NULL);
-}
-
-void
-client_manager_shutdown(void)
-{
- if (!_init_done)
- return;
-
- if (_client_hash)
- _cleanup_client_hash();
-
- _init_done = false;
-}
-
-void *
-client_manager_set_client_focus_cb_handle(mmi_client *client, void *focus_cb_h)
-{
- int r;
-
- if (!client || !focus_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_focus_event_cb_clone(focus_cb_h, &client->focus_cb_h);
- if (r)
- {
- LOGE("Failed to clone focus event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->focus_cb_h;
-}
-
-void *
-client_manager_get_client_focus_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->focus_cb_h;
-}
-
-
-void *
-client_manager_set_client_state_change_cb_handle(mmi_client *client, void *state_change_cb_h)
-{
- int r;
-
- if (!client || !state_change_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_state_change_event_cb_clone(state_change_cb_h, &client->state_change_cb_h);
- if (r)
- {
- LOGE("Failed to clone state_change event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->state_change_cb_h;
-}
-
-void *
-client_manager_get_client_state_change_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->state_change_cb_h;
-}
-
-void *
-client_manager_set_client_wakeup_cb_handle(mmi_client *client, void *wakeup_cb_h)
-{
- int r;
-
- if (!client || !wakeup_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_wakeup_event_cb_clone(wakeup_cb_h, &client->wakeup_cb_h);
- if (r)
- {
- LOGE("Failed to clone wakeup event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->wakeup_cb_h;
-}
-
-void *
-client_manager_get_client_wakeup_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->wakeup_cb_h;
-}
-
-void *
-client_manager_set_client_key_cb_handle(mmi_client *client, void *key_cb_h)
-{
- int r;
-
- if (!client || !key_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_key_event_cb_clone(key_cb_h, &client->key_cb_h);
- if (r)
- {
- LOGE("Failed to clone key event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->key_cb_h;
-}
-
-void *
-client_manager_get_client_key_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->key_cb_h;
-}
-
-void *
-client_manager_set_client_gesture_cb_handle(mmi_client *client, void *gesture_cb_h)
-{
- int r;
-
- if (!client || !gesture_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_gesture_event_cb_clone(gesture_cb_h, &client->gesture_cb_h);
- if (r)
- {
- LOGE("Failed to clone gesture event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->gesture_cb_h;
-}
-
-void *
-client_manager_get_client_gesture_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->gesture_cb_h;
-}
-
-void *
-client_manager_set_client_voice_cb_handle(mmi_client *client, void *voice_cb_h)
-{
- int r;
-
- if (!client || !voice_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_voice_event_cb_clone(voice_cb_h, &client->voice_cb_h);
- if (r)
- {
- LOGE("Failed to clone voice event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->voice_cb_h;
-}
-
-void *
-client_manager_get_client_voice_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->voice_cb_h;
-}
-
-void *
-client_manager_set_client_action_cb_handle(mmi_client *client, void *action_cb_h)
-{
- int r;
-
- if (!client || !action_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_action_event_cb_clone(action_cb_h, &client->action_cb_h);
- if (r)
- {
- LOGE("Failed to clone action event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->action_cb_h;
-}
-
-void *
-client_manager_get_client_action_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->action_cb_h;
-}
-
-void *
-client_manager_set_client_feedback_cb_handle(mmi_client *client, void *feedback_cb_h)
-{
- int r;
-
- if (!client || !feedback_cb_h)
- return NULL;
-
- r = rpc_port_mmifw_feedback_event_cb_clone(feedback_cb_h, &client->feedback_cb_h);
- if (r)
- {
- LOGE("Failed to clone feedback event handle ! (error:%d)\n", r);
- return NULL;
- }
-
- return client->feedback_cb_h;
-}
-
-void *
-client_manager_get_client_feedback_cb_handle(mmi_client *client)
-{
- if (!client)
- return NULL;
-
- return client->feedback_cb_h;
-}
-
-int
-client_manager_send_focus_event(mmi_client *client, focus_event_arg *args)
-{
- int r;
- rpc_port_focus_event_h focus_event_h = NULL;
- focus_event_arg *ev = (focus_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->focus_cb_h)
- {
- LOGE("Given client doesn't have focus_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_focus_event_create(&focus_event_h);
- if (r)
- {
- LOGE("Failed to create focus_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_focus_event_set_type(focus_event_h, ev->type);
- rpc_port_focus_event_set_timestamp(focus_event_h, ev->timestamp);
- rpc_port_focus_event_set_focus_in(focus_event_h, ev->focus_in);
-
- r = rpc_port_mmifw_focus_event_cb_invoke(client->focus_cb_h, focus_event_h);
- if (r)
- {
- LOGE("Failed to invoke focus_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (focus_event_h)
- rpc_port_focus_event_destroy(focus_event_h);
-
- return -1;
-}
-
-int
-client_manager_send_state_change_event(mmi_client *client, state_change_event_arg *args)
-{
- int r;
- rpc_port_state_change_event_h state_change_event_h = NULL;
- state_change_event_arg *ev = (state_change_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->state_change_cb_h)
- {
- LOGE("Given client doesn't have state_change_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_state_change_event_create(&state_change_event_h);
- if (r)
- {
- LOGE("Failed to create state_change_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_state_change_event_set_type(state_change_event_h, ev->type);
- rpc_port_state_change_event_set_timestamp(state_change_event_h, ev->timestamp);
- rpc_port_state_change_event_set_state(state_change_event_h, ev->state);
- rpc_port_state_change_event_set_old_state(state_change_event_h, ev->old_state);
-
- r = rpc_port_mmifw_state_change_event_cb_invoke(client->state_change_cb_h, state_change_event_h);
- if (r)
- {
- LOGE("Failed to invoke state_change_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (state_change_event_h)
- rpc_port_state_change_event_destroy(state_change_event_h);
-
- return -1;
-}
-
-int
-client_manager_send_wakeup_event(mmi_client *client, wakeup_event_arg *args)
-{
- int r;
- rpc_port_wakeup_event_h wakeup_event_h = NULL;
- wakeup_event_arg *ev = (wakeup_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->wakeup_cb_h)
- {
- LOGE("Given client doesn't have wakeup_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_wakeup_event_create(&wakeup_event_h);
- if (r)
- {
- LOGE("Failed to create wakeup_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_wakeup_event_set_type(wakeup_event_h, ev->type);
- rpc_port_wakeup_event_set_timestamp(wakeup_event_h, ev->timestamp);
- rpc_port_wakeup_event_set_source(wakeup_event_h, ev->source);
-
- r = rpc_port_mmifw_wakeup_event_cb_invoke(client->wakeup_cb_h, wakeup_event_h);
- if (r)
- {
- LOGE("Failed to invoke wakeup_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (wakeup_event_h)
- rpc_port_wakeup_event_destroy(wakeup_event_h);
-
- return -1;
-}
-
-int
-client_manager_send_key_event(mmi_client *client, key_event_arg *args)
-{
- int r;
- rpc_port_key_event_h key_event_h = NULL;
- key_event_arg *ev = (key_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->key_cb_h)
- {
- LOGE("Given client doesn't have key_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_key_event_create(&key_event_h);
- if (r)
- {
- LOGE("Failed to create key_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_key_event_set_type(key_event_h, ev->type);
- rpc_port_key_event_set_timestamp(key_event_h, ev->timestamp);
- rpc_port_key_event_set_key_down(key_event_h, ev->key_down);
- rpc_port_key_event_set_keycode(key_event_h, ev->keycode);
- rpc_port_key_event_set_keyname(key_event_h, ev->keyname);
- rpc_port_key_event_set_source(key_event_h, ev->source);
-
- r = rpc_port_mmifw_key_event_cb_invoke(client->key_cb_h, key_event_h);
- if (r)
- {
- LOGE("Failed to invoke key_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (key_event_h)
- rpc_port_key_event_destroy(key_event_h);
-
- return -1;
-}
-
-int
-client_manager_send_gesture_event(mmi_client *client, gesture_event_arg *args)
-{
- int r;
- rpc_port_gesture_event_h gesture_event_h = NULL;
- gesture_event_arg *ev = (gesture_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->gesture_cb_h)
- {
- LOGE("Given client doesn't have gesture_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_gesture_event_create(&gesture_event_h);
- if (r)
- {
- LOGE("Failed to create gesture_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_gesture_event_set_type(gesture_event_h, ev->type);
- rpc_port_gesture_event_set_timestamp(gesture_event_h, ev->timestamp);
- rpc_port_gesture_event_set_source(gesture_event_h, ev->source);
-
- r = rpc_port_mmifw_gesture_event_cb_invoke(client->gesture_cb_h, gesture_event_h);
- if (r)
- {
- LOGE("Failed to invoke gesture_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (gesture_event_h)
- rpc_port_gesture_event_destroy(gesture_event_h);
-
- return -1;
-}
-
-int
-client_manager_send_voice_event(mmi_client *client, voice_event_arg *args)
-{
- int r;
- rpc_port_voice_event_h voice_event_h = NULL;
- voice_event_arg *ev = (voice_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->voice_cb_h)
- {
- LOGE("Given client doesn't have voice_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_voice_event_create(&voice_event_h);
- if (r)
- {
- LOGE("Failed to create voice_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_voice_event_set_type(voice_event_h, ev->type);
- rpc_port_voice_event_set_timestamp(voice_event_h, ev->timestamp);
- rpc_port_voice_event_set_source(voice_event_h, ev->source);
-
- r = rpc_port_mmifw_voice_event_cb_invoke(client->voice_cb_h, voice_event_h);
- if (r)
- {
- LOGE("Failed to invoke voice_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (voice_event_h)
- rpc_port_voice_event_destroy(voice_event_h);
-
- return -1;
-}
-
-int
-client_manager_send_action_event(mmi_client *client, action_event_arg *args)
-{
- int r;
- rpc_port_action_event_h action_event_h = NULL;
- action_event_arg *ev = (action_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->action_cb_h)
- {
- LOGE("Given client doesn't have action_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_action_event_create(&action_event_h);
- if (r)
- {
- LOGE("Failed to create action_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_action_event_set_type(action_event_h, ev->type);
- rpc_port_action_event_set_timestamp(action_event_h, ev->timestamp);
- rpc_port_action_event_set_cmd(action_event_h, ev->cmd);
- rpc_port_action_event_set_nargs(action_event_h, ev->nargs);
- rpc_port_action_event_set_source(action_event_h, ev->source);
- rpc_port_action_event_set_args(action_event_h, ev->args, ev->nargs);
-
- r = rpc_port_mmifw_action_event_cb_invoke(client->action_cb_h, action_event_h);
- if (r)
- {
- LOGE("Failed to invoke action_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (action_event_h)
- rpc_port_action_event_destroy(action_event_h);
-
- return -1;
-}
-
-int
-client_manager_send_feedback_event(mmi_client *client, feedback_event_arg *args)
-{
- int r;
- rpc_port_feedback_event_h feedback_event_h = NULL;
- feedback_event_arg *ev = (feedback_event_arg *)args;
-
- if (!client || !args)
- {
- LOGE("Invalid client or args was given !\n");
- return -1;
- }
-
- if (!client->feedback_cb_h)
- {
- LOGE("Given client doesn't have feedback_cb handle !\n");
- return -1;
- }
-
- r = rpc_port_feedback_event_create(&feedback_event_h);
- if (r)
- {
- LOGE("Failed to create feedback_event_h ! (error:%d)\n", r);
- return -1;
- }
-
- rpc_port_feedback_event_set_type(feedback_event_h, ev->type);
- rpc_port_feedback_event_set_timestamp(feedback_event_h, ev->timestamp);
- rpc_port_feedback_event_set_feedback(feedback_event_h, ev->feedback);
- rpc_port_feedback_event_set_comment(feedback_event_h, ev->comment);
-
- r = rpc_port_mmifw_feedback_event_cb_invoke(client->feedback_cb_h, feedback_event_h);
- if (r)
- {
- LOGE("Failed to invoke feedback_event_cb ! (error:%d)\n", r);
- goto err;
- }
-
- return 0;
-err:
- if (feedback_event_h)
- rpc_port_feedback_event_destroy(feedback_event_h);
-
- return -1;
-}
+++ /dev/null
-/*
-* 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_CLIENT_H__
-#define __MMI_CLIENT_H__
-
-#include "mmi-common.h"
-#include <sys/types.h>
-
-typedef struct _mmi_client mmi_client;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-mmi_client *client_manager_add_client(const char* sender);
-mmi_client *client_manager_get_client(const char* sender);
-int client_manager_remove_client(const char *sender);
-int client_manager_set_client_uid(mmi_client *client, uid_t uid);
-int client_manager_get_client_uid(mmi_client *client);
-int client_manager_set_client_pid(mmi_client *client, pid_t pid);
-int client_manager_get_client_pid(mmi_client *client);
-mmi_state client_manager_set_client_state(mmi_client *client, mmi_state state);
-mmi_state client_manager_get_client_state(mmi_client *client);
-bool client_manager_set_client_has_focus(mmi_client *client, bool has_focus);
-bool client_manager_get_client_has_focus(mmi_client *client);
-const char *client_manager_get_client_sender(mmi_client *client);
-
-void *client_manager_set_client_focus_cb_handle(mmi_client *client, void *focus_cb_h);
-void *client_manager_get_client_focus_cb_handle(mmi_client *client);
-void *client_manager_set_client_state_change_cb_handle(mmi_client *client, void *state_change_cb_h);
-void *client_manager_get_client_state_change_cb_handle(mmi_client *client);
-void *client_manager_set_client_wakeup_cb_handle(mmi_client *client, void *wakeup_cb_h);
-void *client_manager_get_client_wakeup_cb_handle(mmi_client *client);
-void *client_manager_set_client_key_cb_handle(mmi_client *client, void *key_cb_h);
-void *client_manager_get_client_key_cb_handle(mmi_client *client);
-void *client_manager_set_client_gesture_cb_handle(mmi_client *client, void *gesture_cb_h);
-void *client_manager_get_client_gesture_cb_handle(mmi_client *client);
-void *client_manager_set_client_voice_cb_handle(mmi_client *client, void *voice_cb_h);
-void *client_manager_get_client_voice_cb_handle(mmi_client *client);
-void *client_manager_set_client_action_cb_handle(mmi_client *client, void *action_cb_h);
-void *client_manager_get_client_action_cb_handle(mmi_client *client);
-void *client_manager_set_client_feedback_cb_handle(mmi_client *client, void *feedback_cb_h);
-void *client_manager_get_client_feedback_cb_handle(mmi_client *client);
-
-int client_manager_send_focus_event(mmi_client *client, focus_event_arg *args);
-int client_manager_send_state_change_event(mmi_client *client, state_change_event_arg *args);
-int client_manager_send_wakeup_event(mmi_client *client, wakeup_event_arg *args);
-int client_manager_send_key_event(mmi_client *client, key_event_arg *args);
-int client_manager_send_gesture_event(mmi_client *client, gesture_event_arg *args);
-int client_manager_send_voice_event(mmi_client *client, voice_event_arg *args);
-int client_manager_send_action_event(mmi_client *client, action_event_arg *args);
-int client_manager_send_feedback_event(mmi_client *client, feedback_event_arg *args);
-
-void client_manager_init(void);
-void client_manager_shutdown(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__MMI_CLIENT_H__
+++ /dev/null
-/*
-* 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-common.h"
-
-MMI_API int MMI_MANAGER_EVENT_FOCUS_CHANGE = -1;
-MMI_API int MMI_MANAGER_EVENT_STATE_CHANGE = -1;
-
-MMI_API int MMI_PROVIDER_EVENT_KEY = -1;
-MMI_API int MMI_PROVIDER_EVENT_GESTURE = -1;
-MMI_API int MMI_PROVIDER_EVENT_VOICE = -1;
-MMI_API int MMI_PROVIDER_EVENT_VISION = -1;
+++ /dev/null
-/*
-* 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_COMMON_H__
-#define __MMI_COMMON_H__
-
-#include <stdbool.h>
-
-#ifndef MMI_API
-#define MMI_API __attribute__ ((visibility("default")))
-#endif
-
-MMI_API extern int MMI_PROVIDER_EVENT_KEY;
-MMI_API extern int MMI_PROVIDER_EVENT_GESTURE;
-MMI_API extern int MMI_PROVIDER_EVENT_VOICE;
-MMI_API extern int MMI_PROVIDER_EVENT_VISION;
-
-typedef enum mmi_event_key_type
-{
- MMI_EVENT_KEY_TYPE_DOWN,
- MMI_EVENT_KEY_TYPE_UP
-} mmi_event_key_type;
-
-typedef enum mmi_event_gesture_type
-{
- MMI_EVENT_GESTURE_TYPE_SWIPE_UP,
- MMI_EVENT_GESTURE_TYPE_SWIPE_DOWN,
- MMI_EVENT_GESTURE_TYPE_SWIPE_LEFT,
- MMI_EVENT_GESTURE_TYPE_SWIPE_RIGHT,
- MMI_EVENT_GESTURE_TYPE_PUSH
-} mmi_event_gesture_type;
-
-typedef enum mmi_event_voice_type
-{
- MMI_EVENT_VOICE_TYPE_UP,
- MMI_EVENT_VOICE_TYPE_DOWN,
- MMI_EVENT_VOICE_TYPE_LEFT,
- MMI_EVENT_VOICE_TYPE_RIGHT,
- MMI_EVENT_VOICE_TYPE_CANCEL,
- MMI_EVENT_VOICE_TYPE_PLAY,
- MMI_EVENT_VOICE_TYPE_YES,
- MMI_EVENT_VOICE_TYPE_EXECUTE,
- MMI_EVENT_VOICE_TYPE_BACK,
- MMI_EVENT_VOICE_TYPE_EXIT,
- MMI_EVENT_VOICE_TYPE_STOP,
- MMI_EVENT_VOICE_TYPE_TERMINATE
-} mmi_event_voice_type;
-
-typedef enum mmi_event_vision_type
-{
- MMI_EVENT_VISION_TYPE_USER_ENTER,
- MMI_EVENT_VISION_TYPE_USER_LEAVE,
- MMI_EVENT_VISION_TYPE_USER_MOVE_AWAY,
- MMI_EVENT_VISION_TYPE_USER_MOVE_CLOSER,
- MMI_EVENT_VISION_TYPE_YES,
- MMI_EVENT_VISION_TYPE_NO,
- MMI_EVENT_VISION_TYPE_REVOKE,
- MMI_EVENT_VISION_TYPE_STOP
-} mmi_event_vision_type;
-
-typedef enum mmi_event_wakeup_type
-{
- MMI_EVENT_WAKEUP_TYPE_WAKEUP
-} mmi_event_wakeup_type;
-
-typedef enum mmi_event_action_type
-{
- MMI_EVENT_ACTION_TYPE_PLAY,
- MMI_EVENT_ACTION_TYPE_PAUSE,
- MMI_EVENT_ACTION_TYPE_RESUME,
- MMI_EVENT_ACTION_TYPE_STOP,
- MMI_EVENT_ACTION_TYPE_EXECUTE,
- MMI_EVENT_ACTION_TYPE_LAUNCH,
- MMI_EVENT_ACTION_TYPE_REVOKE,
- MMI_EVENT_ACTION_TYPE_CANCEL
-} mmi_event_action_type;
-
-typedef enum mmi_event_feedback_type
-{
- MMI_EVENT_FEEDBACK_TYPE_FEEDBACK
-} mmi_event_feedback_type;
-
-typedef enum mmi_event_focus_type
-{
- MMI_EVENT_FOCUS_TYPE_IN,
- MMI_EVENT_FOCUS_TYPE_OUT
-} mmi_event_focus_type;
-
-typedef enum mmi_event_state_change_type
-{
- MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE
-} mmi_event_state_change_type;
-
-typedef struct
-{
- int type;
- int timestamp;
- bool focus_in;
-} focus_event_arg;
-
-typedef struct
-{
- int type;
- int timestamp;
- int state;
- int old_state;
-} state_change_event_arg;
-
-typedef struct
-{
- int type;
- int timestamp;
- char *source;
-} wakeup_event_arg;
-
-typedef struct
-{
- int type;
- int timestamp;
- bool key_down;
- int keycode;
- char *keyname;
- char *source;
-} key_event_arg;
-
-typedef struct
-{
- int type;
- int timestamp;
- char *source;
-} gesture_event_arg;
-
-typedef struct
-{
- int type;
- int timestamp;
- char *source;
-} voice_event_arg;
-
-typedef struct
-{
- int type;
- int timestamp;
- char *cmd;
- char **args;
- int nargs;
- char *source;
-} action_event_arg;
-
-typedef struct
-{
- int type;
- int timestamp;
- char *feedback;
- char *comment;
-} feedback_event_arg;
-
-typedef struct
-{
- int type;//down or up
- int timestamp;
- int duration;
- double confidence;
- int keycode;
- bool key_down;
- char *keyname;
- char *source;//event source information
-} mmi_provider_event_key;
-
-typedef struct
-{
- int type;//swipe up, down, left, palm open, palm cover
- int timestamp;
- int duration;
- double confidence;
- char *source;//event source information
-} mmi_provider_event_gesture;
-
-typedef struct
-{
- int type;//play, pause, ..., yes, no
- int timestamp;
- int duration;
- double confidence;
- char *cmd;
- char **args;
- int nargs;//num of args
- char *source;//event source information
-} mmi_provider_event_voice;
-
-typedef struct
-{
- int type;//leave, enter, move away, move closer
- int timestamp;
- int duration;
- double confidence;
- char *cmd;
- char **args;
- int nargs;//num of args
- char *source;//event source information
-} mmi_provider_event_vision;
-
-typedef unsigned long long ull;
-
-typedef enum mmi_state
-{
- MMI_STATE_NONE,
- MMI_STATE_INITIATION,
- MMI_STATE_EXPLORATION,
- MMI_STATE_EXECUTION,
- MMI_STATE_FEEDBACK,
- MMI_STATE_OBSERVATION,
- MMI_STATE_TERMINATION
-} mmi_state;
-
-typedef enum mmi_provider_op_mode
-{
- MODALITY_PROVIDER_MODE_NONE,
- MODALITY_PROVIDER_MODE_PROPAGATE_EVENT,
- MODALITY_PROVIDER_MODE_KEEP_EVENT,
- MODALITY_PROVIDER_MODE_DROP_EVENT,
-} mmi_provider_op_mode;
-
-typedef enum mmi_provider_capability
-{
- MODALITY_PROVIDER_CAP_NONE = 0,
- MODALITY_PROVIDER_CAP_KEY_EVENT = (1 << 0),
- MODALITY_PROVIDER_CAP_MOUSE_EVENT = (1 << 1),
- MODALITY_PROVIDER_CAP_TOUCH_EVENT = (1 << 2),
- MODALITY_PROVIDER_CAP_GESTURE_EVENT = (1 << 3),
- MODALITY_PROVIDER_CAP_VOICE_EVENT = (1 << 4),
- MODALITY_PROVIDER_CAP_VISION_EVENT = (1 << 5),
- MODALITY_PROVIDER_CAP_UNKNOWN = ((ull)1 << 62),
- MODALITY_PROVIDER_CAP_MAX = ((ull)1 << 63)
-} mmi_provider_capability;
-
-typedef enum mmi_provider_result
-{
- MODALITY_PROVIDER_RESULT_NONE,
- MODALITY_PROVIDER_RESULT_FAIL,
- MODALITY_PROVIDER_RESULT_SUCCESS
-} mmi_provider_result;
-
-typedef struct _mmi_provider_module_data mmi_provider_module_data;
-typedef struct _mmi_provider_module mmi_provider_module;
-typedef struct _mmi_provider_handle mmi_provider_handle;
-
-typedef struct _mmi_fusion_module_data mmi_fusion_module_data;
-typedef struct _mmi_fusion_module mmi_fusion_module;
-typedef struct _mmi_fusion_handle mmi_fusion_handle;
-
-#endif //__MMI_COMMON_H__
+++ /dev/null
-/*
-* 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-core.h"
-
-void
-mmi_core_init()
-{
-}
-
-void
-mmi_core_shutdown()
-{
-}
-
+++ /dev/null
-/*
-* 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_CORE_H__
-#define __MMI_CORE_H__
-
-void mmi_core_init(void);
-void mmi_core_shutdown(void);
-
-#endif //__MMI_CORE_H__
+++ /dev/null
-/*
-* 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_FUSION_IFACE_H__
-#define __MMI_FUSION_IFACE_H__
-
-#include "mmi-common.h"
-
-#define MMI_FUSION_ABI_MAJOR_MASK 0xFFFF0000
-#define MMI_FUSION_ABI_MINOR_MASK 0x0000FFFF
-
-#define MMI_FUSION_GET_ABI_MAJOR(m) (((m) & MMI_FUSION_ABI_MAJOR_MASK) >> 16)
-#define MMI_FUSION_GET_ABI_MINOR(m) ((m) & MMI_FUSION_ABI_MINOR_MASK)
-
-#define MMI_FUSION_SET_ABI_VERSION(major, minor) \
- ((((major) << 16) & MMI_FUSION_ABI_MAJOR_MASK) \
- | ((minor) & MMI_FUSION_ABI_MINOR_MASK))
-
-#define MMI_FUSION_API __attribute__ ((visibility("default")))
-
-#ifndef bool
-typedef int bool;
-#endif
-
-struct _mmi_fusion_module
-{
- const char *name; /**< The name of a fusion module */
- const char *so_name; /**< The shared library name of a fusion module */
- unsigned long abi_version; /**< The API version of a fusion module */
-
- mmi_fusion_module_data *(*fusion_init)(void);
- void (*fusion_deinit)(mmi_fusion_module_data *fusion_data);
-};
-
-struct _mmi_fusion_handle
-{
- void *fusion_info;
- mmi_fusion_module *module_info;
- mmi_fusion_module_data *module_data;
- mmi_state state;
-};
-
-struct _mmi_fusion_module_data
-{
- mmi_state (*set_state)(mmi_state state);
- mmi_state (*get_state)(void);
-};
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//APIs for fusions
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__MMI_FUSION_IFACE_H__
+++ /dev/null
-/*
-* 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-fusion.h"
-#include "mmi-fusion-iface.h"
-#include "mmi-manager-dbg.h"
-
-#include <Ecore.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <dlfcn.h>
-#include <string.h>
-
-#define FUSION_PATH "/lib/fusion/"
-
-Eina_List *_fusion_list = NULL;
-int _loaded_fusion_cnt = 0;
-mmi_fusion_handle *_cur_fusion = NULL;
-
-int
-_fusion_load_module(const char *fusion_name)
-{
- mmi_fusion_handle *fusion = (mmi_fusion_handle *)calloc(1, sizeof(mmi_fusion_handle));
-
- if (!fusion)
- {
- LOGE("Failed to alloc fusion handle");
- return 0;
- }
-
- void *fusion_info = NULL;
- mmi_fusion_module *mmi_fusion_module_info = NULL;
-
- fusion_info = dlopen(fusion_name, RTLD_LAZY);
-
- if(!fusion_info)
- {
- LOGE("Failed to dlopen(error :%s, path :%s)!\n", dlerror(), fusion_name);
- goto err;
- }
-
- mmi_fusion_module_info = dlsym(fusion_info, "mmi_fusion_module_info");
-
- if(!mmi_fusion_module_info)
- {
- LOGE("Module(%s) dosen't have mmi_fusion_module_info \n", fusion_name);
- goto err;
- }
-
- if(!mmi_fusion_module_info->fusion_init || !mmi_fusion_module_info->fusion_deinit)
- {
- LOGE("Module(%s) doesn't have init/deinit function\n", fusion_name);
- goto err;
- }
-
- ++_loaded_fusion_cnt;
-
- fusion->fusion_info = fusion_info;
- fusion->module_info = mmi_fusion_module_info;
-
- //FIXME: init() of a fusion module needs to be called in mmi-manager
- //Right now, we initiate a fusion module found for the first time.
- if (_loaded_fusion_cnt == 1)
- {
- fusion->module_data = fusion->module_info->fusion_init();
- if (!fusion->module_data)
- {
- LOGE("Failed to init of a fusion module (name:%s) !\n", fusion->module_info->name);
- goto err;
- }
- _cur_fusion = fusion;
- }
-
- _fusion_list = eina_list_append(_fusion_list, fusion);
-
- return 1;
-
-err:
- if(fusion_info)
- dlclose(fusion_info);
-
- if(fusion)
- free(fusion);
- return 0;
-}
-
-int
-_modality_fusions_lookup(void)
-{
- int cnt = 0;
- DIR *dir;
- struct dirent *entry;
-
- dir = opendir(FUSION_PATH);
-
- if(!dir)
- {
- LOGE("no dir = %s\n", FUSION_PATH);
- return -1;
- }
-
- while((entry = readdir(dir)) != NULL)
- {
- char fusion_name[512];
- if(strstr(entry->d_name, "fusion") != NULL)
- {
- snprintf(fusion_name, sizeof(fusion_name), "%s%s", FUSION_PATH, entry->d_name);
- LOGD("Fusion full path = %s\n", fusion_name);
- cnt += _fusion_load_module(fusion_name);
- }
- }
-
- closedir(dir);
-
- return cnt;
-}
-
-mmi_fusion_handle *
-modality_fusions_get_client_fusion(mmi_client *client)
-{
- return _cur_fusion;
-}
-
-mmi_state
-modality_fusion_get_state(mmi_fusion_handle *fusion)
-{
- mmi_state state = MMI_STATE_NONE;
-
- if (!fusion)
- {
- LOGE("Given fusion handle is invalid !\n");
- return state;
- }
-
- state = fusion->module_data->get_state();
- return state;
-}
-
-mmi_state
-modality_fusion_set_state(mmi_fusion_handle *fusion, mmi_state state)
-{
- if (!fusion)
- {
- LOGE("Given fusion handle is invalid !\n");
- return MMI_STATE_NONE;
- }
-
- return fusion->module_data->set_state(state);
-}
-
-
-void
-modality_fusions_init(void)
-{
- int fusion_cnt = -1;
- fusion_cnt = _modality_fusions_lookup();
-
- if(fusion_cnt < 0)
- {
- LOGE("No find any fusion in path = %s\n", FUSION_PATH);
- return;
- }
-
- LOGD("%d fusion modules have been loaded !\n", fusion_cnt);
-}
-
-void
-modality_fusions_shutdown(void)
-{
- if(!_fusion_list)
- return;
-
- Eina_List *l = NULL;
- mmi_fusion_handle *fusion = NULL;
- EINA_LIST_FOREACH(_fusion_list, l, fusion)
- {
- if(fusion->module_info)
- {
- if(fusion->module_data)
- fusion->module_info->fusion_deinit(fusion->module_data);
- fusion->module_data = NULL;
- fusion->module_info = NULL;
- }
- if(fusion->fusion_info)
- dlclose(fusion->fusion_info);
- }
-
- _fusion_list = eina_list_free(_fusion_list);
- _fusion_list = NULL;
- _loaded_fusion_cnt = 0;
- _cur_fusion = NULL;
-}
+++ /dev/null
-/*
-* 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_FUSION_H__
-#define __MMI_FUSION_H__
-
-#include "mmi-common.h"
-#include "mmi-client.h"
-
-mmi_fusion_handle *modality_fusions_get_client_fusion(mmi_client *client);
-mmi_state modality_fusion_get_state(mmi_fusion_handle *fusion);
-mmi_state modality_fusion_set_state(mmi_fusion_handle *fusion, mmi_state state);
-
-void modality_fusions_init(void);
-void modality_fusions_shutdown(void);
-
-#endif //__MMI_FUSION_H__
+++ /dev/null
-/*
-* 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 <Ecore.h>
-#include <json-glib/json-glib.h>
-
-#include "mmi-manager.h"
-#include "iu/mmi_iu_log.h"
-#include "iu/mmi_iu.h"
-
-#define APP_ID "org.tizen.test"
-
-enum event_handlers {
- EVENT_HANDLER_FOCUS_CHANGE,
- EVENT_HANDLER_STATE_CHANGE,
- EVENT_HANDLER_KEY,
- EVENT_HANDLER_GESTURE,
- EVENT_HANDLER_VOICE,
- EVENT_HANDLER_VISION,
- EVENT_HANDLER_MAX
-};
-
-static Ecore_Event_Handler *_event_handlers[EVENT_HANDLER_MAX];
-static mmi_client *g_client = NULL;
-
-static void output_intent_received_cb(const char *app_id, const char *json_data, void *user_data)
-{
- JsonParser *parser = json_parser_new();
- GError *err_msg = NULL;
- JsonNode *root = NULL;
- JsonObject *root_obj = NULL;
- const gchar *action = NULL;
-
- action_event_arg arg;
- arg.timestamp = ecore_time_get();
- char* arr[1] = { "Action" };
- arg.cmd = NULL;
- arg.args = arr;
- arg.nargs = 1;
- arg.source = NULL;
-
- json_parser_load_from_data(parser, (char *)json_data, -1, &err_msg);
- if (err_msg) {
- LOGE("failed to load json file. error message: %s\n", err_msg->message);
- goto cleanup;
- }
-
- root = json_parser_get_root(parser);
- if (root == NULL) {
- LOGE("failed to get root\n");
- goto cleanup;
- }
-
- root_obj = json_node_get_object(root);
- if (root_obj == NULL) {
- LOGE("failed to get object\n");
- goto cleanup;
- }
-
- action = json_object_get_string_member(root_obj, "Action");
- LOGD("Action: %s\n", action);
-
- if (strcmp(action, "WakeUp") == 0) {
- wakeup_event_arg arg;
- arg.type = MMI_EVENT_WAKEUP_TYPE_WAKEUP;
- arg.source = NULL;
- arg.timestamp = ecore_time_get();
-
- client_manager_send_wakeup_event(g_client, &arg);
- }
- else if (strcmp(action, "Execute") == 0) {
- arg.type = MMI_EVENT_ACTION_TYPE_EXECUTE;
- client_manager_send_action_event(g_client, &arg);
- }
- else if (strcmp(action, "Play") == 0) {
- arg.type = MMI_EVENT_ACTION_TYPE_PLAY;
- client_manager_send_action_event(g_client, &arg);
- }
- else if (strcmp(action, "Cancel") == 0) {
- arg.type = MMI_EVENT_ACTION_TYPE_CANCEL;
- client_manager_send_action_event(g_client, &arg);
- }
- else if (strcmp(action, "Pause") == 0) {
- arg.type = MMI_EVENT_ACTION_TYPE_PAUSE;
- client_manager_send_action_event(g_client, &arg);
- }
- else if (strcmp(action, "Stop") == 0) {
- arg.type = MMI_EVENT_ACTION_TYPE_STOP;
- client_manager_send_action_event(g_client, &arg);
- }
-
-cleanup:
- if (err_msg)
- g_error_free(err_msg);
-
- if (parser)
- g_object_unref(parser);
-}
-
-static Eina_Bool
-_focus_change_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_manager_event_focus_change *ev = (mmi_manager_event_focus_change *)event;
-
- LOGI("[focus change] cur focus : %p, new focus : %p", ev->cur_focus, ev->new_focus);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_state_change_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_manager_event_state_change *ev = (mmi_manager_event_state_change *)event;
- g_client = ev->client;
-
- LOGI("state : %d", ev->to_state);
- mmi_iu_set_app_state(ev->to_state);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_key_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_key *ev = (mmi_provider_event_key *)event;
-
- LOGI("[key event] code : %d, name : %s, type : %d, timestamp : %d, source: %s", ev->keycode, ev->keyname, ev->type, ev->timestamp, ev->source);
-
- if (ev->key_down) {
- mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_KEY, ev);
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_gesture_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_gesture *ev = (mmi_provider_event_gesture *)event;
-
- LOGI("[gesture event] type : %d, timestamp : %d", ev->type, ev->timestamp);
-
- mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_GESTURE, ev);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_voice_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_voice *ev = (mmi_provider_event_voice *)event;
-
- LOGI("[voice event] type : %d, timestamp : %d", ev->type, ev->timestamp);
-
- mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_VOICE, ev);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_vision_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_vision *ev = (mmi_provider_event_vision *)event;
-
- mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_KEY, ev);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static void
-init_event_handler()
-{
- _event_handlers[EVENT_HANDLER_FOCUS_CHANGE] = ecore_event_handler_add(MMI_MANAGER_EVENT_FOCUS_CHANGE,
- _focus_change_cb, NULL);
- _event_handlers[EVENT_HANDLER_STATE_CHANGE] = ecore_event_handler_add(MMI_MANAGER_EVENT_STATE_CHANGE,
- _state_change_cb, NULL);
-
- _event_handlers[EVENT_HANDLER_KEY] = ecore_event_handler_add(MMI_PROVIDER_EVENT_KEY,
- _key_event_cb, NULL);
- _event_handlers[EVENT_HANDLER_GESTURE] = ecore_event_handler_add(MMI_PROVIDER_EVENT_GESTURE,
- _gesture_event_cb, NULL);
- _event_handlers[EVENT_HANDLER_VOICE] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VOICE,
- _voice_event_cb, NULL);
- _event_handlers[EVENT_HANDLER_VISION] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VISION,
- _vision_event_cb, NULL);
-}
-
-static void
-shutdown_event_handler()
-{
- for (int i=0; i<EVENT_HANDLER_MAX; i++) {
- if (_event_handlers[i]) {
- ecore_event_handler_del(_event_handlers[i]);
- _event_handlers[i] = NULL;
- }
- }
-}
-
-int mmi_iu_bridge_init()
-{
- int ret;
-
- mmi_iu_init();
-
- init_event_handler();
-
- ret = mmi_iu_set_output_intent_received_callback(output_intent_received_cb, NULL);
- if (ret != MMI_IU_ERROR_NONE) {
- LOGE("Error code : %d", ret);
- return ret;
- }
-
- return ret;
-}
-
-int mmi_iu_bridge_shutdown()
-{
- shutdown_event_handler();
-
- int ret = mmi_iu_shutdown();
- return ret;
-}
-
+++ /dev/null
-/*
-* 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_IU_BRIDGE_H__
-#define __MMI_IU_BRIDGE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void mmi_iu_bridge_init();
-void mmi_iu_bridge_shutdown();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__MMI_IU_BRIDGE_H__
+++ /dev/null
-/*
-* 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_MANAGER_DBG_H__
-#define __MMI_MANAGER_DBG_H__
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "MMIMGR"
-
-#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_MANAGER_DBG_H__
+++ /dev/null
-/*
-* 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-manager.h"
-#include "mmi-core.h"
-#include "mmi-fusion.h"
-#include "mmi-provider.h"
-#include "mmi-common.h"
-#include "mmi-manager-dbg.h"
-#include "mmi-api-handler.h"
-#include "mmi-iu-bridge.h"
-
-#include <Ecore.h>
-#include <Eina.h>
-
-static Eina_Bool _init_done = false;
-static Eina_List *_focus_candidates = NULL;
-static int _focus_candidates_cnt = 0;
-static mmi_client* _cur_focus_client = NULL;
-Ecore_Event_Handler *_event_handlers[2];
-
-int
-mmi_manager_remove_client_from_focus_candidates(mmi_client *client)
-{
- if (!client)
- return -1;
-
- if (client != eina_list_data_find(_focus_candidates, client))
- {
- return -1;
- }
-
- _focus_candidates = eina_list_remove(_focus_candidates, client);
- LOGI("Client(=%s) has been removed from focus_candidates !\n",
- client_manager_get_client_sender(client));
- _focus_candidates_cnt--;
- return 0;
-}
-
-int
-_add_focus_change_event(mmi_client *cur_focus, mmi_client *new_focus)
-{
- mmi_manager_event_focus_change *ev = NULL;
- ev = calloc(1, sizeof(mmi_manager_event_focus_change));
-
- if (!ev)
- {
- LOGE("Failed to allocate memory for focus change !\n");
- return -1;
- }
-
- ev->timestamp = ecore_time_get();
- ev->cur_focus = cur_focus;
- ev->new_focus = new_focus;
-
- ecore_event_add(MMI_MANAGER_EVENT_FOCUS_CHANGE, ev, NULL, NULL);
- return 0;
-}
-
-int
-mmi_manager_remove_focus_client(mmi_client *client)
-{
- mmi_client *new_focus = NULL;
-
- if (!client || (client != _cur_focus_client) || !client_manager_get_client_has_focus(client))
- {
- LOGE("Invalid client was given !\n");
- return -1;
- }
-
- new_focus = eina_list_nth(_focus_candidates, 0);
- if(new_focus)
- mmi_manager_remove_client_from_focus_candidates(new_focus);
- return _add_focus_change_event(NULL, new_focus);
-}
-
-int
-mmi_manager_set_focus_client(mmi_client *client)
-{
- if (!client)
- return -1;
-
- LOGI("...");
-
- return _add_focus_change_event(_cur_focus_client, client);
-}
-
-int
-mmi_manager_set_state(mmi_client *client, mmi_state state)
-{
- mmi_fusion_handle *fusion = NULL;
-
- if (!client)
- return -1;
-
- if (client_manager_get_client_state(client) == state)
- {
- LOGI("Given state equals to the current state(=%d) of client !\n", state);
- return 0;
- }
-
- LOGI("...");
-
- fusion = modality_fusions_get_client_fusion(client);
- if (!fusion)
- {
- LOGE("Failed to get fusion handle from client(%p)\n", client);
- return 0;
- }
-
- if (state == modality_fusion_get_state(fusion))
- {
- LOGE("Given state equals to existing state(%d) of fusion !\n", state);
- return 0;
- }
-
- if (state != modality_fusion_set_state(fusion, state))
- {
- LOGE("Failed to set state(%d) on fusion !\n", state);
- return 0;
- }
-
- mmi_manager_event_state_change *ev = NULL;
- ev = calloc(1, sizeof(mmi_manager_event_state_change));
-
- if (!ev)
- {
- LOGE("Failed to allocate memory for state change !\n");
- goto err;
- }
-
- ev->timestamp = ecore_time_get();
- ev->client = client;
- ev->from_state = client_manager_get_client_state(client);
- ev->to_state = state;
-
- ecore_event_add(MMI_MANAGER_EVENT_STATE_CHANGE, ev, NULL, NULL);
- return 0;
-err:
- return -1;
-}
-
-mmi_client *
-mmi_manager_get_focus_client(void)
-{
- return _cur_focus_client;
-}
-
-static void
-_event_init()
-{
- MMI_MANAGER_EVENT_FOCUS_CHANGE = ecore_event_type_new();
- MMI_MANAGER_EVENT_STATE_CHANGE = ecore_event_type_new();
-}
-
-static void
-_event_shutdown()
-{
- MMI_MANAGER_EVENT_FOCUS_CHANGE = -1;
- MMI_MANAGER_EVENT_STATE_CHANGE = -1;
-}
-
-static Eina_Bool
-_focus_change_cb(void *data EINA_UNUSED, int type, void *event)
-{
- int r;
- focus_event_arg arg;
-
- LOGI("...");
-
- mmi_manager_event_focus_change *ev = (mmi_manager_event_focus_change *)event;
-
- arg.type = MMI_EVENT_FOCUS_TYPE_OUT;
- arg.timestamp = ecore_time_get();
- arg.focus_in = false;
-
- if (ev->cur_focus)
- {
- r = client_manager_send_focus_event(ev->cur_focus, &arg);
- client_manager_set_client_has_focus(ev->cur_focus, false);
- if (r)
- LOGE("Failed to send focus event(=%d) to client(%p) !\n",
- MMI_EVENT_FOCUS_TYPE_OUT, ev->cur_focus);
- }
-
- arg.type = MMI_EVENT_FOCUS_TYPE_IN;
- arg.timestamp = ecore_time_get();
- arg.focus_in = true;
-
- if (ev->new_focus)
- {
- r = client_manager_send_focus_event(ev->new_focus, &arg);
- client_manager_set_client_has_focus(ev->new_focus, true);
- if (r)
- LOGE("Failed to send focus event(=%d) to client(%p) !\n",
- MMI_EVENT_FOCUS_TYPE_IN, ev->new_focus);
- }
-
- LOGI("Focused client has been changed. (%s -> %s)\n",
- ev->cur_focus ? client_manager_get_client_sender(ev->cur_focus) : "NONE",
- client_manager_get_client_sender(ev->new_focus));
-
- if (ev->cur_focus)
- {
- _focus_candidates = eina_list_prepend(_focus_candidates, ev->cur_focus);
- _focus_candidates_cnt++;
- }
-
- _cur_focus_client = ev->new_focus;
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_state_change_cb(void *data EINA_UNUSED, int type, void *event)
-{
- int r;
- state_change_event_arg arg;
-
- LOGI("...");
-
- mmi_manager_event_state_change *ev = (mmi_manager_event_state_change *)event;
-
- arg.type = MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE;
- arg.timestamp = ecore_time_get();
- arg.state = ev->to_state;
- arg.old_state = ev->from_state;
-
- if (ev->client)
- {
- if (ev->to_state != client_manager_set_client_state(ev->client, ev->to_state))
- {
- LOGE("Failed to set client state ! (client:%p, state=%d)\n",
- ev->client, ev->to_state);
- return ECORE_CALLBACK_PASS_ON;
- }
-
- r = client_manager_send_state_change_event(ev->client, &arg);
- if (r)
- LOGE("Failed to send state cnahnge event(=%d) to client(%p) !\n",
- MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE, ev->client);
- }
- else
- {
- LOGE("Abnormal state change event ! (No client info !)\n");
- return ECORE_CALLBACK_PASS_ON;
- }
-
- LOGI("State of client(%p) has been changed. (%d->%d)\n", ev->client, ev->from_state, ev->to_state);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static void
-_event_handler_init()
-{
- _event_handlers[0] = ecore_event_handler_add(MMI_MANAGER_EVENT_FOCUS_CHANGE,
- _focus_change_cb, NULL);
- _event_handlers[1] = ecore_event_handler_add(MMI_MANAGER_EVENT_STATE_CHANGE,
- _state_change_cb, NULL);
-}
-
-static void
-_event_handler_shutdown()
-{
- ecore_event_handler_del(_event_handlers[0]);
- ecore_event_handler_del(_event_handlers[1]);
-}
-
-void
-mmi_manager_init()
-{
- if (_init_done)
- return;
-
- ecore_init();
- _event_init();
-
- mmi_core_init();
- modality_providers_init();
- modality_fusions_init();
- client_manager_init();
- mmi_api_handler_init();
-
- mmi_iu_bridge_init();
- _event_handler_init();
-
- _init_done = true;
-}
-
-void
-mmi_manager_loop_begin()
-{
- ecore_main_loop_begin();
-}
-
-void
-mmi_manager_loop_end()
-{
- ecore_main_loop_quit();
-}
-
-void
-mmi_manager_shutdown()
-{
- if (!_init_done)
- return;
-
- _event_handler_shutdown();
- mmi_iu_bridge_shutdown();
-
- mmi_api_handler_shutdown();
- client_manager_shutdown();
- modality_fusions_shutdown();
- modality_providers_shutdown();
- mmi_core_shutdown();
-
- ecore_shutdown();
- _event_shutdown();
-
- _init_done = false;
-}
+++ /dev/null
-/*
-* 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_MANAGER_H__
-#define __MMI_MANAGER_H__
-
-#include "mmi-client.h"
-
-MMI_API extern int MMI_MANAGER_EVENT_FOCUS_CHANGE;
-MMI_API extern int MMI_MANAGER_EVENT_STATE_CHANGE;
-
-typedef struct
-{
- int timestamp;
- mmi_client *cur_focus;
- mmi_client *new_focus;
-} mmi_manager_event_focus_change;
-
-typedef struct
-{
- int timestamp;
- mmi_client *client;
- mmi_state from_state;
- mmi_state to_state;
-} mmi_manager_event_state_change;
-
-int mmi_manager_set_focus_client(mmi_client *client);
-int mmi_manager_set_state(mmi_client *client, mmi_state state);
-int mmi_manager_remove_client_from_focus_candidates(mmi_client *client);
-int mmi_manager_remove_focus_client(mmi_client *client);
-
-mmi_client* mmi_manager_get_focus_client(void);
-
-void mmi_manager_init(void);
-void mmi_manager_loop_begin(void);
-void mmi_manager_loop_end(void);
-void mmi_manager_shutdown(void);
-
-#endif //__MMI_MANAGER_H__
+++ /dev/null
-/*
-* 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_PROVIDER_IFACE_H__
-#define __MMI_PROVIDER_IFACE_H__
-
-#include "mmi-common.h"
-
-#define MMI_PROVIDER_ABI_MAJOR_MASK 0xFFFF0000
-#define MMI_PROVIDER_ABI_MINOR_MASK 0x0000FFFF
-
-#define MMI_PROVIDER_GET_ABI_MAJOR(m) (((m) & MMI_PROVIDER_ABI_MAJOR_MASK) >> 16)
-#define MMI_PROVIDER_GET_ABI_MINOR(m) ((m) & MMI_PROVIDER_ABI_MINOR_MASK)
-
-#define MMI_PROVIDER_SET_ABI_VERSION(major, minor) \
- ((((major) << 16) & MMI_PROVIDER_ABI_MAJOR_MASK) \
- | ((minor) & MMI_PROVIDER_ABI_MINOR_MASK))
-
-#define MMI_PROVIDER_API __attribute__ ((visibility("default")))
-
-#ifndef bool
-typedef int bool;
-#endif
-
-struct _mmi_provider_module
-{
- const char *name; /**< The name of a provider module */
- const char *so_name; /**< The shared library name of a provider module */
- const unsigned long long capabilities; /**< The capabilities provided by a provider module */
- unsigned long abi_version; /**< The API version of a provider module */
-
- mmi_provider_module_data *(*provider_init)(void);
- void (*provider_deinit)(mmi_provider_module_data *provider_data);
-};
-
-struct _mmi_provider_handle
-{
- void *provider_info;
- mmi_provider_module *module_info;
- mmi_provider_module_data *module_data;
- unsigned long long capabilities;
- mmi_provider_op_mode op_mode;
-};
-
-struct _mmi_provider_module_data
-{
- bool (*set_mode)(mmi_provider_op_mode mode);
- mmi_provider_op_mode (*get_mode)(void);
-};
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//APIs for providers
-int mmi_provider_register_caps(mmi_provider_handle *provider, unsigned long long caps);
-void *mmi_provider_alloc_event(int ev_type);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__MMI_PROVIDER_IFACE_H__
+++ /dev/null
-/*
-* 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-provider-iface.h"
-#include "mmi-manager-dbg.h"
-#include "mmi-common.h"
-
-#include <Ecore.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <dlfcn.h>
-#include <string.h>
-
-#define PROVIDER_PATH "/lib/provider/"
-
-Eina_List *_provider_list = NULL;
-Ecore_Event_Handler *_provider_event_handlers[4];
-
-static Eina_Bool
-_key_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_key *ev = (mmi_provider_event_key *)event;
-
- LOGI("[MMI_PROVIDER_EVENT_KEY] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
- ev->type, ev->timestamp, ev->duration, ev->confidence);
- LOGI("... keycode:%d, key_down:%d, keyname=%s, source=%s\n",
- ev->keycode, ev->key_down, ev->keyname, ev->source);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_gesture_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_gesture *ev = (mmi_provider_event_gesture *)event;
-
- LOGI("[MMI_PROVIDER_EVENT_GESTURE] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
- ev->type, ev->timestamp, ev->duration, ev->confidence);
- LOGI("... source=%s\n", ev->source);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_voice_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_voice *ev = (mmi_provider_event_voice *)event;
-
- LOGI("[MMI_PROVIDER_EVENT_VOICE] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
- ev->type, ev->timestamp, ev->duration, ev->confidence);
- LOGI("... cmd:%s, nargs:%d, source:%s\n", ev->cmd, ev->nargs, ev->source);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_vision_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
-{
- mmi_provider_event_vision *ev = (mmi_provider_event_vision *)event;
-
- LOGI("[MMI_PROVIDER_EVENT_VISION] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
- ev->type, ev->timestamp, ev->duration, ev->confidence);
- LOGI("... cmd:%s, nargs:%d, source:%s\n", ev->cmd, ev->nargs, ev->source);
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-int
-mmi_provider_set_op_mode_on_caps(unsigned long long caps, mmi_provider_op_mode mode)
-{
- Eina_List *l = NULL;
- mmi_provider_handle *provider = NULL;
-
- if (!caps)
- {
- LOGE("Given caps in empty !\n");
- return -1;
- }
-
- EINA_LIST_FOREACH(_provider_list, l, provider)
- {
- if (provider->capabilities & caps)
- {
- LOGD("Set op_mode(%d) on provider(%s) !\n", mode, provider->module_info->name);
- provider->module_data->set_mode(mode);
- }
- }
-
- return 0;
-}
-
-int
-mmi_provider_register_caps(mmi_provider_handle *provider, unsigned long long caps)
-{
- if (!provider)
- {
- LOGE("Given provider is invalid !\n");
- return -1;
- }
-
- if (!caps)
- {
- LOGE("Given caps is invalid ! (caps=%lld)\n", caps);
- return -1;
- }
-
- /* Right now, we add the given caps to the existing caps. */
- provider->capabilities |= caps;
- return 0;
-}
-
-void *
-mmi_provider_alloc_event(int ev_type)
-{
- (void) ev_type;
-
- return (void *)0;
-}
-
-void
-_provider_load_module(const char *provider_name)
-{
- mmi_provider_handle *provider = (mmi_provider_handle *)calloc(1, sizeof(mmi_provider_handle));
-
- if (!provider)
- {
- LOGE("Failed to alloc provider handle");
- return;
- }
-
- void *provider_info = NULL;
- mmi_provider_module *mmi_provider_module_info = NULL;
- mmi_provider_module_data *provider_module_data = NULL;
-
- provider_info = dlopen(provider_name, RTLD_LAZY);
-
- if(!provider_info)
- {
- LOGE("Failed to dlopen(error :%s, path :%s)!\n", dlerror(), provider_name);
- goto err;
- }
-
- mmi_provider_module_info = dlsym(provider_info, "mmi_provider_module_info");
-
- if(!mmi_provider_module_info)
- {
- LOGE("Module(%s) dosen't have mmi_provider_module_info \n", provider_name);
- goto err;
- }
-
- if(!mmi_provider_module_info->provider_init || !mmi_provider_module_info->provider_deinit)
- {
- LOGE("Module(%s) doesn't have init/deinit function\n", provider_name);
- goto err;
- }
-
- provider_module_data = mmi_provider_module_info->provider_init();
-
- if(!provider_module_data)
- {
- LOGE("Failed to init module (%s) !\n", provider_name);
- goto err;
- }
-
- LOGI("moudle info name = %s\n", mmi_provider_module_info->name);
- provider->provider_info = provider_info;
- provider->module_info = mmi_provider_module_info;
- provider->module_data = provider_module_data;
- provider->capabilities = mmi_provider_module_info->capabilities;
- provider->op_mode = provider_module_data->get_mode();
-
- _provider_list = eina_list_append(_provider_list, provider);
- return;
-
-err:
- if(mmi_provider_module_info && mmi_provider_module_info->provider_deinit)
- mmi_provider_module_info->provider_deinit(provider_module_data);
-
- if(provider_info)
- dlclose(provider_info);
-
- if(provider)
- free(provider);
- return;
-}
-
-void
-_modality_providers_lookup(void)
-{
- DIR *dir;
- struct dirent *entry;
-
- dir = opendir(PROVIDER_PATH);
-
- if(!dir)
- {
- LOGE("no dir\n");
- return;
- }
-
- while((entry = readdir(dir)) != NULL)
- {
- char provider_name[512];
- if(strstr(entry->d_name, "libmmi_modality") != NULL)
- {
- snprintf(provider_name, sizeof(provider_name), "%s%s", PROVIDER_PATH, entry->d_name);
- LOGD("Provider full path = %s\n", provider_name);
- _provider_load_module(provider_name);
- }
- }
-
- closedir(dir);
-}
-
-static void
-_event_handler_init()
-{
- MMI_PROVIDER_EVENT_KEY = ecore_event_type_new();
- MMI_PROVIDER_EVENT_GESTURE = ecore_event_type_new();
- MMI_PROVIDER_EVENT_VOICE = ecore_event_type_new();
- MMI_PROVIDER_EVENT_VISION = ecore_event_type_new();
-
- LOGD("MMI_PROVIDER_EVENT_KEY=%d\n", MMI_PROVIDER_EVENT_KEY);
- LOGD("MMI_PROVIDER_EVENT_GESTURE=%d\n", MMI_PROVIDER_EVENT_GESTURE);
- LOGD("MMI_PROVIDER_EVENT_VOICE=%d\n", MMI_PROVIDER_EVENT_VOICE);
- LOGD("MMI_PROVIDER_EVENT_VISION=%d\n", MMI_PROVIDER_EVENT_VISION);
-
- //For debugging
- _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_KEY,
- _key_provider_event_cb, NULL);
- _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_GESTURE,
- _gesture_provider_event_cb, NULL);
- _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VOICE,
- _voice_provider_event_cb, NULL);
- _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VISION,
- _vision_provider_event_cb, NULL);
-}
-
-static void
-_event_handler_shutdown()
-{
- //For debugging
- ecore_event_handler_del(_provider_event_handlers[0]);
- ecore_event_handler_del(_provider_event_handlers[1]);
- ecore_event_handler_del(_provider_event_handlers[2]);
- ecore_event_handler_del(_provider_event_handlers[3]);
-
- MMI_PROVIDER_EVENT_KEY = -1;
- MMI_PROVIDER_EVENT_GESTURE = -1;
- MMI_PROVIDER_EVENT_VOICE = -1;
- MMI_PROVIDER_EVENT_VISION = -1;
-
- LOGD("MMI_PROVIDER_EVENT_KEY=%d\n", MMI_PROVIDER_EVENT_KEY);
- LOGD("MMI_PROVIDER_EVENT_GESTURE=%d\n", MMI_PROVIDER_EVENT_GESTURE);
- LOGD("MMI_PROVIDER_EVENT_VOICE=%d\n", MMI_PROVIDER_EVENT_VOICE);
- LOGD("MMI_PROVIDER_EVENT_VISION=%d\n", MMI_PROVIDER_EVENT_VISION);
-}
-
-void
-modality_providers_init(void)
-{
- //Lookup and init modality providers
- _event_handler_init();
- _modality_providers_lookup();
-}
-
-void
-modality_providers_shutdown(void)
-{
- _event_handler_shutdown();
-
- //Do shutdown for intialized providers
- if(!_provider_list)
- return;
-
- Eina_List *l = NULL;
- mmi_provider_handle *provider = NULL;
- EINA_LIST_FOREACH(_provider_list, l, provider)
- {
- if(provider->module_info)
- {
- if(provider->module_data)
- provider->module_info->provider_deinit(provider->module_data);
- provider->module_data = NULL;
- provider->module_info = NULL;
- }
- if(provider->provider_info)
- dlclose(provider->provider_info);
- }
-
- _provider_list = eina_list_free(_provider_list);
- _provider_list = NULL;
-}
+++ /dev/null
-/*
-* 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_PROVIDER_H__
-#define __MMI_PROVIDER_H__
-
-#include "mmi-common.h"
-
-int mmi_provider_set_op_mode_on_caps(unsigned long long caps, mmi_provider_op_mode mode);
-
-void modality_providers_init(void);
-void modality_providers_shutdown(void);
-
-#endif //__MMI_PROVIDER_H__
--- /dev/null
+/*
+ * Generated by tidlc 1.4.9.
+ */
+
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <glib.h>
+#include <dlog.h>
+#include <rpc-port.h>
+#include <rpc-port-parcel.h>
+
+#include "mmifw_stub.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "RPC_PORT_STUB"
+
+#ifdef _E
+#undef _E
+#endif
+
+#ifdef _W
+#undef _W
+#endif
+
+#ifdef _I
+#undef _I
+#endif
+
+#ifdef _D
+#undef _D
+#endif
+
+#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+typedef int (*stub_method)(rpc_port_h, rpc_port_parcel_h, void *data);
+
+struct focus_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ bool focus_in;
+};
+
+static void __focus_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_focus_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_bool(parcel, h->focus_in);
+}
+
+static void __focus_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_focus_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_bool(parcel, &h->focus_in);
+}
+
+int rpc_port_focus_event_create(rpc_port_focus_event_h *h)
+{
+ struct focus_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct focus_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __focus_event_to;
+ handle->parcelable.from = __focus_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_focus_event_destroy(rpc_port_focus_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_focus_event_clone(rpc_port_focus_event_h h, rpc_port_focus_event_h *clone)
+{
+ rpc_port_focus_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_focus_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create focus_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ handle->focus_in = h->focus_in;
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_focus_event_set_type(rpc_port_focus_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_focus_event_set_timestamp(rpc_port_focus_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_focus_event_set_focus_in(rpc_port_focus_event_h h, bool focus_in)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->focus_in = focus_in;
+ return 0;
+}
+
+int rpc_port_focus_event_get_type(rpc_port_focus_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_focus_event_get_timestamp(rpc_port_focus_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_focus_event_get_focus_in(rpc_port_focus_event_h h, bool *focus_in)
+{
+ if (!h || !focus_in) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *focus_in = h->focus_in;
+ return 0;
+}
+
+struct state_change_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ int state;
+ int old_state;
+};
+
+static void __state_change_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_state_change_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_int32(parcel, h->state);
+ rpc_port_parcel_write_int32(parcel, h->old_state);
+}
+
+static void __state_change_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_state_change_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_int32(parcel, &h->state);
+ rpc_port_parcel_read_int32(parcel, &h->old_state);
+}
+
+int rpc_port_state_change_event_create(rpc_port_state_change_event_h *h)
+{
+ struct state_change_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct state_change_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __state_change_event_to;
+ handle->parcelable.from = __state_change_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_state_change_event_destroy(rpc_port_state_change_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_state_change_event_clone(rpc_port_state_change_event_h h, rpc_port_state_change_event_h *clone)
+{
+ rpc_port_state_change_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_state_change_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create state_change_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ handle->state = h->state;
+ handle->old_state = h->old_state;
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_state_change_event_set_type(rpc_port_state_change_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_state_change_event_set_timestamp(rpc_port_state_change_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_state_change_event_set_state(rpc_port_state_change_event_h h, int state)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->state = state;
+ return 0;
+}
+
+int rpc_port_state_change_event_set_old_state(rpc_port_state_change_event_h h, int old_state)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->old_state = old_state;
+ return 0;
+}
+
+int rpc_port_state_change_event_get_type(rpc_port_state_change_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_state_change_event_get_timestamp(rpc_port_state_change_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_state_change_event_get_state(rpc_port_state_change_event_h h, int *state)
+{
+ if (!h || !state) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *state = h->state;
+ return 0;
+}
+
+int rpc_port_state_change_event_get_old_state(rpc_port_state_change_event_h h, int *old_state)
+{
+ if (!h || !old_state) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *old_state = h->old_state;
+ return 0;
+}
+
+struct wakeup_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ char *source;
+};
+
+static void __wakeup_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_wakeup_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
+}
+
+static void __wakeup_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_wakeup_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_string(parcel, &h->source);
+}
+
+int rpc_port_wakeup_event_create(rpc_port_wakeup_event_h *h)
+{
+ struct wakeup_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct wakeup_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __wakeup_event_to;
+ handle->parcelable.from = __wakeup_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_wakeup_event_destroy(rpc_port_wakeup_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source)
+ free(h->source);
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_wakeup_event_clone(rpc_port_wakeup_event_h h, rpc_port_wakeup_event_h *clone)
+{
+ rpc_port_wakeup_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_wakeup_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create wakeup_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ if (h->source) {
+ handle->source = strdup(h->source);
+ if (!handle->source) {
+ _E("Failed to duplicate h->source");
+ rpc_port_wakeup_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_wakeup_event_set_type(rpc_port_wakeup_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_wakeup_event_set_timestamp(rpc_port_wakeup_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_wakeup_event_set_source(rpc_port_wakeup_event_h h, const char *source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source) {
+ free(h->source);
+ h->source = NULL;
+ }
+
+ h->source = strdup(source);
+ if (!h->source) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_wakeup_event_get_type(rpc_port_wakeup_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_wakeup_event_get_timestamp(rpc_port_wakeup_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_wakeup_event_get_source(rpc_port_wakeup_event_h h, char **source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->source) {
+ _E("Invalid parameter: h->source is NULL");
+ return -1;
+ }
+
+ *source = strdup(h->source);
+ if (*source == NULL) {
+ _E("Failed to duplicate source");
+ return -1;
+ }
+
+ return 0;
+}
+
+struct key_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ bool key_down;
+ int keycode;
+ char *keyname;
+ char *source;
+};
+
+static void __key_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_key_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_bool(parcel, h->key_down);
+ rpc_port_parcel_write_int32(parcel, h->keycode);
+ rpc_port_parcel_write_string(parcel, h->keyname ? h->keyname : "");
+ rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
+}
+
+static void __key_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_key_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_bool(parcel, &h->key_down);
+ rpc_port_parcel_read_int32(parcel, &h->keycode);
+ rpc_port_parcel_read_string(parcel, &h->keyname);
+ rpc_port_parcel_read_string(parcel, &h->source);
+}
+
+int rpc_port_key_event_create(rpc_port_key_event_h *h)
+{
+ struct key_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct key_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __key_event_to;
+ handle->parcelable.from = __key_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_key_event_destroy(rpc_port_key_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->keyname)
+ free(h->keyname);
+
+ if (h->source)
+ free(h->source);
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_key_event_clone(rpc_port_key_event_h h, rpc_port_key_event_h *clone)
+{
+ rpc_port_key_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_key_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create key_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ handle->key_down = h->key_down;
+ handle->keycode = h->keycode;
+ if (h->keyname) {
+ handle->keyname = strdup(h->keyname);
+ if (!handle->keyname) {
+ _E("Failed to duplicate h->keyname");
+ rpc_port_key_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ if (h->source) {
+ handle->source = strdup(h->source);
+ if (!handle->source) {
+ _E("Failed to duplicate h->source");
+ rpc_port_key_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_key_event_set_type(rpc_port_key_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_key_event_set_timestamp(rpc_port_key_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_key_event_set_key_down(rpc_port_key_event_h h, bool key_down)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->key_down = key_down;
+ return 0;
+}
+
+int rpc_port_key_event_set_keycode(rpc_port_key_event_h h, int keycode)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->keycode = keycode;
+ return 0;
+}
+
+int rpc_port_key_event_set_keyname(rpc_port_key_event_h h, const char *keyname)
+{
+ if (!h || !keyname) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->keyname) {
+ free(h->keyname);
+ h->keyname = NULL;
+ }
+
+ h->keyname = strdup(keyname);
+ if (!h->keyname) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_key_event_set_source(rpc_port_key_event_h h, const char *source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source) {
+ free(h->source);
+ h->source = NULL;
+ }
+
+ h->source = strdup(source);
+ if (!h->source) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_key_event_get_type(rpc_port_key_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_key_event_get_timestamp(rpc_port_key_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_key_event_get_key_down(rpc_port_key_event_h h, bool *key_down)
+{
+ if (!h || !key_down) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *key_down = h->key_down;
+ return 0;
+}
+
+int rpc_port_key_event_get_keycode(rpc_port_key_event_h h, int *keycode)
+{
+ if (!h || !keycode) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *keycode = h->keycode;
+ return 0;
+}
+
+int rpc_port_key_event_get_keyname(rpc_port_key_event_h h, char **keyname)
+{
+ if (!h || !keyname) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->keyname) {
+ _E("Invalid parameter: h->keyname is NULL");
+ return -1;
+ }
+
+ *keyname = strdup(h->keyname);
+ if (*keyname == NULL) {
+ _E("Failed to duplicate keyname");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_key_event_get_source(rpc_port_key_event_h h, char **source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->source) {
+ _E("Invalid parameter: h->source is NULL");
+ return -1;
+ }
+
+ *source = strdup(h->source);
+ if (*source == NULL) {
+ _E("Failed to duplicate source");
+ return -1;
+ }
+
+ return 0;
+}
+
+struct gesture_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ char *source;
+};
+
+static void __gesture_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_gesture_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
+}
+
+static void __gesture_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_gesture_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_string(parcel, &h->source);
+}
+
+int rpc_port_gesture_event_create(rpc_port_gesture_event_h *h)
+{
+ struct gesture_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct gesture_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __gesture_event_to;
+ handle->parcelable.from = __gesture_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_gesture_event_destroy(rpc_port_gesture_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source)
+ free(h->source);
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_gesture_event_clone(rpc_port_gesture_event_h h, rpc_port_gesture_event_h *clone)
+{
+ rpc_port_gesture_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_gesture_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create gesture_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ if (h->source) {
+ handle->source = strdup(h->source);
+ if (!handle->source) {
+ _E("Failed to duplicate h->source");
+ rpc_port_gesture_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_gesture_event_set_type(rpc_port_gesture_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_gesture_event_set_timestamp(rpc_port_gesture_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_gesture_event_set_source(rpc_port_gesture_event_h h, const char *source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source) {
+ free(h->source);
+ h->source = NULL;
+ }
+
+ h->source = strdup(source);
+ if (!h->source) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_gesture_event_get_type(rpc_port_gesture_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_gesture_event_get_timestamp(rpc_port_gesture_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_gesture_event_get_source(rpc_port_gesture_event_h h, char **source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->source) {
+ _E("Invalid parameter: h->source is NULL");
+ return -1;
+ }
+
+ *source = strdup(h->source);
+ if (*source == NULL) {
+ _E("Failed to duplicate source");
+ return -1;
+ }
+
+ return 0;
+}
+
+struct voice_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ char *source;
+};
+
+static void __voice_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_voice_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
+}
+
+static void __voice_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_voice_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_string(parcel, &h->source);
+}
+
+int rpc_port_voice_event_create(rpc_port_voice_event_h *h)
+{
+ struct voice_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct voice_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __voice_event_to;
+ handle->parcelable.from = __voice_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_voice_event_destroy(rpc_port_voice_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source)
+ free(h->source);
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_voice_event_clone(rpc_port_voice_event_h h, rpc_port_voice_event_h *clone)
+{
+ rpc_port_voice_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_voice_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create voice_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ if (h->source) {
+ handle->source = strdup(h->source);
+ if (!handle->source) {
+ _E("Failed to duplicate h->source");
+ rpc_port_voice_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_voice_event_set_type(rpc_port_voice_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_voice_event_set_timestamp(rpc_port_voice_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_voice_event_set_source(rpc_port_voice_event_h h, const char *source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source) {
+ free(h->source);
+ h->source = NULL;
+ }
+
+ h->source = strdup(source);
+ if (!h->source) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_voice_event_get_type(rpc_port_voice_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_voice_event_get_timestamp(rpc_port_voice_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_voice_event_get_source(rpc_port_voice_event_h h, char **source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->source) {
+ _E("Invalid parameter: h->source is NULL");
+ return -1;
+ }
+
+ *source = strdup(h->source);
+ if (*source == NULL) {
+ _E("Failed to duplicate source");
+ return -1;
+ }
+
+ return 0;
+}
+
+struct action_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ char *cmd;
+ char **args;
+ int args_size;
+ int nargs;
+ char *source;
+};
+
+static void __action_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_action_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_string(parcel, h->cmd ? h->cmd : "");
+ rpc_port_parcel_write_array_count(parcel, h->args_size);
+ do {
+ for (int i = 0; i < h->args_size; i++) {
+ rpc_port_parcel_write_string(parcel, h->args[i] ? h->args[i] : "");
+ }
+ } while (0);
+
+ rpc_port_parcel_write_int32(parcel, h->nargs);
+ rpc_port_parcel_write_string(parcel, h->source ? h->source : "");
+}
+
+static void __action_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_action_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_string(parcel, &h->cmd);
+
+ do {
+ rpc_port_parcel_read_array_count(parcel, &h->args_size);
+
+ h->args = calloc(h->args_size, sizeof(*h->args));
+ if (!h->args) {
+ _E("Out of memory");
+ return;
+ }
+
+ for (int i = 0; i < h->args_size; i++) {
+ char *value = NULL;
+
+ rpc_port_parcel_read_string(parcel, &value);
+ h->args[i] = value;
+ }
+ } while (0);
+
+ rpc_port_parcel_read_int32(parcel, &h->nargs);
+ rpc_port_parcel_read_string(parcel, &h->source);
+}
+
+int rpc_port_action_event_create(rpc_port_action_event_h *h)
+{
+ struct action_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct action_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __action_event_to;
+ handle->parcelable.from = __action_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_action_event_destroy(rpc_port_action_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->cmd)
+ free(h->cmd);
+
+ do {
+ for (int j = 0; j < h->args_size; j++) {
+ if (h->args[j])
+ free(h->args[j]);
+ }
+ free(h->args);
+ } while (0);
+ if (h->source)
+ free(h->source);
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_action_event_clone(rpc_port_action_event_h h, rpc_port_action_event_h *clone)
+{
+ rpc_port_action_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_action_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create action_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ if (h->cmd) {
+ handle->cmd = strdup(h->cmd);
+ if (!handle->cmd) {
+ _E("Failed to duplicate h->cmd");
+ rpc_port_action_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ do {
+ if (h->args_size == 0) {
+ _W("args is empty");
+ break;
+ }
+
+ handle->args = calloc(h->args_size, sizeof(*h->args));
+ if (!handle->args) {
+ _E("Out of memory");
+ rpc_port_action_event_destroy(handle);
+ return -1;
+ }
+ handle->args_size = h->args_size;
+
+ for (int i = 0; i < h->args_size; i++) {
+ handle->args[i] = strdup(h->args[i]);
+ }
+ } while (0);
+
+ handle->nargs = h->nargs;
+ if (h->source) {
+ handle->source = strdup(h->source);
+ if (!handle->source) {
+ _E("Failed to duplicate h->source");
+ rpc_port_action_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_action_event_set_type(rpc_port_action_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_action_event_set_timestamp(rpc_port_action_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_action_event_set_cmd(rpc_port_action_event_h h, const char *cmd)
+{
+ if (!h || !cmd) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->cmd) {
+ free(h->cmd);
+ h->cmd = NULL;
+ }
+
+ h->cmd = strdup(cmd);
+ if (!h->cmd) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_action_event_set_args(rpc_port_action_event_h h, char **args, int args_size)
+{
+ if (!h || !args) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ do {
+ for (int j = 0; j < h->args_size; j++) {
+ if (h->args[j])
+ free(h->args[j]);
+ }
+ free(h->args);
+ } while (0);
+
+ h->args = NULL;
+
+ do {
+ h->args = calloc(args_size, sizeof(*args));
+ if (!h->args) {
+ _E("Out of memory");
+ return -1;
+ }
+ h->args_size = args_size;
+
+ for (int i = 0; i < h->args_size; i++) {
+ h->args[i] = strdup(args[i]);
+ }
+ } while (0);
+
+ return 0;
+}
+
+int rpc_port_action_event_set_nargs(rpc_port_action_event_h h, int nargs)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->nargs = nargs;
+ return 0;
+}
+
+int rpc_port_action_event_set_source(rpc_port_action_event_h h, const char *source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->source) {
+ free(h->source);
+ h->source = NULL;
+ }
+
+ h->source = strdup(source);
+ if (!h->source) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_action_event_get_type(rpc_port_action_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_action_event_get_timestamp(rpc_port_action_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_action_event_get_cmd(rpc_port_action_event_h h, char **cmd)
+{
+ if (!h || !cmd) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->cmd) {
+ _E("Invalid parameter: h->cmd is NULL");
+ return -1;
+ }
+
+ *cmd = strdup(h->cmd);
+ if (*cmd == NULL) {
+ _E("Failed to duplicate cmd");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_action_event_get_args(rpc_port_action_event_h h, char ***args, int *args_size)
+{
+ if (!h || !args || !args_size) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ do {
+ if (h->args_size == 0) {
+ _W("args is empty");
+ break;
+ }
+
+ *args = calloc(h->args_size, sizeof(*h->args));
+ if (!*args) {
+ _E("Out of memory");
+ return -1;
+ }
+ *args_size = h->args_size;
+
+ for (int i = 0; i < h->args_size; i++) {
+ (*args)[i] = strdup(h->args[i]);
+ }
+ } while (0);
+
+ return 0;
+}
+
+int rpc_port_action_event_get_nargs(rpc_port_action_event_h h, int *nargs)
+{
+ if (!h || !nargs) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *nargs = h->nargs;
+ return 0;
+}
+
+int rpc_port_action_event_get_source(rpc_port_action_event_h h, char **source)
+{
+ if (!h || !source) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->source) {
+ _E("Invalid parameter: h->source is NULL");
+ return -1;
+ }
+
+ *source = strdup(h->source);
+ if (*source == NULL) {
+ _E("Failed to duplicate source");
+ return -1;
+ }
+
+ return 0;
+}
+
+struct feedback_event_s {
+ rpc_port_parcelable_t parcelable;
+ int type;
+ int timestamp;
+ char *feedback;
+ char *comment;
+};
+
+static void __feedback_event_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_feedback_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->type);
+ rpc_port_parcel_write_int32(parcel, h->timestamp);
+ rpc_port_parcel_write_string(parcel, h->feedback ? h->feedback : "");
+ rpc_port_parcel_write_string(parcel, h->comment ? h->comment : "");
+}
+
+static void __feedback_event_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_feedback_event_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->type);
+ rpc_port_parcel_read_int32(parcel, &h->timestamp);
+ rpc_port_parcel_read_string(parcel, &h->feedback);
+ rpc_port_parcel_read_string(parcel, &h->comment);
+}
+
+int rpc_port_feedback_event_create(rpc_port_feedback_event_h *h)
+{
+ struct feedback_event_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct feedback_event_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __feedback_event_to;
+ handle->parcelable.from = __feedback_event_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_feedback_event_destroy(rpc_port_feedback_event_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->feedback)
+ free(h->feedback);
+
+ if (h->comment)
+ free(h->comment);
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_feedback_event_clone(rpc_port_feedback_event_h h, rpc_port_feedback_event_h *clone)
+{
+ rpc_port_feedback_event_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_feedback_event_create(&handle);
+ if (!handle) {
+ _E("Failed to create feedback_event handle");
+ return -1;
+ }
+
+ handle->type = h->type;
+ handle->timestamp = h->timestamp;
+ if (h->feedback) {
+ handle->feedback = strdup(h->feedback);
+ if (!handle->feedback) {
+ _E("Failed to duplicate h->feedback");
+ rpc_port_feedback_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ if (h->comment) {
+ handle->comment = strdup(h->comment);
+ if (!handle->comment) {
+ _E("Failed to duplicate h->comment");
+ rpc_port_feedback_event_destroy(handle);
+ return -1;
+ }
+ }
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_feedback_event_set_type(rpc_port_feedback_event_h h, int type)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->type = type;
+ return 0;
+}
+
+int rpc_port_feedback_event_set_timestamp(rpc_port_feedback_event_h h, int timestamp)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->timestamp = timestamp;
+ return 0;
+}
+
+int rpc_port_feedback_event_set_feedback(rpc_port_feedback_event_h h, const char *feedback)
+{
+ if (!h || !feedback) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->feedback) {
+ free(h->feedback);
+ h->feedback = NULL;
+ }
+
+ h->feedback = strdup(feedback);
+ if (!h->feedback) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_feedback_event_set_comment(rpc_port_feedback_event_h h, const char *comment)
+{
+ if (!h || !comment) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->comment) {
+ free(h->comment);
+ h->comment = NULL;
+ }
+
+ h->comment = strdup(comment);
+ if (!h->comment) {
+ _E("Failed to duplicate data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_feedback_event_get_type(rpc_port_feedback_event_h h, int *type)
+{
+ if (!h || !type) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *type = h->type;
+ return 0;
+}
+
+int rpc_port_feedback_event_get_timestamp(rpc_port_feedback_event_h h, int *timestamp)
+{
+ if (!h || !timestamp) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *timestamp = h->timestamp;
+ return 0;
+}
+
+int rpc_port_feedback_event_get_feedback(rpc_port_feedback_event_h h, char **feedback)
+{
+ if (!h || !feedback) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->feedback) {
+ _E("Invalid parameter: h->feedback is NULL");
+ return -1;
+ }
+
+ *feedback = strdup(h->feedback);
+ if (*feedback == NULL) {
+ _E("Failed to duplicate feedback");
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_port_feedback_event_get_comment(rpc_port_feedback_event_h h, char **comment)
+{
+ if (!h || !comment) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!h->comment) {
+ _E("Invalid parameter: h->comment is NULL");
+ return -1;
+ }
+
+ *comment = strdup(h->comment);
+ if (*comment == NULL) {
+ _E("Failed to duplicate comment");
+ return -1;
+ }
+
+ return 0;
+}
+
+struct array_string_s {
+ rpc_port_parcelable_t parcelable;
+ char **array_strings;
+ int array_strings_size;
+};
+
+static void __array_string_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_array_string_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_array_count(parcel, h->array_strings_size);
+ do {
+ for (int i = 0; i < h->array_strings_size; i++) {
+ rpc_port_parcel_write_string(parcel, h->array_strings[i] ? h->array_strings[i] : "");
+ }
+ } while (0);
+}
+
+static void __array_string_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_array_string_h h = data;
+
+ if (!parcel || !h) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ do {
+ rpc_port_parcel_read_array_count(parcel, &h->array_strings_size);
+
+ h->array_strings = calloc(h->array_strings_size, sizeof(*h->array_strings));
+ if (!h->array_strings) {
+ _E("Out of memory");
+ return;
+ }
+
+ for (int i = 0; i < h->array_strings_size; i++) {
+ char *value = NULL;
+
+ rpc_port_parcel_read_string(parcel, &value);
+ h->array_strings[i] = value;
+ }
+ } while (0);
+}
+
+int rpc_port_array_string_create(rpc_port_array_string_h *h)
+{
+ struct array_string_s *handle;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct array_string_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __array_string_to;
+ handle->parcelable.from = __array_string_from;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_array_string_destroy(rpc_port_array_string_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ do {
+ for (int j = 0; j < h->array_strings_size; j++) {
+ if (h->array_strings[j])
+ free(h->array_strings[j]);
+ }
+ free(h->array_strings);
+ } while (0);
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_array_string_clone(rpc_port_array_string_h h, rpc_port_array_string_h *clone)
+{
+ rpc_port_array_string_h handle = NULL;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ rpc_port_array_string_create(&handle);
+ if (!handle) {
+ _E("Failed to create array_string handle");
+ return -1;
+ }
+
+ do {
+ if (h->array_strings_size == 0) {
+ _W("array_strings is empty");
+ break;
+ }
+
+ handle->array_strings = calloc(h->array_strings_size, sizeof(*h->array_strings));
+ if (!handle->array_strings) {
+ _E("Out of memory");
+ rpc_port_array_string_destroy(handle);
+ return -1;
+ }
+ handle->array_strings_size = h->array_strings_size;
+
+ for (int i = 0; i < h->array_strings_size; i++) {
+ handle->array_strings[i] = strdup(h->array_strings[i]);
+ }
+ } while (0);
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_array_string_set_array_strings(rpc_port_array_string_h h, char **array_strings, int array_strings_size)
+{
+ if (!h || !array_strings) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ do {
+ for (int j = 0; j < h->array_strings_size; j++) {
+ if (h->array_strings[j])
+ free(h->array_strings[j]);
+ }
+ free(h->array_strings);
+ } while (0);
+
+ h->array_strings = NULL;
+
+ do {
+ h->array_strings = calloc(array_strings_size, sizeof(*array_strings));
+ if (!h->array_strings) {
+ _E("Out of memory");
+ return -1;
+ }
+ h->array_strings_size = array_strings_size;
+
+ for (int i = 0; i < h->array_strings_size; i++) {
+ h->array_strings[i] = strdup(array_strings[i]);
+ }
+ } while (0);
+
+ return 0;
+}
+
+int rpc_port_array_string_get_array_strings(rpc_port_array_string_h h, char ***array_strings, int *array_strings_size)
+{
+ if (!h || !array_strings || !array_strings_size) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ do {
+ if (h->array_strings_size == 0) {
+ _W("array_strings is empty");
+ break;
+ }
+
+ *array_strings = calloc(h->array_strings_size, sizeof(*h->array_strings));
+ if (!*array_strings) {
+ _E("Out of memory");
+ return -1;
+ }
+ *array_strings_size = h->array_strings_size;
+
+ for (int i = 0; i < h->array_strings_size; i++) {
+ (*array_strings)[i] = strdup(h->array_strings[i]);
+ }
+ } while (0);
+
+ return 0;
+}
+
+enum mmifw_method_e {
+ mmifw_METHOD_Result,
+ mmifw_METHOD_Callback,
+ mmifw_METHOD_register_cb,
+ mmifw_METHOD_deregister_cb,
+ mmifw_METHOD_get_focus,
+ mmifw_METHOD_set_state,
+};
+
+enum mmifw_delegate_e {
+ mmifw_DELEGATE_focus_event_cb = 1,
+ mmifw_DELEGATE_state_change_event_cb = 2,
+ mmifw_DELEGATE_wakeup_event_cb = 3,
+ mmifw_DELEGATE_key_event_cb = 4,
+ mmifw_DELEGATE_gesture_event_cb = 5,
+ mmifw_DELEGATE_voice_event_cb = 6,
+ mmifw_DELEGATE_action_event_cb = 7,
+ mmifw_DELEGATE_feedback_event_cb = 8,
+};
+
+static rpc_port_stub_h __mmifw_stub;
+static rpc_port_stub_mmifw_callback_s __mmifw_callback;
+static void *__mmifw_user_data;
+static GList *__mmifw_contexts;
+
+struct mmifw_context_s {
+ char *sender;
+ char *instance;
+ rpc_port_h port;
+ void *tag;
+ rpc_port_stub_mmifw_callback_s callback;
+ void *user_data;
+};
+
+static struct mmifw_context_s *__create_mmifw_context(const char *sender, const char *instance)
+{
+ struct mmifw_context_s *handle;
+
+ handle = calloc(1, sizeof(struct mmifw_context_s));
+ if (!handle) {
+ _E("Out of memory");
+ return NULL;
+ }
+
+ handle->sender = strdup(sender);
+ if (!handle->sender) {
+ _E("Out of memory");
+ free(handle);
+ return NULL;
+ }
+
+ handle->instance = strdup(instance);
+ if (!handle->instance) {
+ _E("Out of memory");
+ free(handle->sender);
+ free(handle);
+ return NULL;
+ }
+
+ handle->callback = __mmifw_callback;
+ handle->user_data = __mmifw_user_data;
+
+ return handle;
+}
+
+static void __destroy_mmifw_context(gpointer data)
+{
+ struct mmifw_context_s *handle = data;
+
+ if (!handle) {
+ _E("Critical error!");
+ return;
+ }
+
+ free(handle->instance);
+ free(handle->sender);
+
+ free(handle);
+}
+
+static struct mmifw_context_s *__find_mmifw_context(const char *instance)
+{
+ struct mmifw_context_s *handle;
+ GList *iter;
+
+ iter = __mmifw_contexts;
+ while (iter) {
+ handle = (struct mmifw_context_s *)iter->data;
+ if (!strcmp(handle->instance, instance))
+ return handle;
+ iter = g_list_next(iter);
+ }
+
+ return NULL;
+}
+
+int rpc_port_stub_mmifw_context_set_tag(rpc_port_stub_mmifw_context_h ctx, void *tag)
+{
+ if (!ctx) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ ctx->tag = tag;
+
+ return 0;
+}
+
+int rpc_port_stub_mmifw_context_get_tag(rpc_port_stub_mmifw_context_h ctx, void **tag)
+{
+ if (!ctx || !tag) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *tag = ctx->tag;
+
+ return 0;
+}
+
+int rpc_port_stub_mmifw_context_get_sender(rpc_port_stub_mmifw_context_h ctx, char **sender)
+{
+ if (!ctx || !sender) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ *sender = strdup(ctx->sender);
+ if (*sender == NULL) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ return 0;
+}
+
+struct mmifw_focus_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_focus_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_focus_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_focus_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_focus_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_focus_event_cb_create(rpc_port_mmifw_focus_event_cb_h *h)
+{
+ struct mmifw_focus_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_focus_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_focus_event_cb_to;
+ handle->parcelable.from = __mmifw_focus_event_cb_from;
+ handle->id = mmifw_DELEGATE_focus_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_focus_event_cb_destroy(rpc_port_mmifw_focus_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_focus_event_cb_clone(rpc_port_mmifw_focus_event_cb_h h, rpc_port_mmifw_focus_event_cb_h *clone)
+{
+ rpc_port_mmifw_focus_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_focus_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_focus_event_cb_invoke(rpc_port_mmifw_focus_event_cb_h h, rpc_port_focus_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_focus_event_cb_set_port(rpc_port_mmifw_focus_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+struct mmifw_state_change_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_state_change_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_state_change_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_state_change_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_state_change_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_state_change_event_cb_create(rpc_port_mmifw_state_change_event_cb_h *h)
+{
+ struct mmifw_state_change_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_state_change_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_state_change_event_cb_to;
+ handle->parcelable.from = __mmifw_state_change_event_cb_from;
+ handle->id = mmifw_DELEGATE_state_change_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_state_change_event_cb_destroy(rpc_port_mmifw_state_change_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_state_change_event_cb_clone(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_mmifw_state_change_event_cb_h *clone)
+{
+ rpc_port_mmifw_state_change_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_state_change_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_state_change_event_cb_invoke(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_state_change_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_state_change_event_cb_set_port(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+struct mmifw_wakeup_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_wakeup_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_wakeup_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_wakeup_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_wakeup_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_wakeup_event_cb_create(rpc_port_mmifw_wakeup_event_cb_h *h)
+{
+ struct mmifw_wakeup_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_wakeup_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_wakeup_event_cb_to;
+ handle->parcelable.from = __mmifw_wakeup_event_cb_from;
+ handle->id = mmifw_DELEGATE_wakeup_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_wakeup_event_cb_destroy(rpc_port_mmifw_wakeup_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_wakeup_event_cb_clone(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_mmifw_wakeup_event_cb_h *clone)
+{
+ rpc_port_mmifw_wakeup_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_wakeup_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_wakeup_event_cb_invoke(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_wakeup_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_wakeup_event_cb_set_port(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+struct mmifw_key_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_key_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_key_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_key_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_key_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_key_event_cb_create(rpc_port_mmifw_key_event_cb_h *h)
+{
+ struct mmifw_key_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_key_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_key_event_cb_to;
+ handle->parcelable.from = __mmifw_key_event_cb_from;
+ handle->id = mmifw_DELEGATE_key_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_key_event_cb_destroy(rpc_port_mmifw_key_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_key_event_cb_clone(rpc_port_mmifw_key_event_cb_h h, rpc_port_mmifw_key_event_cb_h *clone)
+{
+ rpc_port_mmifw_key_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_key_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_key_event_cb_invoke(rpc_port_mmifw_key_event_cb_h h, rpc_port_key_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_key_event_cb_set_port(rpc_port_mmifw_key_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+struct mmifw_gesture_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_gesture_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_gesture_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_gesture_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_gesture_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_gesture_event_cb_create(rpc_port_mmifw_gesture_event_cb_h *h)
+{
+ struct mmifw_gesture_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_gesture_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_gesture_event_cb_to;
+ handle->parcelable.from = __mmifw_gesture_event_cb_from;
+ handle->id = mmifw_DELEGATE_gesture_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_gesture_event_cb_destroy(rpc_port_mmifw_gesture_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_gesture_event_cb_clone(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_mmifw_gesture_event_cb_h *clone)
+{
+ rpc_port_mmifw_gesture_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_gesture_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_gesture_event_cb_invoke(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_gesture_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_gesture_event_cb_set_port(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+struct mmifw_voice_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_voice_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_voice_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_voice_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_voice_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_voice_event_cb_create(rpc_port_mmifw_voice_event_cb_h *h)
+{
+ struct mmifw_voice_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_voice_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_voice_event_cb_to;
+ handle->parcelable.from = __mmifw_voice_event_cb_from;
+ handle->id = mmifw_DELEGATE_voice_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_voice_event_cb_destroy(rpc_port_mmifw_voice_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_voice_event_cb_clone(rpc_port_mmifw_voice_event_cb_h h, rpc_port_mmifw_voice_event_cb_h *clone)
+{
+ rpc_port_mmifw_voice_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_voice_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_voice_event_cb_invoke(rpc_port_mmifw_voice_event_cb_h h, rpc_port_voice_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_voice_event_cb_set_port(rpc_port_mmifw_voice_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+struct mmifw_action_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_action_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_action_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_action_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_action_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_action_event_cb_create(rpc_port_mmifw_action_event_cb_h *h)
+{
+ struct mmifw_action_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_action_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_action_event_cb_to;
+ handle->parcelable.from = __mmifw_action_event_cb_from;
+ handle->id = mmifw_DELEGATE_action_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_action_event_cb_destroy(rpc_port_mmifw_action_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_action_event_cb_clone(rpc_port_mmifw_action_event_cb_h h, rpc_port_mmifw_action_event_cb_h *clone)
+{
+ rpc_port_mmifw_action_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_action_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_action_event_cb_invoke(rpc_port_mmifw_action_event_cb_h h, rpc_port_action_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_action_event_cb_set_port(rpc_port_mmifw_action_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+struct mmifw_feedback_event_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+};
+
+static void __mmifw_feedback_event_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_feedback_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, handle->id);
+ rpc_port_parcel_write_int32(parcel, handle->seq_id);
+ rpc_port_parcel_write_bool(parcel, handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static void __mmifw_feedback_event_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_mmifw_feedback_event_cb_h handle = data;
+
+ if (!handle) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &handle->id);
+ rpc_port_parcel_read_int32(parcel, &handle->seq_id);
+ rpc_port_parcel_read_bool(parcel, &handle->once);
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+}
+
+static int rpc_port_mmifw_feedback_event_cb_create(rpc_port_mmifw_feedback_event_cb_h *h)
+{
+ struct mmifw_feedback_event_cb_s *handle;
+ static int seq_num;
+
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_feedback_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable.to = __mmifw_feedback_event_cb_to;
+ handle->parcelable.from = __mmifw_feedback_event_cb_from;
+ handle->id = mmifw_DELEGATE_feedback_event_cb;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+
+ *h = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_feedback_event_cb_destroy(rpc_port_mmifw_feedback_event_cb_h h)
+{
+ if (!h) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ free(h);
+
+ return 0;
+}
+
+int rpc_port_mmifw_feedback_event_cb_clone(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_mmifw_feedback_event_cb_h *clone)
+{
+ rpc_port_mmifw_feedback_event_cb_h handle;
+
+ if (!h || !clone) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ handle = calloc(1, sizeof(struct mmifw_feedback_event_cb_s));
+ if (!handle) {
+ _E("Out of memory");
+ return -1;
+ }
+
+ handle->parcelable = h->parcelable;
+ handle->port = h->port;
+ handle->id = h->id;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+ _I("id(%d), seq_id(%d), once(%s)", handle->id, handle->seq_id, handle->once ? "true" : "false");
+
+ *clone = handle;
+
+ return 0;
+}
+
+int rpc_port_mmifw_feedback_event_cb_invoke(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_feedback_event_h args)
+{
+ rpc_port_parcel_h parcel = NULL;
+ int r;
+
+ if (!h || !h->port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (h->once && !h->valid) {
+ _E("Invalid callback");
+ return -1;
+ }
+
+ rpc_port_parcel_create(&parcel);
+ if (!parcel) {
+ _E("Failed to create parcel");
+ return -1;
+ }
+
+ rpc_port_parcel_write_int32(parcel, mmifw_METHOD_Callback);
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_write(parcel, &args->parcelable, args);
+
+ r = rpc_port_parcel_send(parcel, h->port);
+ rpc_port_parcel_destroy(parcel);
+ h->valid = false;
+
+ return r;
+}
+
+int rpc_port_mmifw_feedback_event_cb_set_port(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_h port)
+{
+ if (!h || !port) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ h->port = port;
+
+ return 0;
+}
+
+static int __mmifw_method_register_cb(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_mmifw_context_h context = data;
+ rpc_port_h callback_port;
+ int r;
+
+ r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
+ if (r != 0) {
+ _E("Failed to get callback port");
+ return -1;
+ }
+
+ rpc_port_mmifw_focus_event_cb_h focus_cb = NULL;
+ rpc_port_mmifw_state_change_event_cb_h state_cb = NULL;
+ rpc_port_mmifw_wakeup_event_cb_h wakeup_cb = NULL;
+ rpc_port_mmifw_key_event_cb_h key_cb = NULL;
+ rpc_port_mmifw_gesture_event_cb_h gesture_cb = NULL;
+ rpc_port_mmifw_voice_event_cb_h voice_cb = NULL;
+ rpc_port_mmifw_action_event_cb_h action_cb = NULL;
+ rpc_port_mmifw_feedback_event_cb_h feedback_cb = NULL;
+
+ rpc_port_mmifw_focus_event_cb_create(&focus_cb);
+
+ if (!focus_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_focus_event_cb_set_port(focus_cb, callback_port);
+ rpc_port_parcel_read(parcel, &focus_cb->parcelable, focus_cb);
+ rpc_port_mmifw_state_change_event_cb_create(&state_cb);
+
+ if (!state_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_state_change_event_cb_set_port(state_cb, callback_port);
+ rpc_port_parcel_read(parcel, &state_cb->parcelable, state_cb);
+ rpc_port_mmifw_wakeup_event_cb_create(&wakeup_cb);
+
+ if (!wakeup_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_wakeup_event_cb_set_port(wakeup_cb, callback_port);
+ rpc_port_parcel_read(parcel, &wakeup_cb->parcelable, wakeup_cb);
+ rpc_port_mmifw_key_event_cb_create(&key_cb);
+
+ if (!key_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_key_event_cb_set_port(key_cb, callback_port);
+ rpc_port_parcel_read(parcel, &key_cb->parcelable, key_cb);
+ rpc_port_mmifw_gesture_event_cb_create(&gesture_cb);
+
+ if (!gesture_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_gesture_event_cb_set_port(gesture_cb, callback_port);
+ rpc_port_parcel_read(parcel, &gesture_cb->parcelable, gesture_cb);
+ rpc_port_mmifw_voice_event_cb_create(&voice_cb);
+
+ if (!voice_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_voice_event_cb_set_port(voice_cb, callback_port);
+ rpc_port_parcel_read(parcel, &voice_cb->parcelable, voice_cb);
+ rpc_port_mmifw_action_event_cb_create(&action_cb);
+
+ if (!action_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_action_event_cb_set_port(action_cb, callback_port);
+ rpc_port_parcel_read(parcel, &action_cb->parcelable, action_cb);
+ rpc_port_mmifw_feedback_event_cb_create(&feedback_cb);
+
+ if (!feedback_cb) {
+ _E("Failed to create handle");
+ return -1;
+ }
+
+ rpc_port_mmifw_feedback_event_cb_set_port(feedback_cb, callback_port);
+ rpc_port_parcel_read(parcel, &feedback_cb->parcelable, feedback_cb);
+
+ int ret = context->callback.register_cb(context, focus_cb, state_cb, wakeup_cb, key_cb, gesture_cb, voice_cb, action_cb, feedback_cb, context->user_data);
+ do {
+ rpc_port_parcel_h result;
+
+ rpc_port_parcel_create(&result);
+ rpc_port_parcel_write_int32(result, mmifw_METHOD_Result);
+ rpc_port_parcel_write_int32(result, ret);
+ r = rpc_port_parcel_send(result, port);
+ rpc_port_parcel_destroy(result);
+ } while (0);
+
+ rpc_port_mmifw_focus_event_cb_destroy(focus_cb);
+ rpc_port_mmifw_state_change_event_cb_destroy(state_cb);
+ rpc_port_mmifw_wakeup_event_cb_destroy(wakeup_cb);
+ rpc_port_mmifw_key_event_cb_destroy(key_cb);
+ rpc_port_mmifw_gesture_event_cb_destroy(gesture_cb);
+ rpc_port_mmifw_voice_event_cb_destroy(voice_cb);
+ rpc_port_mmifw_action_event_cb_destroy(action_cb);
+ rpc_port_mmifw_feedback_event_cb_destroy(feedback_cb);
+ return r;
+}
+
+static int __mmifw_method_deregister_cb(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_mmifw_context_h context = data;
+ rpc_port_h callback_port;
+ int r;
+
+ r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
+ if (r != 0) {
+ _E("Failed to get callback port");
+ return -1;
+ }
+
+ context->callback.deregister_cb(context, context->user_data);
+
+ return r;
+}
+
+static int __mmifw_method_get_focus(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_mmifw_context_h context = data;
+ rpc_port_h callback_port;
+ int r;
+
+ r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
+ if (r != 0) {
+ _E("Failed to get callback port");
+ return -1;
+ }
+
+ context->callback.get_focus(context, context->user_data);
+
+ return r;
+}
+
+static int __mmifw_method_set_state(rpc_port_h port, rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_mmifw_context_h context = data;
+ rpc_port_h callback_port;
+ int r;
+
+ r = rpc_port_stub_get_port(__mmifw_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port);
+ if (r != 0) {
+ _E("Failed to get callback port");
+ return -1;
+ }
+
+ int state;
+
+ rpc_port_parcel_read_int32(parcel, &state);
+
+ context->callback.set_state(context, state, context->user_data);
+
+ return r;
+}
+
+static stub_method __mmifw_method_table[] = {
+ [mmifw_METHOD_register_cb] = __mmifw_method_register_cb,
+ [mmifw_METHOD_deregister_cb] = __mmifw_method_deregister_cb,
+ [mmifw_METHOD_get_focus] = __mmifw_method_get_focus,
+ [mmifw_METHOD_set_state] = __mmifw_method_set_state,
+};
+
+static void __mmifw_on_connected(const char *sender, const char *instance, void *data)
+{
+ rpc_port_stub_mmifw_context_h context;
+
+ _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance);
+ context = __create_mmifw_context(sender, instance);
+ if (!context)
+ return;
+
+ if (context->callback.create)
+ context->callback.create(context, context->user_data);
+ __mmifw_contexts = g_list_append(__mmifw_contexts, context);
+}
+
+static void __mmifw_on_disconnected(const char *sender, const char *instance, void *data)
+{
+ rpc_port_stub_mmifw_context_h context;
+
+ _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance);
+ context = __find_mmifw_context(instance);
+ if (!context)
+ return;
+
+ if (context->callback.terminate)
+ context->callback.terminate(context, context->user_data);
+ __mmifw_contexts = g_list_remove(__mmifw_contexts, context);
+ __destroy_mmifw_context(context);
+}
+
+static int __mmifw_on_received(const char *sender, const char *instance, rpc_port_h port, void *data)
+{
+ rpc_port_stub_mmifw_context_h context;
+ rpc_port_parcel_h parcel;
+ int cmd = -1;
+ int r;
+
+ _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance);
+ context = __find_mmifw_context(instance);
+ if (!context) {
+ _E("Failed to find mmifw context(%s)", instance);
+ return -1;
+ }
+
+ context->port = port;
+ r = rpc_port_parcel_create_from_port(&parcel, port);
+ if (r != 0) {
+ _E("Failed to create parcel from port");
+ return r;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &cmd);
+ if (cmd > 1 && cmd < (sizeof(__mmifw_method_table) / sizeof(__mmifw_method_table[0]))) {
+ if (__mmifw_method_table[cmd])
+ r = __mmifw_method_table[cmd](port, parcel, context);
+ } else {
+ _E("Unknown Command(%d)", cmd);
+ r = -1;
+ }
+
+ rpc_port_parcel_destroy(parcel);
+
+ return r;
+}
+
+static int __mmifw_add_privileges(void)
+{
+
+ return 0;
+}
+
+int rpc_port_stub_mmifw_register(rpc_port_stub_mmifw_callback_s *callback, void *user_data)
+{
+ int r;
+
+ if (__mmifw_stub) {
+ _W("Already exists");
+ return -1;
+ }
+
+ if (!callback) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ __mmifw_callback = *callback;
+ __mmifw_user_data = user_data;
+ r = rpc_port_stub_create(&__mmifw_stub, "mmifw");
+ if (r != 0) {
+ _E("Failed to create stub handle");
+ return r;
+ }
+
+ r = rpc_port_stub_add_received_event_cb(__mmifw_stub, __mmifw_on_received, NULL);
+ if (r != 0) {
+ _E("Failed to add received event callback");
+ rpc_port_stub_destroy(__mmifw_stub);
+ __mmifw_stub = NULL;
+ return r;
+ }
+
+ r = rpc_port_stub_add_connected_event_cb(__mmifw_stub, __mmifw_on_connected, NULL);
+ if (r != 0) {
+ _E("Failed to add connected event callback");
+ rpc_port_stub_destroy(__mmifw_stub);
+ __mmifw_stub = NULL;
+ return r;
+ }
+
+ r = rpc_port_stub_add_disconnected_event_cb(__mmifw_stub, __mmifw_on_disconnected, NULL);
+ if (r != 0) {
+ _E("Failed to add disconnected event callback");
+ rpc_port_stub_destroy(__mmifw_stub);
+ __mmifw_stub = NULL;
+ return r;
+ }
+
+ r = __mmifw_add_privileges();
+ if (r != 0) {
+ _E("Failed to add privileges");
+ rpc_port_stub_destroy(__mmifw_stub);
+ __mmifw_stub = NULL;
+ return r;
+ }
+
+ r = rpc_port_stub_listen(__mmifw_stub);
+ if (r != 0) {
+ _E("Failed to listen stub");
+ rpc_port_stub_destroy(__mmifw_stub);
+ __mmifw_stub = NULL;
+ return r;
+ }
+
+ return 0;
+}
+
+int rpc_port_stub_mmifw_unregister(void)
+{
+ int r;
+
+ if (!__mmifw_stub)
+ return -1;
+
+ if (__mmifw_contexts) {
+ g_list_free_full(__mmifw_contexts, __destroy_mmifw_context);
+ __mmifw_contexts = NULL;
+ }
+
+ r = rpc_port_stub_destroy(__mmifw_stub);
+ __mmifw_stub = NULL;
+
+ return r;
+}
+
+int rpc_port_stub_mmifw_get_client_number(unsigned int *n)
+{
+ if (!n) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (!__mmifw_stub) {
+ _E("mmifw Stub is not ready");
+ return -1;
+ }
+
+ *n = g_list_length(__mmifw_contexts);
+
+ return 0;
+}
--- /dev/null
+/*
+ * Generated by tidlc 1.4.9.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct focus_event_s *rpc_port_focus_event_h;
+
+int rpc_port_focus_event_create(rpc_port_focus_event_h *h);
+
+int rpc_port_focus_event_destroy(rpc_port_focus_event_h h);
+
+int rpc_port_focus_event_clone(rpc_port_focus_event_h h, rpc_port_focus_event_h *clone);
+
+int rpc_port_focus_event_set_type(rpc_port_focus_event_h h, int type);
+
+int rpc_port_focus_event_set_timestamp(rpc_port_focus_event_h h, int timestamp);
+
+int rpc_port_focus_event_set_focus_in(rpc_port_focus_event_h h, bool focus_in);
+
+int rpc_port_focus_event_get_type(rpc_port_focus_event_h h, int *type);
+
+int rpc_port_focus_event_get_timestamp(rpc_port_focus_event_h h, int *timestamp);
+
+int rpc_port_focus_event_get_focus_in(rpc_port_focus_event_h h, bool *focus_in);
+
+typedef struct state_change_event_s *rpc_port_state_change_event_h;
+
+int rpc_port_state_change_event_create(rpc_port_state_change_event_h *h);
+
+int rpc_port_state_change_event_destroy(rpc_port_state_change_event_h h);
+
+int rpc_port_state_change_event_clone(rpc_port_state_change_event_h h, rpc_port_state_change_event_h *clone);
+
+int rpc_port_state_change_event_set_type(rpc_port_state_change_event_h h, int type);
+
+int rpc_port_state_change_event_set_timestamp(rpc_port_state_change_event_h h, int timestamp);
+
+int rpc_port_state_change_event_set_state(rpc_port_state_change_event_h h, int state);
+
+int rpc_port_state_change_event_set_old_state(rpc_port_state_change_event_h h, int old_state);
+
+int rpc_port_state_change_event_get_type(rpc_port_state_change_event_h h, int *type);
+
+int rpc_port_state_change_event_get_timestamp(rpc_port_state_change_event_h h, int *timestamp);
+
+int rpc_port_state_change_event_get_state(rpc_port_state_change_event_h h, int *state);
+
+int rpc_port_state_change_event_get_old_state(rpc_port_state_change_event_h h, int *old_state);
+
+typedef struct wakeup_event_s *rpc_port_wakeup_event_h;
+
+int rpc_port_wakeup_event_create(rpc_port_wakeup_event_h *h);
+
+int rpc_port_wakeup_event_destroy(rpc_port_wakeup_event_h h);
+
+int rpc_port_wakeup_event_clone(rpc_port_wakeup_event_h h, rpc_port_wakeup_event_h *clone);
+
+int rpc_port_wakeup_event_set_type(rpc_port_wakeup_event_h h, int type);
+
+int rpc_port_wakeup_event_set_timestamp(rpc_port_wakeup_event_h h, int timestamp);
+
+int rpc_port_wakeup_event_set_source(rpc_port_wakeup_event_h h, const char *source);
+
+int rpc_port_wakeup_event_get_type(rpc_port_wakeup_event_h h, int *type);
+
+int rpc_port_wakeup_event_get_timestamp(rpc_port_wakeup_event_h h, int *timestamp);
+
+int rpc_port_wakeup_event_get_source(rpc_port_wakeup_event_h h, char **source);
+
+typedef struct key_event_s *rpc_port_key_event_h;
+
+int rpc_port_key_event_create(rpc_port_key_event_h *h);
+
+int rpc_port_key_event_destroy(rpc_port_key_event_h h);
+
+int rpc_port_key_event_clone(rpc_port_key_event_h h, rpc_port_key_event_h *clone);
+
+int rpc_port_key_event_set_type(rpc_port_key_event_h h, int type);
+
+int rpc_port_key_event_set_timestamp(rpc_port_key_event_h h, int timestamp);
+
+int rpc_port_key_event_set_key_down(rpc_port_key_event_h h, bool key_down);
+
+int rpc_port_key_event_set_keycode(rpc_port_key_event_h h, int keycode);
+
+int rpc_port_key_event_set_keyname(rpc_port_key_event_h h, const char *keyname);
+
+int rpc_port_key_event_set_source(rpc_port_key_event_h h, const char *source);
+
+int rpc_port_key_event_get_type(rpc_port_key_event_h h, int *type);
+
+int rpc_port_key_event_get_timestamp(rpc_port_key_event_h h, int *timestamp);
+
+int rpc_port_key_event_get_key_down(rpc_port_key_event_h h, bool *key_down);
+
+int rpc_port_key_event_get_keycode(rpc_port_key_event_h h, int *keycode);
+
+int rpc_port_key_event_get_keyname(rpc_port_key_event_h h, char **keyname);
+
+int rpc_port_key_event_get_source(rpc_port_key_event_h h, char **source);
+
+typedef struct gesture_event_s *rpc_port_gesture_event_h;
+
+int rpc_port_gesture_event_create(rpc_port_gesture_event_h *h);
+
+int rpc_port_gesture_event_destroy(rpc_port_gesture_event_h h);
+
+int rpc_port_gesture_event_clone(rpc_port_gesture_event_h h, rpc_port_gesture_event_h *clone);
+
+int rpc_port_gesture_event_set_type(rpc_port_gesture_event_h h, int type);
+
+int rpc_port_gesture_event_set_timestamp(rpc_port_gesture_event_h h, int timestamp);
+
+int rpc_port_gesture_event_set_source(rpc_port_gesture_event_h h, const char *source);
+
+int rpc_port_gesture_event_get_type(rpc_port_gesture_event_h h, int *type);
+
+int rpc_port_gesture_event_get_timestamp(rpc_port_gesture_event_h h, int *timestamp);
+
+int rpc_port_gesture_event_get_source(rpc_port_gesture_event_h h, char **source);
+
+typedef struct voice_event_s *rpc_port_voice_event_h;
+
+int rpc_port_voice_event_create(rpc_port_voice_event_h *h);
+
+int rpc_port_voice_event_destroy(rpc_port_voice_event_h h);
+
+int rpc_port_voice_event_clone(rpc_port_voice_event_h h, rpc_port_voice_event_h *clone);
+
+int rpc_port_voice_event_set_type(rpc_port_voice_event_h h, int type);
+
+int rpc_port_voice_event_set_timestamp(rpc_port_voice_event_h h, int timestamp);
+
+int rpc_port_voice_event_set_source(rpc_port_voice_event_h h, const char *source);
+
+int rpc_port_voice_event_get_type(rpc_port_voice_event_h h, int *type);
+
+int rpc_port_voice_event_get_timestamp(rpc_port_voice_event_h h, int *timestamp);
+
+int rpc_port_voice_event_get_source(rpc_port_voice_event_h h, char **source);
+
+typedef struct action_event_s *rpc_port_action_event_h;
+
+int rpc_port_action_event_create(rpc_port_action_event_h *h);
+
+int rpc_port_action_event_destroy(rpc_port_action_event_h h);
+
+int rpc_port_action_event_clone(rpc_port_action_event_h h, rpc_port_action_event_h *clone);
+
+int rpc_port_action_event_set_type(rpc_port_action_event_h h, int type);
+
+int rpc_port_action_event_set_timestamp(rpc_port_action_event_h h, int timestamp);
+
+int rpc_port_action_event_set_cmd(rpc_port_action_event_h h, const char *cmd);
+
+int rpc_port_action_event_set_args(rpc_port_action_event_h h, char **args, int args_size);
+
+int rpc_port_action_event_set_nargs(rpc_port_action_event_h h, int nargs);
+
+int rpc_port_action_event_set_source(rpc_port_action_event_h h, const char *source);
+
+int rpc_port_action_event_get_type(rpc_port_action_event_h h, int *type);
+
+int rpc_port_action_event_get_timestamp(rpc_port_action_event_h h, int *timestamp);
+
+int rpc_port_action_event_get_cmd(rpc_port_action_event_h h, char **cmd);
+
+int rpc_port_action_event_get_args(rpc_port_action_event_h h, char ***args, int *args_size);
+
+int rpc_port_action_event_get_nargs(rpc_port_action_event_h h, int *nargs);
+
+int rpc_port_action_event_get_source(rpc_port_action_event_h h, char **source);
+
+typedef struct feedback_event_s *rpc_port_feedback_event_h;
+
+int rpc_port_feedback_event_create(rpc_port_feedback_event_h *h);
+
+int rpc_port_feedback_event_destroy(rpc_port_feedback_event_h h);
+
+int rpc_port_feedback_event_clone(rpc_port_feedback_event_h h, rpc_port_feedback_event_h *clone);
+
+int rpc_port_feedback_event_set_type(rpc_port_feedback_event_h h, int type);
+
+int rpc_port_feedback_event_set_timestamp(rpc_port_feedback_event_h h, int timestamp);
+
+int rpc_port_feedback_event_set_feedback(rpc_port_feedback_event_h h, const char *feedback);
+
+int rpc_port_feedback_event_set_comment(rpc_port_feedback_event_h h, const char *comment);
+
+int rpc_port_feedback_event_get_type(rpc_port_feedback_event_h h, int *type);
+
+int rpc_port_feedback_event_get_timestamp(rpc_port_feedback_event_h h, int *timestamp);
+
+int rpc_port_feedback_event_get_feedback(rpc_port_feedback_event_h h, char **feedback);
+
+int rpc_port_feedback_event_get_comment(rpc_port_feedback_event_h h, char **comment);
+
+typedef struct array_string_s *rpc_port_array_string_h;
+
+int rpc_port_array_string_create(rpc_port_array_string_h *h);
+
+int rpc_port_array_string_destroy(rpc_port_array_string_h h);
+
+int rpc_port_array_string_clone(rpc_port_array_string_h h, rpc_port_array_string_h *clone);
+
+int rpc_port_array_string_set_array_strings(rpc_port_array_string_h h, char **array_strings, int array_strings_size);
+
+int rpc_port_array_string_get_array_strings(rpc_port_array_string_h h, char ***array_strings, int *array_strings_size);
+
+typedef struct mmifw_context_s* rpc_port_stub_mmifw_context_h;
+
+int rpc_port_stub_mmifw_context_set_tag(rpc_port_stub_mmifw_context_h ctx, void *tag);
+
+int rpc_port_stub_mmifw_context_get_tag(rpc_port_stub_mmifw_context_h ctx, void **tag);
+
+int rpc_port_stub_mmifw_context_get_sender(rpc_port_stub_mmifw_context_h ctx, char **sender);
+
+typedef struct mmifw_focus_event_cb_s *rpc_port_mmifw_focus_event_cb_h;
+
+int rpc_port_mmifw_focus_event_cb_destroy(rpc_port_mmifw_focus_event_cb_h h);
+
+int rpc_port_mmifw_focus_event_cb_clone(rpc_port_mmifw_focus_event_cb_h h, rpc_port_mmifw_focus_event_cb_h *clone);
+
+int rpc_port_mmifw_focus_event_cb_invoke(rpc_port_mmifw_focus_event_cb_h h, rpc_port_focus_event_h args);
+
+typedef struct mmifw_state_change_event_cb_s *rpc_port_mmifw_state_change_event_cb_h;
+
+int rpc_port_mmifw_state_change_event_cb_destroy(rpc_port_mmifw_state_change_event_cb_h h);
+
+int rpc_port_mmifw_state_change_event_cb_clone(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_mmifw_state_change_event_cb_h *clone);
+
+int rpc_port_mmifw_state_change_event_cb_invoke(rpc_port_mmifw_state_change_event_cb_h h, rpc_port_state_change_event_h args);
+
+typedef struct mmifw_wakeup_event_cb_s *rpc_port_mmifw_wakeup_event_cb_h;
+
+int rpc_port_mmifw_wakeup_event_cb_destroy(rpc_port_mmifw_wakeup_event_cb_h h);
+
+int rpc_port_mmifw_wakeup_event_cb_clone(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_mmifw_wakeup_event_cb_h *clone);
+
+int rpc_port_mmifw_wakeup_event_cb_invoke(rpc_port_mmifw_wakeup_event_cb_h h, rpc_port_wakeup_event_h args);
+
+typedef struct mmifw_key_event_cb_s *rpc_port_mmifw_key_event_cb_h;
+
+int rpc_port_mmifw_key_event_cb_destroy(rpc_port_mmifw_key_event_cb_h h);
+
+int rpc_port_mmifw_key_event_cb_clone(rpc_port_mmifw_key_event_cb_h h, rpc_port_mmifw_key_event_cb_h *clone);
+
+int rpc_port_mmifw_key_event_cb_invoke(rpc_port_mmifw_key_event_cb_h h, rpc_port_key_event_h args);
+
+typedef struct mmifw_gesture_event_cb_s *rpc_port_mmifw_gesture_event_cb_h;
+
+int rpc_port_mmifw_gesture_event_cb_destroy(rpc_port_mmifw_gesture_event_cb_h h);
+
+int rpc_port_mmifw_gesture_event_cb_clone(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_mmifw_gesture_event_cb_h *clone);
+
+int rpc_port_mmifw_gesture_event_cb_invoke(rpc_port_mmifw_gesture_event_cb_h h, rpc_port_gesture_event_h args);
+
+typedef struct mmifw_voice_event_cb_s *rpc_port_mmifw_voice_event_cb_h;
+
+int rpc_port_mmifw_voice_event_cb_destroy(rpc_port_mmifw_voice_event_cb_h h);
+
+int rpc_port_mmifw_voice_event_cb_clone(rpc_port_mmifw_voice_event_cb_h h, rpc_port_mmifw_voice_event_cb_h *clone);
+
+int rpc_port_mmifw_voice_event_cb_invoke(rpc_port_mmifw_voice_event_cb_h h, rpc_port_voice_event_h args);
+
+typedef struct mmifw_action_event_cb_s *rpc_port_mmifw_action_event_cb_h;
+
+int rpc_port_mmifw_action_event_cb_destroy(rpc_port_mmifw_action_event_cb_h h);
+
+int rpc_port_mmifw_action_event_cb_clone(rpc_port_mmifw_action_event_cb_h h, rpc_port_mmifw_action_event_cb_h *clone);
+
+int rpc_port_mmifw_action_event_cb_invoke(rpc_port_mmifw_action_event_cb_h h, rpc_port_action_event_h args);
+
+typedef struct mmifw_feedback_event_cb_s *rpc_port_mmifw_feedback_event_cb_h;
+
+int rpc_port_mmifw_feedback_event_cb_destroy(rpc_port_mmifw_feedback_event_cb_h h);
+
+int rpc_port_mmifw_feedback_event_cb_clone(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_mmifw_feedback_event_cb_h *clone);
+
+int rpc_port_mmifw_feedback_event_cb_invoke(rpc_port_mmifw_feedback_event_cb_h h, rpc_port_feedback_event_h args);
+
+typedef struct {
+ void (*create)(rpc_port_stub_mmifw_context_h context, void *user_data);
+ void (*terminate)(rpc_port_stub_mmifw_context_h context, void *user_data);
+
+ int (*register_cb)(rpc_port_stub_mmifw_context_h context, rpc_port_mmifw_focus_event_cb_h focus_cb, rpc_port_mmifw_state_change_event_cb_h state_cb, rpc_port_mmifw_wakeup_event_cb_h wakeup_cb, rpc_port_mmifw_key_event_cb_h key_cb, rpc_port_mmifw_gesture_event_cb_h gesture_cb, rpc_port_mmifw_voice_event_cb_h voice_cb, rpc_port_mmifw_action_event_cb_h action_cb, rpc_port_mmifw_feedback_event_cb_h feedback_cb, void *user_data);
+ void (*deregister_cb)(rpc_port_stub_mmifw_context_h context, void *user_data);
+ void (*get_focus)(rpc_port_stub_mmifw_context_h context, void *user_data);
+ void (*set_state)(rpc_port_stub_mmifw_context_h context, int state, void *user_data);
+} rpc_port_stub_mmifw_callback_s;
+
+int rpc_port_stub_mmifw_register(rpc_port_stub_mmifw_callback_s *callback, void *user_data);
+
+int rpc_port_stub_mmifw_unregister(void);
+
+int rpc_port_stub_mmifw_get_client_number(unsigned int *n);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+{
+ "IURule" : [
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressMicButton"
+ }
+ ],
+ "MMIStatus" : "Initiation",
+ "OutputIntent": {
+ "Action" : "WakeUp"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "ShowPalm"
+ }
+ ],
+ "MMIStatus": "Initiation",
+ "OutputIntent": {
+ "Action" : "WakeUp"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressUpButton"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveUp"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressDownButton"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveDown"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressRightButton"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveRight"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressLeftButton"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveLeft"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "MoveUp"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveUp"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "MoveDown"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveDown"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "MoveRight"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveRight"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "MoveLeft"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveLeft"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "HandUp"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveUp"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "HandDown"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveDown"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "HandRight"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveRight"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "HandLeft"
+ }
+ ],
+ "MMIStatus": "Exploration",
+ "OutputIntent": {
+ "Action" : "MoveLeft"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressOkButton"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Execute"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Execute"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Execute"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Play"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Play"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Yes"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Yes"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Yes"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Execute"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Yes"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Execute"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "HandPush"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Execute"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressOkButton"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Execute"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressBackButton"
+ }
+ ],
+ "MMIStatus": "Execution",
+ "OutputIntent": {
+ "Action" : "Cancel"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressBackButton"
+ }
+ ],
+ "MMIStatus": "Initiation",
+ "OutputIntent": {
+ "Action" : "Cancel"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressBackButton"
+ }
+ ],
+ "MMIStatus": "Feedback",
+ "OutputIntent": {
+ "Action" : "Cancel"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Cancel"
+ }
+ ],
+ "MMIStatus": "Feedback",
+ "OutputIntent": {
+ "Action" : "Cancel"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Back"
+ }
+ ],
+ "MMIStatus": "Feedback",
+ "OutputIntent": {
+ "Action" : "Cancel"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "WaveHandX"
+ }
+ ],
+ "MMIStatus": "Feedback",
+ "OutputIntent": {
+ "Action" : "Cancel"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Vision",
+ "Action" : "OutOfVision"
+ }
+ ],
+ "MMIStatus": "Observation",
+ "OutputIntent": {
+ "Action" : "Pause"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "KeyInput",
+ "Action" : "PressBackButton"
+ }
+ ],
+ "MMIStatus": "Termination",
+ "OutputIntent": {
+ "Action" : "Exit"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Exit"
+ }
+ ],
+ "MMIStatus": "Termination",
+ "OutputIntent": {
+ "Action" : "Exit"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Stop"
+ }
+ ],
+ "MMIStatus": "Termination",
+ "OutputIntent": {
+ "Action" : "Stop"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Voice",
+ "Action" : "Terminate"
+ }
+ ],
+ "MMIStatus": "Termination",
+ "OutputIntent": {
+ "Action" : "Terminate"
+ }
+ },
+ {
+ "InputIntents" : [
+ {
+ "Modality" : "Gesture",
+ "Action" : "FlipPalm"
+ }
+ ],
+ "MMIStatus": "Termination",
+ "OutputIntent": {
+ "Action" : "Exit"
+ }
+ }
+ ]
+}
+
--- /dev/null
+/*
+ * 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 <unistd.h>
+#include <string>
+
+#include "input_intent.h"
+
+using namespace std;
+
+InputIntent::InputIntent()
+{
+
+}
+
+InputIntent::~InputIntent()
+{
+
+}
+
+void InputIntent::set_modality(string modality)
+{
+ this->modality = modality;
+}
+
+string InputIntent::get_modality()
+{
+ return modality;
+}
+
+void InputIntent::set_action(string action)
+{
+ this->action = action;
+}
+
+string InputIntent::get_action()
+{
+ return action;
+}
+
+void InputIntent::set_input_time(int time)
+{
+ input_time = time;
+}
+
+int InputIntent::get_input_time()
+{
+ return input_time;
+}
+
+void InputIntent::set_input_duration(int duration)
+{
+ input_duration = duration;
+}
+
+int InputIntent::get_input_duration()
+{
+ return input_duration;
+}
+
+bool InputIntent::match_intent(const InputIntent &other)
+{
+ if (this->modality == other.modality &&
+ this->action == other.action)
+ return true;
+
+ return false;
+}
--- /dev/null
+/*
+ * 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 __INPUT_INTENT_H__
+#define __INPUT_INTENT_H__
+
+#include <unistd.h>
+#include <string>
+
+using namespace std;
+
+class InputIntent {
+public:
+ InputIntent();
+ virtual ~InputIntent();
+
+ void set_modality(string modality);
+ string get_modality();
+
+ void set_action(string modality);
+ string get_action();
+
+ void set_input_time(int time);
+ int get_input_time();
+
+ void set_input_duration(int duration);
+ int get_input_duration();
+
+ bool match_intent(const InputIntent &other);
+
+private:
+ string modality;
+ string action;
+ int input_time = 0;
+ int input_duration = 0;
+};
+
+#endif /* __INPUT_INTENT_H__ */
--- /dev/null
+/*
+ * 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 <unistd.h>
+#include <string>
+#include <json-glib/json-glib.h>
+#include <unordered_map>
+
+#include "mmi_iu_log.h"
+#include "mmi_iu_event.h"
+#include "intent_understanding_engine.h"
+#include "input_intent.h"
+#include "output_intent.h"
+#include "mmi-common.h"
+
+using namespace std;
+
+static unordered_map<string, string> key_action_map
+ = { { "UP", "Up" },
+ { "DOWN", "Down" },
+ { "LEFT", "Left" },
+ { "RIGHT", "Right" },
+ { "RETURN", "Ok" },
+ { "XF86Back", "Back" },
+ { "I69", "Back" },
+ };
+
+static unordered_map<int, string> voice_action_map
+ = { { MMI_EVENT_VOICE_TYPE_UP, "MoveUp" },
+ { MMI_EVENT_VOICE_TYPE_DOWN, "MoveDown" },
+ { MMI_EVENT_VOICE_TYPE_LEFT, "MoveLeft" },
+ { MMI_EVENT_VOICE_TYPE_RIGHT, "MoveRight" },
+ { MMI_EVENT_VOICE_TYPE_CANCEL, "Cancel" },
+ { MMI_EVENT_VOICE_TYPE_PLAY, "Play" },
+ { MMI_EVENT_VOICE_TYPE_YES, "Yes" },
+ { MMI_EVENT_VOICE_TYPE_EXECUTE, "Execute" },
+ { MMI_EVENT_VOICE_TYPE_BACK, "Back" },
+ { MMI_EVENT_VOICE_TYPE_EXIT, "Exit" },
+ { MMI_EVENT_VOICE_TYPE_STOP, "Stop" },
+ { MMI_EVENT_VOICE_TYPE_TERMINATE, "Terminate" },
+ };
+
+static unordered_map<int, string> gesture_action_map
+ = { { MMI_EVENT_GESTURE_TYPE_SWIPE_UP, "HandUp" },
+ { MMI_EVENT_GESTURE_TYPE_SWIPE_DOWN, "HandDown" },
+ { MMI_EVENT_GESTURE_TYPE_SWIPE_LEFT, "HandLeft" },
+ { MMI_EVENT_GESTURE_TYPE_SWIPE_RIGHT, "HandRight" },
+ { MMI_EVENT_GESTURE_TYPE_PUSH, "HandPush" },
+ //{ MMI_EVENT_GESTURE_TYPE_WAVEHANDX, "WaveHandX" },
+ //{ MMI_EVENT_GESTURE_TYPE_FLIPPALM, "FlipPalm" },
+ //{ MMI_EVENT_GESTURE_TYPE_SHOWPALM, "ShowPalm" }
+ };
+
+static unordered_map<int, string> vision_action_map
+ = { { MMI_EVENT_VISION_TYPE_USER_MOVE_AWAY, "OutOfVision" }
+ };
+
+IntentUnderstandingEngine::IntentUnderstandingEngine()
+{
+}
+
+IntentUnderstandingEngine::~IntentUnderstandingEngine()
+{
+
+}
+
+void IntentUnderstandingEngine::set_app_state(const char *state)
+{
+ if (string(state) == "Initiation")
+ application_state = MMI_STATE_INITIATION;
+ else if (string(state) == "Exploration")
+ application_state = MMI_STATE_EXPLORATION;
+ else if (string(state) == "Execution")
+ application_state = MMI_STATE_EXECUTION;
+ else if (string(state) == "Feedback")
+ application_state = MMI_STATE_FEEDBACK;
+ else if (string(state) == "Observation")
+ application_state = MMI_STATE_OBSERVATION;
+ else if (string(state) == "Termination")
+ application_state = MMI_STATE_TERMINATION;
+}
+
+void IntentUnderstandingEngine::set_app_state(mmi_state appstate)
+{
+ application_state = appstate;
+}
+
+mmi_state IntentUnderstandingEngine::get_app_state()
+{
+ return application_state;
+}
+
+bool IntentUnderstandingEngine::parse_json_data(JsonParser *parser)
+{
+ JsonNode *root = NULL;
+
+ JsonObject *root_obj = NULL;
+ JsonObject *output_intent_obj = NULL;
+ JsonObject *input_intent_obj = NULL;
+ JsonObject *iu_rule_arr_obj = NULL;
+
+ JsonArray *input_intent_array = NULL;
+ JsonArray *iu_rule_array = NULL;
+
+ const gchar *status = NULL;
+ const gchar *output_action = NULL;
+ const gchar *modality = NULL;
+ const gchar *action = NULL;
+
+ int arr_len = 0;
+
+ root = json_parser_get_root(parser);
+ if (root == NULL) {
+ _E("failed to get root");
+ return false;
+ }
+
+ root_obj = json_node_get_object(root);
+ if (root_obj == NULL) {
+ _E("failed to get object");
+ return false;
+ }
+
+ iu_rule_array = json_object_get_array_member(root_obj, "IURule");
+ if (iu_rule_array) {
+ iu_rule_list.clear();
+
+ arr_len = json_array_get_length(iu_rule_array);
+
+ for (int i = 0; i < arr_len; i++) {
+ IntentUnderstandingRule iu_rule;
+ iu_rule_arr_obj = json_array_get_object_element(iu_rule_array, i);
+ input_intent_array = json_object_get_array_member(iu_rule_arr_obj, "InputIntents");
+
+ if (input_intent_array) {
+ int input_intent_list_len = json_array_get_length(input_intent_array);
+ for (int j = 0; j < input_intent_list_len; j++) {
+ input_intent_obj = json_array_get_object_element(input_intent_array, j);
+
+ modality = json_object_get_string_member(input_intent_obj, "Modality");
+ action = json_object_get_string_member(input_intent_obj, "Action");
+
+ InputIntent intent;
+ intent.set_modality(string(modality));
+ intent.set_action(string(action));
+
+ iu_rule.add_input_intent(intent);
+ }
+ }
+
+ status = json_object_get_string_member(iu_rule_arr_obj, "MMIStatus");
+ iu_rule.set_app_state(status);
+
+ output_intent_obj = json_object_get_object_member(iu_rule_arr_obj, "OutputIntent");
+ output_action = json_object_get_string_member(output_intent_obj, "Action");
+
+ OutputIntent oi;
+ oi.set_action(output_action);
+
+ iu_rule.set_output_intent(oi);
+
+ iu_rule_list.push_back(iu_rule);
+ }
+ }
+
+ return true;
+}
+
+bool IntentUnderstandingEngine::set_rule_json_file(const char *json_file_path)
+{
+ if (!json_file_path)
+ return false;
+
+ JsonParser *parser = json_parser_new();
+ GError *err_msg = NULL;
+ bool ret = true;
+
+ json_parser_load_from_file(parser, (char *)json_file_path, &err_msg);
+ if (err_msg) {
+ _E("failed to load json file. error message: %s", err_msg->message);
+ ret = false;
+ goto cleanup;
+ }
+
+ ret = parse_json_data(parser);
+
+cleanup:
+ if (err_msg)
+ g_error_free(err_msg);
+
+ if (parser)
+ g_object_unref(parser);
+
+ return ret;
+}
+
+bool IntentUnderstandingEngine::set_rule_json_data(const char *json_data)
+{
+ if (!json_data)
+ return false;
+
+ JsonParser *parser = json_parser_new();
+ GError *err_msg = NULL;
+ bool ret = true;
+
+ json_parser_load_from_data(parser, (char *)json_data, -1, &err_msg);
+ if (err_msg) {
+ _E("failed to load json file. error message: %s", err_msg->message);
+ ret = false;
+ goto cleanup;
+ }
+
+ parse_json_data(parser);
+
+cleanup:
+ if (err_msg)
+ g_error_free(err_msg);
+
+ if (parser)
+ g_object_unref(parser);
+
+ return ret;
+}
+
+bool IntentUnderstandingEngine::set_input_intent_json_data(const char *json_data)
+{
+ JsonParser *parser = json_parser_new();
+ GError *err_msg = NULL;
+ JsonNode *root = NULL;
+ JsonObject *root_obj = NULL;
+ JsonArray *input_intent_array = NULL;
+ JsonObject *arr_obj;
+ const gchar *modality_type;
+ const gchar *action;
+
+ bool ret = true;
+ int arr_len = 0;
+ int input_time = 0, input_duration = 0;
+
+ json_parser_load_from_data(parser, (char *)json_data, -1, &err_msg);
+ if (err_msg) {
+ _E("failed to load json file. error message: %s", err_msg->message);
+ ret = false;
+ goto cleanup;
+ }
+
+ root = json_parser_get_root(parser);
+ if (root == NULL) {
+ _E("failed to get root");
+ ret = false;
+ goto cleanup;
+ }
+
+ root_obj = json_node_get_object(root);
+ if (root_obj == NULL) {
+ _E("failed to get object");
+ ret = false;
+ goto cleanup;
+ }
+
+ input_intent_array = json_object_get_array_member(root_obj, "InputIntents");
+ if (input_intent_array) {
+ input_intent_list.clear();
+
+ arr_len = json_array_get_length(input_intent_array);
+
+ for (int i = 0; i < arr_len; i++) {
+ input_time = 0, input_duration = 0;
+ arr_obj = json_array_get_object_element(input_intent_array, i);
+ modality_type = json_object_get_string_member(arr_obj, "Modality");
+ action = json_object_get_string_member(arr_obj, "Action");
+
+ if (json_object_has_member(arr_obj, "Time"))
+ input_time = json_object_get_int_member(arr_obj, "Time");
+
+ if (json_object_has_member(arr_obj, "Duration"))
+ input_duration = json_object_get_int_member(arr_obj, "Duration");
+
+ _I("### modality type: %s, action: %s, time: %d, duration: %d ###\n", modality_type, action, input_time, input_duration);
+
+ InputIntent intent;
+ intent.set_modality(string(modality_type));
+ intent.set_action(string(action));
+ intent.set_input_time(input_time);
+ intent.set_input_duration(input_duration);
+
+ input_intent_list.push_back(intent);
+ }
+ }
+
+cleanup:
+ if (err_msg)
+ g_error_free(err_msg);
+
+ if (parser)
+ g_object_unref(parser);
+
+ return ret;
+}
+
+string IntentUnderstandingEngine::convert_key_event(int type, char *keyname)
+{
+ string action;
+ string button_name;
+
+ if (!keyname)
+ return string("");
+
+ button_name = key_action_map[string(keyname)];
+ if (!button_name.empty()) {
+ action = "Press" + button_name + "Button";
+ }
+
+ return action;
+}
+
+string IntentUnderstandingEngine::convert_voice_event(int type)
+{
+ string action = voice_action_map[type];
+ return action;
+}
+
+string IntentUnderstandingEngine::convert_gesture_event(int type)
+{
+ string action = gesture_action_map[type];
+ return action;
+}
+
+string IntentUnderstandingEngine::convert_vision_event(int type)
+{
+ string action = vision_action_map[type];
+ return action;
+}
+
+bool IntentUnderstandingEngine::set_input_event(int type, void *event)
+{
+ InputIntent intent;
+ string modality_type;
+ string action;
+
+ mmi_provider_event_key *key_event;
+ mmi_provider_event_voice *voice_event;
+ mmi_provider_event_gesture *gesture_event;
+ mmi_provider_event_vision *vision_event;
+
+ if (type == MMI_PROVIDER_EVENT_KEY) {
+ modality_type = "KeyInput";
+ key_event = (mmi_provider_event_key *)event;
+ action = convert_key_event(type, key_event->keyname);
+ }
+ else if (type == MMI_PROVIDER_EVENT_VOICE) {
+ modality_type = "Voice";
+ voice_event = (mmi_provider_event_voice *)event;
+ action = convert_voice_event(voice_event->type);
+ }
+ else if (type == MMI_PROVIDER_EVENT_GESTURE) {
+ modality_type = "Gesture";
+ gesture_event = (mmi_provider_event_gesture *)event;
+ action = convert_gesture_event(gesture_event->type);
+ }
+ else if (type == MMI_PROVIDER_EVENT_VISION) {
+ modality_type = "Vision";
+ vision_event = (mmi_provider_event_vision *)event;
+ action = convert_vision_event(vision_event->type);
+ }
+
+ intent.set_modality(modality_type);
+ intent.set_action(action);
+
+ input_intent_list.push_back(intent);
+
+ return !action.empty();
+}
+
+string IntentUnderstandingEngine::get_output_intent_json_data()
+{
+ OutputIntent oi;
+ string output_json_text;
+
+ oi.set_action(get_output_intent_action());
+
+ output_json_text = oi.get_output_intent_text();
+
+ return output_json_text;
+}
+
+bool IntentUnderstandingEngine::match_input_intent(IntentUnderstandingRule iu_rule)
+{
+ unsigned int input_intent_size = input_intent_list.size();
+ unsigned int match_count = 0;
+
+ if (iu_rule.get_input_intent_size() != input_intent_size)
+ return false;
+
+ for (InputIntent it : input_intent_list)
+ {
+ if (iu_rule.find_input_intent(it))
+ {
+ match_count++;
+ break;
+ }
+ }
+
+ return input_intent_size == match_count ? true : false;
+}
+
+string IntentUnderstandingEngine::get_output_intent_action()
+{
+ if (iu_rule_list.empty()) {
+ _E("No intent understanding rule data");
+ return string("");
+ }
+
+ for (IntentUnderstandingRule iu_rule : iu_rule_list)
+ {
+ if (match_input_intent(iu_rule) && iu_rule.get_app_state() == application_state) {
+ string output_action = iu_rule.get_output_intent().get_action();
+ _D("Output action : %s\n", output_action.c_str());
+ return output_action;
+ }
+ }
+
+ return string("");
+}
+
+void IntentUnderstandingEngine::init_input_buffer()
+{
+ input_intent_list.clear();
+}
--- /dev/null
+/*
+ * 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 __INTENT_UNDERSTANDING_ENGINE__
+#define __INTENT_UNDERSTANDING_ENGINE__
+
+#include <unistd.h>
+#include <string>
+#include <list>
+
+#include "input_intent.h"
+#include "mmi-common.h"
+#include "iu_rule.h"
+
+using namespace std;
+
+class IntentUnderstandingEngine {
+public:
+ IntentUnderstandingEngine();
+ virtual ~IntentUnderstandingEngine();
+
+ bool set_rule_json_file(const char *json_file_path);
+ bool set_rule_json_data(const char *json_data);
+
+ bool set_input_intent_json_data(const char *json_data);
+ bool set_input_event(int type, void *event);
+
+ string get_output_intent_json_data();
+ string get_output_intent_action();
+
+ void set_app_state(mmi_state appstate);
+ void set_app_state(const char *state);
+
+ void init_input_buffer();
+
+ mmi_state get_app_state();
+
+private:
+ bool match_input_intent(IntentUnderstandingRule iu_rule);
+
+ bool parse_json_data(JsonParser *parser);
+
+ string convert_key_event(int type, char *keyname);
+ string convert_voice_event(int type);
+ string convert_gesture_event(int type);
+ string convert_vision_event(int type);
+
+ list<IntentUnderstandingRule> iu_rule_list;
+ list<InputIntent> input_intent_list;
+
+ mmi_state application_state = MMI_STATE_INITIATION;
+};
+
+#endif /* __INTENT_UNDERSTANDING_ENGINE__ */
--- /dev/null
+/*
+ * 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 <unistd.h>
+#include <string>
+
+#include "input_intent.h"
+#include "iu_rule.h"
+
+using namespace std;
+
+IntentUnderstandingRule::IntentUnderstandingRule()
+{
+
+}
+
+IntentUnderstandingRule::~IntentUnderstandingRule()
+{
+
+}
+
+void IntentUnderstandingRule::set_app_state(const char* state)
+{
+ if (string(state) == "Initiation")
+ app_state = MMI_STATE_INITIATION;
+ else if (string(state) == "Exploration")
+ app_state = MMI_STATE_EXPLORATION;
+ else if (string(state) == "Execution")
+ app_state = MMI_STATE_EXECUTION;
+ else if (string(state) == "Feedback")
+ app_state = MMI_STATE_FEEDBACK;
+ else if (string(state) == "Observation")
+ app_state = MMI_STATE_OBSERVATION;
+ else if (string(state) == "Termination")
+ app_state = MMI_STATE_TERMINATION;
+}
+
+mmi_state IntentUnderstandingRule::get_app_state()
+{
+ return app_state;
+}
+
+void IntentUnderstandingRule::set_output_intent(const OutputIntent &output_intent)
+{
+ this->output_intent = output_intent;
+}
+
+OutputIntent IntentUnderstandingRule::get_output_intent()
+{
+ return this->output_intent;
+}
+
+void IntentUnderstandingRule::add_input_intent(const InputIntent &intent)
+{
+ input_intent_list.push_back(intent);
+}
+
+bool IntentUnderstandingRule::find_input_intent(InputIntent intent)
+{
+ for (InputIntent it : input_intent_list)
+ {
+ if (it.match_intent(intent))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+unsigned int IntentUnderstandingRule::get_input_intent_size()
+{
+ return input_intent_list.size();
+}
--- /dev/null
+/*
+ * 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 __IU_RULE__
+#define __IU_RULE__
+
+#include <unistd.h>
+#include <string>
+#include <list>
+
+#include "input_intent.h"
+#include "output_intent.h"
+#include "mmi-common.h"
+
+using namespace std;
+
+class IntentUnderstandingRule {
+public:
+ IntentUnderstandingRule();
+ virtual ~IntentUnderstandingRule();
+
+ void set_app_state(const char* state);
+ mmi_state get_app_state();
+
+ void set_output_intent(const OutputIntent &output_intent);
+ OutputIntent get_output_intent();
+
+ void add_input_intent(const InputIntent &intent);
+ bool find_input_intent(InputIntent intent);
+ unsigned int get_input_intent_size();
+
+private:
+ list<InputIntent> input_intent_list;
+
+ OutputIntent output_intent;
+
+ mmi_state app_state = MMI_STATE_NONE;
+};
+
+#endif /* __IU_RULE__ */
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <string>
+#include <list>
+#include <json-glib/json-glib.h>
+
+#include "mmi_iu.h"
+#include "mmi_iu_log.h"
+#include "output_intent.h"
+#include "input_intent.h"
+#include "intent_understanding_engine.h"
+#include "mmi-common.h"
+
+using namespace std;
+
+static mmi_state g_app_state = MMI_STATE_INITIATION;
+static mmi_iu_output_intent_received_cb iu_output_intent_received_callback = NULL;
+static void *iu_output_intent_user_data = NULL;
+
+static bool initialized = false;
+
+static string g_system_app_id;
+static string g_focus_app_id;
+
+static IntentUnderstandingEngine *iu_engine = NULL;
+
+#define DEFAULT_RULE_FILE "/usr/share/iu/default_rule.json"
+
+static void init()
+{
+ initialized = true;
+
+ g_app_state = MMI_STATE_INITIATION;
+
+ iu_output_intent_received_callback = NULL;
+
+ iu_output_intent_user_data = NULL;
+
+ g_system_app_id = "";
+ g_focus_app_id = "";
+}
+
+EXPORT_API int mmi_iu_init()
+{
+ init();
+
+ iu_engine = new IntentUnderstandingEngine();
+
+ if (!iu_engine)
+ return MMI_IU_ERROR_OUT_OF_MEMORY;
+
+ int ret = mmi_iu_set_rule_filepath(DEFAULT_RULE_FILE);
+
+ return ret;
+}
+
+EXPORT_API int mmi_iu_shutdown()
+{
+ init();
+
+ if (iu_engine) {
+ delete iu_engine;
+ iu_engine = NULL;
+ }
+
+ if (!initialized)
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+
+ initialized = false;
+
+ return MMI_IU_ERROR_NONE;
+}
+
+EXPORT_API int mmi_iu_set_rule_filepath(const char *filepath)
+{
+ if (!initialized || !iu_engine)
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+
+ if (!iu_engine->set_rule_json_file(filepath)) {
+ _W("Failed to set rule data");
+ return MMI_IU_ERROR_OPERATION_FAILED;
+ }
+
+ return MMI_IU_ERROR_NONE;
+}
+
+static void fire_output_intent_callback(const char *app_id, const char *output_intent)
+{
+ if (iu_output_intent_received_callback)
+ iu_output_intent_received_callback(app_id, output_intent, iu_output_intent_user_data);
+ else
+ _D("No output intent receive callback\n");
+}
+
+static void fire_output_intent(const char *app_id, const char *json_output_intent)
+{
+ if (g_system_app_id == string(app_id)) {
+ fire_output_intent_callback(app_id, json_output_intent);
+ }
+ else {
+ if (g_focus_app_id.empty()) {
+ fire_output_intent_callback(app_id, json_output_intent);
+ }
+ else {
+ if (g_focus_app_id == string(app_id)) {
+ fire_output_intent_callback(app_id, json_output_intent);
+ }
+ else {
+ _I("different focus app\n");
+ }
+ }
+ }
+}
+
+EXPORT_API int mmi_iu_feed_intent(const char *app_id, const char *json_data)
+{
+ if (!app_id || !json_data) {
+ _W("[ERROR] Invalid parameter");
+ return MMI_IU_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!initialized) {
+ _W("[ERROR] Not initialized");
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+ }
+
+ if (iu_engine)
+ if (!iu_engine->set_input_intent_json_data(json_data))
+ return MMI_IU_ERROR_OPERATION_FAILED;
+
+ _I("app state: %d\n", g_app_state);
+
+ string json_output_intent;
+ if (iu_engine) {
+ iu_engine->set_app_state(g_app_state);
+
+ json_output_intent = iu_engine->get_output_intent_json_data();
+ _I("output intent : %s\n", json_output_intent.c_str());
+ }
+
+ if (json_output_intent.empty())
+ return MMI_IU_ERROR_OPERATION_FAILED;
+
+ fire_output_intent(app_id, json_output_intent.c_str());
+
+ return MMI_IU_ERROR_NONE;
+}
+
+EXPORT_API int mmi_iu_feed_input_event(const char *app_id, int type, void *event)
+{
+ if (!app_id || !event) {
+ _W("[ERROR] Invalid parameter");
+ return MMI_IU_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!initialized) {
+ _W("[ERROR] Not initialized");
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+ }
+
+ if (iu_engine)
+ if (!iu_engine->set_input_event(type, event)) {
+ LOGE("Failed to set input event");
+ return MMI_IU_ERROR_OPERATION_FAILED;
+ }
+
+ _I("app state: %d\n", g_app_state);
+
+ string json_output_intent;
+ if (iu_engine) {
+ iu_engine->set_app_state(g_app_state);
+
+ json_output_intent = iu_engine->get_output_intent_json_data();
+ _I("output intent : %s\n", json_output_intent.c_str());
+ }
+
+ if (json_output_intent.empty())
+ return MMI_IU_ERROR_OPERATION_FAILED;
+
+ fire_output_intent(app_id, json_output_intent.c_str());
+
+ if (iu_engine)
+ iu_engine->init_input_buffer();
+
+ return MMI_IU_ERROR_NONE;
+}
+
+EXPORT_API int mmi_iu_set_output_intent_received_callback(mmi_iu_output_intent_received_cb callback, void *user_data)
+{
+ if (!callback) {
+ _W("[ERROR] Invalid parameter");
+ return MMI_IU_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!initialized) {
+ _W("[ERROR] Not initialized");
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+ }
+
+ iu_output_intent_received_callback = callback;
+ iu_output_intent_user_data = user_data;
+
+ return MMI_IU_ERROR_NONE;
+}
+
+EXPORT_API int mmi_iu_unset_output_intent_received_callback()
+{
+ if (!initialized) {
+ _W("[ERROR] Not initialized");
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+ }
+
+ iu_output_intent_received_callback = NULL;
+ iu_output_intent_user_data = NULL;
+
+ return MMI_IU_ERROR_NONE;
+}
+
+EXPORT_API int mmi_iu_set_app_state(mmi_state app_state)
+{
+ if (!initialized) {
+ _W("[ERROR] Not initialized");
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+ }
+
+ g_app_state = app_state;
+
+ return MMI_IU_ERROR_NONE;
+}
+
+EXPORT_API int mmi_iu_set_focus_app_id(const char *app_id)
+{
+ if (!app_id) {
+ _W("[ERROR] Invalid parameter");
+ return MMI_IU_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!initialized) {
+ _W("[ERROR] Not initialized");
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+ }
+
+ g_focus_app_id = string(app_id);
+
+ return MMI_IU_ERROR_NONE;
+}
+
+EXPORT_API int mmi_iu_set_system_app_id(const char *system_app_id)
+{
+ if (!system_app_id) {
+ _W("[ERROR] Invalid parameter");
+ return MMI_IU_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!initialized) {
+ _W("[ERROR] Not initialized");
+ return MMI_IU_ERROR_NOT_INITIALIZED;
+ }
+
+ g_system_app_id = string(system_app_id);
+
+ return MMI_IU_ERROR_NONE;
+}
--- /dev/null
+/*
+ * 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 __TIZEN_UIX_MMI_IU_H__
+#define __TIZEN_UIX_MMI_IU_H__
+
+#include "mmi_iu_error.h"
+#include "mmi-common.h"
+
+/**
+ * @file iu.h
+ * @brief This file contains Intent Understanding APIs and related enumeration.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup UIX_MMI_IU_MODULE
+ * @{
+ */
+
+/**
+ * @brief The callback function to receive output intent
+ * @param[in] target_app_id The app ID to process output intent (focused app or system app id)
+ * @param[in] json_data The output intent data with json format
+ * @param[in] user_data The user data passed from the callback function
+ */
+typedef void (*mmi_iu_output_intent_received_cb)(const char *target_app_id, const char *json_data, void *user_data);
+
+/**
+ * @brief Initialize Intent Understanding library
+ *
+ * @return int MMI_IU_ERROR_NONE on success
+ */
+int mmi_iu_init();
+
+/**
+ * @brief Shutdown Intent Understanding library
+ *
+ * @return int MMI_IU_ERROR_NONE on success
+ */
+int mmi_iu_shutdown();
+
+/**
+ * @brief Set file path of json rule data
+ * @param[in] filepath file path of json rule data
+ *
+ * @return int MMI_IU_ERROR_NONE on success
+ */
+int mmi_iu_set_rule_filepath(const char *filepath);
+
+/**
+ * @brief Feed input intent
+ * @remark The result can be received by the callback registered by mmi_iu_set_output_intent_received_callback().
+ * @param[in] app_id The app ID that input event occurred
+ */
+int mmi_iu_feed_intent(const char *app_id, const char *json_data);
+
+/**
+ * @brief Feed raw input event
+ * @remark The result can be received by the callback registered by mmi_iu_set_output_intent_received_callback().
+ * @param[in] app_id The app ID that input event occurred
+ * @param[in] type The input event type (key, voice, gesture, ..)
+ * @param[in] event The event information
+ */
+int mmi_iu_feed_input_event(const char *app_id, int type, void *event);
+
+/**
+ * @brief Register the callback function to receive output intent
+ * @param callback The (callback) function to be called when output intent is generated.
+ * @param data The data pointer to be passed to @p callback
+ */
+int mmi_iu_set_output_intent_received_callback(mmi_iu_output_intent_received_cb callback, void *user_data);
+
+/**
+ * @brief Unregister the callback function to receive output intent
+ */
+int mmi_iu_unset_output_intent_received_callback();
+
+/**
+ * @brief Set app state
+ * @param app_state The application state
+ */
+int mmi_iu_set_app_state(mmi_state app_state);
+
+/**
+ * @brief Set system application ID
+ * @param[in] system_app_id system application ID
+ */
+int mmi_iu_set_system_app_id(const char *system_app_id);
+
+/**
+ * @brief Set focus app ID
+ * @param[in] app_id The focus application ID
+ */
+int mmi_iu_set_focus_app_id(const char *app_id);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_UIX_MMI_IU_H__ */
--- /dev/null
+/*
+ * 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 __TIZEN_UIX_MMI_IU_ERROR_H__
+#define __TIZEN_UIX_MMI_IU_ERROR_H__
+
+#include <tizen.h>
+
+/**
+ * @file MMI_IU_ERROR.h
+ * @brief This file contains intent understanding error enumeration.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup UIX_IU_COMMON_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for intent understanding function error.
+ *
+ * @since_tizen 6.5
+ */
+typedef enum {
+ MMI_IU_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ MMI_IU_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ MMI_IU_ERROR_NOT_INITIALIZED = TIZEN_ERROR_UNKNOWN - 1, /**< Not initialized */
+ MMI_IU_ERROR_OPERATION_FAILED = TIZEN_ERROR_UNKNOWN - 2, /**< Operation failed */
+ MMI_IU_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+} MMI_IU_ERROR_e;
+
+/**
+ * @}
+ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_UIX_MMI_IU_ERROR_H__ */
--- /dev/null
+/*
+ * 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 __TIZEN_UIX_MMI_IU_EVENT_H__
+#define __TIZEN_UIX_MMI_IU_EVENT_H__
+
+#include <xkbcommon/xkbcommon.h>
+
+/* temporary definition */
+#define MMI_EVENT_KEYEVENT_MIC 0x8080
+
+#endif /* __TIZEN_UIX_MMI_IU_EVENT_H__ */
--- /dev/null
+/*
+ * 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 __TIZEN_UIX_MMI_IU_LOG_H__
+#define __TIZEN_UIX_MMI_IU_LOG_H__
+
+#include <dlog.h>
+#include <stdio.h>
+#include <libgen.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MMI_IU"
+
+#ifdef _E
+#undef _E
+#endif
+
+#ifdef _W
+#undef _W
+#endif
+
+#ifdef _I
+#undef _I
+#endif
+
+#ifdef _D
+#undef _D
+#endif
+
+#define _D LOGD
+#define _E LOGE
+#define _I LOGI
+#define _W LOGW
+
+#endif /* __TIZEN_UIX_MMI_IU_LOG_H__ */
--- /dev/null
+/*
+ * 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 <unistd.h>
+#include <string>
+
+#include "output_intent.h"
+#include "mmi_iu_log.h"
+
+OutputIntent::OutputIntent()
+{
+ json_object = json_object_new();
+}
+
+OutputIntent::~OutputIntent()
+{
+ json_object = NULL;
+}
+
+string OutputIntent::get_action()
+{
+ return action;
+}
+
+void OutputIntent::set_action(string action)
+{
+ json_object_set_string_member(json_object, "Action", action.c_str());
+ this->action = action;
+}
+
+void OutputIntent::add_member_value(string key, string value)
+{
+ json_object_set_string_member(json_object, key.c_str(), value.c_str());
+}
+
+string OutputIntent::get_output_intent_text()
+{
+ string json_output_text;
+ JsonGenerator *j_generator = NULL;
+ JsonNode *j_node = NULL;
+ gsize size = 0;
+ gchar *data = NULL;
+
+ j_generator = json_generator_new();
+ if (j_generator == NULL) {
+ _E("json generator create error");
+ goto cleanup;
+ }
+
+ j_node = json_node_new(JSON_NODE_OBJECT);
+ if (j_node == NULL) {
+ _E("json node create error");
+ goto cleanup;
+ }
+
+ json_node_set_object(j_node, json_object);
+ json_generator_set_root(j_generator, j_node);
+
+ data = json_generator_to_data(j_generator, &size);
+ if (data == NULL) {
+ _E("Failed to get json data");
+ goto cleanup;
+ }
+
+ json_output_text = string(data);
+
+cleanup:
+ if (data)
+ g_free(data);
+
+ if (j_node)
+ json_node_free(j_node);
+
+ if (j_generator)
+ g_object_unref(j_generator);
+
+ return json_output_text;
+}
--- /dev/null
+/*
+ * 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 __OUTPUT_INTENT_H__
+#define __OUTPUT_INTENT_H__
+
+#include <unistd.h>
+#include <string>
+#include <json-glib/json-glib.h>
+
+using namespace std;
+
+class OutputIntent
+{
+public:
+ OutputIntent();
+ virtual ~OutputIntent();
+
+ void add_member_value(string key, string value);
+ void set_action(string action);
+ string get_action();
+
+ string get_output_intent_text();
+
+private:
+ JsonObject *json_object = NULL;
+ string action;
+};
+
+#endif /* __OUTPUT_INTENT_H__ */
--- /dev/null
+mmimgr_srcs = [
+ 'mmi-manager.h',
+ 'mmi-manager.c',
+ 'mmi-core.h',
+ 'mmi-core.c',
+ 'mmi-api-handler.h',
+ 'mmi-api-handler.c',
+ 'mmi-client.h',
+ 'mmi-client.c',
+ 'mmi-common.h',
+ 'mmi-common.c',
+ 'mmi-provider.c',
+ 'mmi-provider.h',
+ 'mmi-provider-iface.h',
+ 'mmi-fusion.c',
+ 'mmi-fusion.h',
+ 'mmi-fusion-iface.h',
+ 'mmi-manager-dbg.h',
+ 'mmi-iu-bridge.c',
+ 'mmi-iu-bridge.h',
+ 'interface/mmifw_stub.h',
+ 'interface/mmifw_stub.c',
+ 'iu/input_intent.cpp',
+ 'iu/input_intent.h',
+ 'iu/intent_understanding_engine.cpp',
+ 'iu/intent_understanding_engine.h',
+ 'iu/iu_rule.cpp',
+ 'iu/iu_rule.h',
+ 'iu/mmi_iu.cpp',
+ 'iu/output_intent.cpp',
+ 'iu/output_intent.h'
+ ]
+
+install_headers(
+ 'mmi-manager.h',
+ 'mmi-manager-dbg.h',
+ 'mmi-common.h',
+ 'mmi-provider-iface.h',
+ 'mmi-fusion-iface.h'
+ )
+
+install_data('iu/data/default_rule.json', install_dir : '/usr/share/iu/')
+
+glib_dep = dependency('glib-2.0', method : 'pkg-config')
+gio_dep = dependency('gio-2.0', method : 'pkg-config')
+bundle_dep = dependency('bundle', method : 'pkg-config')
+dlog_dep = dependency('dlog', method : 'pkg-config')
+ecore_dep = dependency('ecore', method : 'pkg-config')
+rpc_port_dep = dependency('rpc-port')
+json_glib_dep = dependency('json-glib-1.0')
+libtzplatform_config_dep = dependency('libtzplatform-config')
+xkbcommon_dep = dependency('xkbcommon', method : 'pkg-config')
+
+mmimgr_deps = [
+ ecore_dep,
+ glib_dep,
+ gio_dep,
+ bundle_dep,
+ dlog_dep,
+ rpc_port_dep,
+ json_glib_dep,
+ libtzplatform_config_dep,
+ xkbcommon_dep]
+
+mmimgr_include_dirs = include_directories('.')
+
+mmimgr_library = library('mmimgr',
+ mmimgr_srcs,
+ include_directories : [ mmimgr_include_dirs ],
+ dependencies : [mmimgr_deps],
+ install_dir : mmi_manager_prefix_libdir,
+ install : true
+ )
+
+mmimgr_declared_dep = declare_dependency(
+ link_with : mmimgr_library,
+ dependencies : [mmimgr_deps],
+ include_directories : [mmimgr_include_dirs]
+ )
+
+pkgconfig.generate(
+ filebase : 'libmmimgr',
+ name : 'libmmimgr',
+ description : 'Multi-modal Interaction Manager Library',
+ version : meson.project_version(),
+ libraries : mmimgr_library
+ )
+
--- /dev/null
+/*
+* 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-api-handler.h"
+#include "mmi-manager-dbg.h"
+#include "mmi-manager.h"
+#include "mmi-client.h"
+
+#include <stdlib.h>
+#include <rpc-port.h>
+#include <rpc-port-internal.h>
+
+static bool _init_done = false;
+
+static const char* _stub_appid = "mmi-manager";
+
+static void _on_create(rpc_port_stub_mmifw_context_h context, void *user_data)
+{
+ int r;
+ char *sender = NULL;
+ mmi_client *mc = NULL;
+
+ r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
+ if (r || !sender)
+ {
+ LOGE("Failed to get sender from context ! (error:%d)\n", r);
+ goto err;
+ }
+
+ LOGI("Client(%s) has been connected !\n", sender);
+
+ mc = client_manager_add_client(sender);
+
+ if (!mc)
+ {
+ LOGE("Failed to add client info to client hash !\n");
+ goto err;
+ }
+
+ //TODO: set additional information of client
+
+ free(sender);
+ return;
+err:
+ if (sender)
+ free(sender);
+}
+
+static void _on_terminate(rpc_port_stub_mmifw_context_h context, void *user_data)
+{
+ int r;
+ char *sender = NULL;
+
+ r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
+ if (r || !sender)
+ {
+ LOGE("Failed to get sender from context ! (error:%d)\n", r);
+ return;
+ }
+
+ LOGI("Client(%s) has been disconnected !\n", sender);
+
+ client_manager_remove_client(sender);
+ free(sender);
+}
+
+static int _register_cb(rpc_port_stub_mmifw_context_h context, rpc_port_mmifw_focus_event_cb_h focus_cb, rpc_port_mmifw_state_change_event_cb_h state_cb, rpc_port_mmifw_wakeup_event_cb_h wakeup_cb, rpc_port_mmifw_key_event_cb_h key_cb, rpc_port_mmifw_gesture_event_cb_h gesture_cb, rpc_port_mmifw_voice_event_cb_h voice_cb, rpc_port_mmifw_action_event_cb_h action_cb, rpc_port_mmifw_feedback_event_cb_h feedback_cb, void *user_data)
+{
+ int r;
+ char *sender = NULL;
+ mmi_client *mc = NULL;
+
+ r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
+ if (r || !sender)
+ {
+ LOGE("Failed to get sender from context ! (error:%d)\n", r);
+ return -1;
+ }
+
+ mc = client_manager_get_client(sender);
+ if (!mc)
+ {
+ LOGE("Failed to get client information from sender !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_focus_cb_handle(mc, (void *)focus_cb))
+ {
+ LOGE("Failed to set focus event handler to client info !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_state_change_cb_handle(mc, (void *)state_cb))
+ {
+ LOGE("Failed to set state_change event handler to client info !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_wakeup_cb_handle(mc, (void *)wakeup_cb))
+ {
+ LOGE("Failed to set wakeup event handler to client info !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_key_cb_handle(mc, (void *)key_cb))
+ {
+ LOGE("Failed to set key event handler to client info !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_gesture_cb_handle(mc, (void *)gesture_cb))
+ {
+ LOGE("Failed to set gesture event handler to client info !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_voice_cb_handle(mc, (void *)voice_cb))
+ {
+ LOGE("Failed to set voice event handler to client info !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_action_cb_handle(mc, (void *)action_cb))
+ {
+ LOGE("Failed to set action event handler to client info !\n");
+ goto err;
+ }
+
+ if (!client_manager_set_client_feedback_cb_handle(mc, (void *)feedback_cb))
+ {
+ LOGE("Failed to set feedback event handler to client info !\n");
+ goto err;
+ }
+
+ free(sender);
+ return 0;
+err:
+ if (sender)
+ free(sender);
+ return -1;
+}
+
+static void _deregister_cb(rpc_port_stub_mmifw_context_h context, void *user_data)
+{
+ int r;
+ char *sender = NULL;
+ mmi_client *mc = NULL;
+
+ r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
+ if (r || !sender)
+ {
+ LOGE("Failed to get sender from context ! (error:%d)\n", r);
+ return;
+ }
+
+ mc = client_manager_get_client(sender);
+ if (!mc)
+ {
+ LOGE("Failed to get client information from sender !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_focus_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset focus event handler of client !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_state_change_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset state_change event handler of client !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_wakeup_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset wakeup event handler of client !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_key_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset key event handler of client !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_gesture_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset gesture event handler of client !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_voice_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset voice event handler of client !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_action_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset action event handler of client !\n");
+ goto err;
+ }
+
+ if (NULL != client_manager_set_client_feedback_cb_handle(mc, NULL))
+ {
+ LOGE("Failed to unset feedback event handler of client !\n");
+ goto err;
+ }
+
+
+ free(sender);
+ return;
+err:
+ if (sender)
+ free(sender);
+ return;
+}
+
+static void _get_focus_cb(rpc_port_stub_mmifw_context_h context, void *user_data)
+{
+ int r;
+ char *sender = NULL;
+ mmi_client *mc = NULL;
+
+ r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
+ if (r || !sender)
+ {
+ LOGE("Failed to get sender from context ! (error:%d)\n", r);
+ goto err;
+ }
+
+ LOGI("Get focus request came from a client(%s) !\n", sender);
+
+ mc = client_manager_get_client(sender);
+ if (!mc)
+ {
+ LOGE("Failed to get client info from sender(=%s)]n", sender);
+ goto err;
+ }
+
+ r = mmi_manager_set_focus_client(mc);
+ if (r)
+ {
+ LOGE("Failed returned mmi_manager_set_focus_client ! (error:%d)\n", r);
+ goto err;
+ }
+
+ free(sender);
+ return;
+err:
+ if (sender)
+ free(sender);
+ if (mc)
+ free(mc);
+}
+
+static void _set_state_cb(rpc_port_stub_mmifw_context_h context, int state, void *user_data)
+{
+ int r;
+ char *sender = NULL;
+ mmi_client *mc = NULL;
+
+ r = rpc_port_stub_mmifw_context_get_sender(context, &sender);
+ if (r || !sender)
+ {
+ LOGE("Failed to get sender from context ! (error:%d)\n", r);
+ goto err;
+ }
+
+ LOGI("Get focus request came from a client(%s) !\n", sender);
+
+ mc = client_manager_get_client(sender);
+ if (!mc)
+ {
+ LOGE("Failed to get client info from sender(=%s)]n", sender);
+ goto err;
+ }
+
+ r = mmi_manager_set_state(mc, state);
+ if (r)
+ {
+ LOGE("Failed returned mmi_manager_set_state(=%d) ! (error:%d)\n", state, r);
+ goto err;
+ }
+
+ free(sender);
+ return;
+err:
+ if (sender)
+ free(sender);
+ if (mc)
+ free(mc);
+}
+
+void
+mmi_api_handler_init(void)
+{
+ int r;
+
+ if (_init_done)
+ return;
+
+ r = rpc_port_register_proc_info(_stub_appid, NULL);
+ if (r != RPC_PORT_ERROR_NONE)
+ {
+ LOGE("Failed to register proc info ! (error:%d)\n", r);
+ goto err;
+ }
+
+ rpc_port_stub_mmifw_callback_s callback = {
+ _on_create,
+ _on_terminate,
+ _register_cb,
+ _deregister_cb,
+ _get_focus_cb,
+ _set_state_cb
+ };
+
+ r = rpc_port_stub_mmifw_register(&callback, NULL);
+ if (r != 0)
+ {
+ LOGE("Failed to register callbacks (error:%d)\n", r);
+ goto err;
+ }
+
+ _init_done = true;
+err:
+ return;
+}
+
+void
+mmi_api_handler_shutdown(void)
+{
+ if (!_init_done)
+ return;
+
+ rpc_port_stub_mmifw_unregister();
+
+ _init_done = false;
+}
+
--- /dev/null
+/*
+* 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_API_HANDLER_H__
+#define __MMI_API_HANDLER_H__
+
+#include "interface/mmifw_stub.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void mmi_api_handler_init(void);
+void mmi_api_handler_shutdown(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_API_HANDLER_H__
--- /dev/null
+/*
+* 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-client.h"
+#include "mmi-common.h"
+#include "mmi-manager.h"
+#include "mmi-manager-dbg.h"
+#include "interface/mmifw_stub.h"
+
+#include <Eina.h>
+#include <stdlib.h>
+
+struct _mmi_client
+{
+ char *sender;
+ uid_t uid;
+ pid_t pid;
+ mmi_state state;
+ bool has_focus;
+
+ rpc_port_mmifw_focus_event_cb_h focus_cb_h;
+ rpc_port_mmifw_state_change_event_cb_h state_change_cb_h;
+ rpc_port_mmifw_wakeup_event_cb_h wakeup_cb_h;
+ rpc_port_mmifw_key_event_cb_h key_cb_h;
+ rpc_port_mmifw_gesture_event_cb_h gesture_cb_h;
+ rpc_port_mmifw_voice_event_cb_h voice_cb_h;
+ rpc_port_mmifw_action_event_cb_h action_cb_h;
+ rpc_port_mmifw_feedback_event_cb_h feedback_cb_h;
+};
+
+Eina_Hash *_client_hash = NULL;
+static Eina_Bool _init_done = false;
+
+static Eina_Bool
+_client_hash_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
+{
+ (void) hash;
+ (void) key;
+ (void) fdata;
+
+ mmi_client *mc = (mmi_client *)data;
+ if (mc && mc->sender)
+ free(mc->sender);
+
+ return 1;
+}
+
+mmi_client *
+client_manager_add_client(const char* sender)
+{
+ mmi_client *mc = NULL;
+
+ if (!sender)
+ return NULL;
+
+ mc = calloc(1, sizeof(mmi_client));
+ if (!mc)
+ {
+ LOGE("Failed to allocate memory for client !\n");
+ return NULL;
+ }
+
+ mc->sender = strdup(sender);
+
+ if (!eina_hash_add(_client_hash, sender, mc))
+ {
+ LOGE("Failed to add client info to client hash !\n");
+ goto err;
+ }
+
+ return mc;
+err:
+ if (mc)
+ free(mc);
+ return NULL;
+}
+
+mmi_client *
+client_manager_get_client(const char* sender)
+{
+ mmi_client *mc = NULL;
+
+ if (!sender)
+ return NULL;
+
+ mc = eina_hash_find(_client_hash, sender);
+
+ if (!mc)
+ {
+ LOGE("Failed to find client info from sender(=%s)\n", sender);
+ return NULL;
+ }
+
+ return mc;
+}
+
+int
+client_manager_remove_client(const char *sender)
+{
+ mmi_client *mc = NULL;
+
+ if (!sender)
+ return -1;
+
+ mc = eina_hash_find(_client_hash, sender);
+ if (!mc)
+ {
+ LOGE("Failed to find client info from sender(=%s)\n", sender);
+ goto err;
+ }
+
+ if (mc->has_focus)
+ mmi_manager_remove_focus_client(mc);
+ else
+ mmi_manager_remove_client_from_focus_candidates(mc);
+
+ if (!eina_hash_del(_client_hash, sender, mc))
+ {
+ LOGE("Failed to remove client info using sender(=%s) !\n", sender);
+ goto err;
+ }
+
+ if (mc->sender)
+ free(mc->sender);
+
+ rpc_port_mmifw_focus_event_cb_destroy(mc->focus_cb_h);
+ rpc_port_mmifw_state_change_event_cb_destroy(mc->state_change_cb_h);
+ rpc_port_mmifw_wakeup_event_cb_destroy(mc->wakeup_cb_h);
+ rpc_port_mmifw_key_event_cb_destroy(mc->key_cb_h);
+ rpc_port_mmifw_gesture_event_cb_destroy(mc->gesture_cb_h);
+ rpc_port_mmifw_voice_event_cb_destroy(mc->voice_cb_h);
+ rpc_port_mmifw_action_event_cb_destroy(mc->action_cb_h);
+ rpc_port_mmifw_feedback_event_cb_destroy(mc->feedback_cb_h);
+
+ mc->focus_cb_h = NULL;
+ mc->state_change_cb_h = NULL;
+ mc->wakeup_cb_h = NULL;
+ mc->key_cb_h = NULL;
+ mc->gesture_cb_h = NULL;
+ mc->voice_cb_h = NULL;
+ mc->action_cb_h = NULL;
+ mc->feedback_cb_h = NULL;
+
+ free(mc);
+ mc = NULL;
+
+ return 0;
+err:
+ if (mc && mc->sender)
+ free(mc->sender);
+ if (mc)
+ free(mc);
+ mc = NULL;
+ return -1;
+}
+
+int
+client_manager_set_client_uid(mmi_client *client, uid_t uid)
+{
+ if (!client)
+ return -1;
+
+ client->uid = uid;
+ return uid;
+}
+
+int
+client_manager_get_client_uid(mmi_client *client)
+{
+ if (!client)
+ return -1;
+
+ return client->uid;
+}
+
+int
+client_manager_set_client_pid(mmi_client *client, pid_t pid)
+{
+ if (!client)
+ return -1;
+
+ client->pid = pid;
+ return pid;
+}
+
+int
+client_manager_get_client_pid(mmi_client *client)
+{
+ if (!client)
+ return -1;
+
+ return client->pid;
+}
+
+mmi_state
+client_manager_set_client_state(mmi_client *client, mmi_state state)
+{
+ if (!client)
+ return MMI_STATE_NONE;
+
+ client->state = state;
+ return state;
+}
+
+mmi_state
+client_manager_get_client_state(mmi_client *client)
+{
+ if (!client)
+ return MMI_STATE_NONE;
+
+ return client->state;
+}
+
+bool
+client_manager_set_client_has_focus(mmi_client *client, bool has_focus)
+{
+ if (!client)
+ return false;
+
+ client->has_focus = has_focus;
+ return client->has_focus;
+}
+
+bool
+client_manager_get_client_has_focus(mmi_client *client)
+{
+ if (!client)
+ return false;
+
+ return client->has_focus;
+}
+
+const char *
+client_manager_get_client_sender(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->sender;
+}
+
+static void
+_cleanup_client_hash(void)
+{
+ if (!_client_hash)
+ return;
+
+ eina_hash_foreach(_client_hash, _client_hash_free_cb, NULL);
+ eina_hash_free(_client_hash);
+ _client_hash = NULL;
+}
+
+void
+client_manager_init(void)
+{
+ if (_init_done)
+ return;
+
+ if (_client_hash)
+ _cleanup_client_hash();
+
+ _init_done = true;
+ _client_hash = eina_hash_string_superfast_new(NULL);
+}
+
+void
+client_manager_shutdown(void)
+{
+ if (!_init_done)
+ return;
+
+ if (_client_hash)
+ _cleanup_client_hash();
+
+ _init_done = false;
+}
+
+void *
+client_manager_set_client_focus_cb_handle(mmi_client *client, void *focus_cb_h)
+{
+ int r;
+
+ if (!client || !focus_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_focus_event_cb_clone(focus_cb_h, &client->focus_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone focus event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->focus_cb_h;
+}
+
+void *
+client_manager_get_client_focus_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->focus_cb_h;
+}
+
+
+void *
+client_manager_set_client_state_change_cb_handle(mmi_client *client, void *state_change_cb_h)
+{
+ int r;
+
+ if (!client || !state_change_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_state_change_event_cb_clone(state_change_cb_h, &client->state_change_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone state_change event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->state_change_cb_h;
+}
+
+void *
+client_manager_get_client_state_change_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->state_change_cb_h;
+}
+
+void *
+client_manager_set_client_wakeup_cb_handle(mmi_client *client, void *wakeup_cb_h)
+{
+ int r;
+
+ if (!client || !wakeup_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_wakeup_event_cb_clone(wakeup_cb_h, &client->wakeup_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone wakeup event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->wakeup_cb_h;
+}
+
+void *
+client_manager_get_client_wakeup_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->wakeup_cb_h;
+}
+
+void *
+client_manager_set_client_key_cb_handle(mmi_client *client, void *key_cb_h)
+{
+ int r;
+
+ if (!client || !key_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_key_event_cb_clone(key_cb_h, &client->key_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone key event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->key_cb_h;
+}
+
+void *
+client_manager_get_client_key_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->key_cb_h;
+}
+
+void *
+client_manager_set_client_gesture_cb_handle(mmi_client *client, void *gesture_cb_h)
+{
+ int r;
+
+ if (!client || !gesture_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_gesture_event_cb_clone(gesture_cb_h, &client->gesture_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone gesture event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->gesture_cb_h;
+}
+
+void *
+client_manager_get_client_gesture_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->gesture_cb_h;
+}
+
+void *
+client_manager_set_client_voice_cb_handle(mmi_client *client, void *voice_cb_h)
+{
+ int r;
+
+ if (!client || !voice_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_voice_event_cb_clone(voice_cb_h, &client->voice_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone voice event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->voice_cb_h;
+}
+
+void *
+client_manager_get_client_voice_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->voice_cb_h;
+}
+
+void *
+client_manager_set_client_action_cb_handle(mmi_client *client, void *action_cb_h)
+{
+ int r;
+
+ if (!client || !action_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_action_event_cb_clone(action_cb_h, &client->action_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone action event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->action_cb_h;
+}
+
+void *
+client_manager_get_client_action_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->action_cb_h;
+}
+
+void *
+client_manager_set_client_feedback_cb_handle(mmi_client *client, void *feedback_cb_h)
+{
+ int r;
+
+ if (!client || !feedback_cb_h)
+ return NULL;
+
+ r = rpc_port_mmifw_feedback_event_cb_clone(feedback_cb_h, &client->feedback_cb_h);
+ if (r)
+ {
+ LOGE("Failed to clone feedback event handle ! (error:%d)\n", r);
+ return NULL;
+ }
+
+ return client->feedback_cb_h;
+}
+
+void *
+client_manager_get_client_feedback_cb_handle(mmi_client *client)
+{
+ if (!client)
+ return NULL;
+
+ return client->feedback_cb_h;
+}
+
+int
+client_manager_send_focus_event(mmi_client *client, focus_event_arg *args)
+{
+ int r;
+ rpc_port_focus_event_h focus_event_h = NULL;
+ focus_event_arg *ev = (focus_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->focus_cb_h)
+ {
+ LOGE("Given client doesn't have focus_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_focus_event_create(&focus_event_h);
+ if (r)
+ {
+ LOGE("Failed to create focus_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_focus_event_set_type(focus_event_h, ev->type);
+ rpc_port_focus_event_set_timestamp(focus_event_h, ev->timestamp);
+ rpc_port_focus_event_set_focus_in(focus_event_h, ev->focus_in);
+
+ r = rpc_port_mmifw_focus_event_cb_invoke(client->focus_cb_h, focus_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke focus_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (focus_event_h)
+ rpc_port_focus_event_destroy(focus_event_h);
+
+ return -1;
+}
+
+int
+client_manager_send_state_change_event(mmi_client *client, state_change_event_arg *args)
+{
+ int r;
+ rpc_port_state_change_event_h state_change_event_h = NULL;
+ state_change_event_arg *ev = (state_change_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->state_change_cb_h)
+ {
+ LOGE("Given client doesn't have state_change_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_state_change_event_create(&state_change_event_h);
+ if (r)
+ {
+ LOGE("Failed to create state_change_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_state_change_event_set_type(state_change_event_h, ev->type);
+ rpc_port_state_change_event_set_timestamp(state_change_event_h, ev->timestamp);
+ rpc_port_state_change_event_set_state(state_change_event_h, ev->state);
+ rpc_port_state_change_event_set_old_state(state_change_event_h, ev->old_state);
+
+ r = rpc_port_mmifw_state_change_event_cb_invoke(client->state_change_cb_h, state_change_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke state_change_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (state_change_event_h)
+ rpc_port_state_change_event_destroy(state_change_event_h);
+
+ return -1;
+}
+
+int
+client_manager_send_wakeup_event(mmi_client *client, wakeup_event_arg *args)
+{
+ int r;
+ rpc_port_wakeup_event_h wakeup_event_h = NULL;
+ wakeup_event_arg *ev = (wakeup_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->wakeup_cb_h)
+ {
+ LOGE("Given client doesn't have wakeup_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_wakeup_event_create(&wakeup_event_h);
+ if (r)
+ {
+ LOGE("Failed to create wakeup_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_wakeup_event_set_type(wakeup_event_h, ev->type);
+ rpc_port_wakeup_event_set_timestamp(wakeup_event_h, ev->timestamp);
+ rpc_port_wakeup_event_set_source(wakeup_event_h, ev->source);
+
+ r = rpc_port_mmifw_wakeup_event_cb_invoke(client->wakeup_cb_h, wakeup_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke wakeup_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (wakeup_event_h)
+ rpc_port_wakeup_event_destroy(wakeup_event_h);
+
+ return -1;
+}
+
+int
+client_manager_send_key_event(mmi_client *client, key_event_arg *args)
+{
+ int r;
+ rpc_port_key_event_h key_event_h = NULL;
+ key_event_arg *ev = (key_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->key_cb_h)
+ {
+ LOGE("Given client doesn't have key_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_key_event_create(&key_event_h);
+ if (r)
+ {
+ LOGE("Failed to create key_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_key_event_set_type(key_event_h, ev->type);
+ rpc_port_key_event_set_timestamp(key_event_h, ev->timestamp);
+ rpc_port_key_event_set_key_down(key_event_h, ev->key_down);
+ rpc_port_key_event_set_keycode(key_event_h, ev->keycode);
+ rpc_port_key_event_set_keyname(key_event_h, ev->keyname);
+ rpc_port_key_event_set_source(key_event_h, ev->source);
+
+ r = rpc_port_mmifw_key_event_cb_invoke(client->key_cb_h, key_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke key_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (key_event_h)
+ rpc_port_key_event_destroy(key_event_h);
+
+ return -1;
+}
+
+int
+client_manager_send_gesture_event(mmi_client *client, gesture_event_arg *args)
+{
+ int r;
+ rpc_port_gesture_event_h gesture_event_h = NULL;
+ gesture_event_arg *ev = (gesture_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->gesture_cb_h)
+ {
+ LOGE("Given client doesn't have gesture_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_gesture_event_create(&gesture_event_h);
+ if (r)
+ {
+ LOGE("Failed to create gesture_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_gesture_event_set_type(gesture_event_h, ev->type);
+ rpc_port_gesture_event_set_timestamp(gesture_event_h, ev->timestamp);
+ rpc_port_gesture_event_set_source(gesture_event_h, ev->source);
+
+ r = rpc_port_mmifw_gesture_event_cb_invoke(client->gesture_cb_h, gesture_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke gesture_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (gesture_event_h)
+ rpc_port_gesture_event_destroy(gesture_event_h);
+
+ return -1;
+}
+
+int
+client_manager_send_voice_event(mmi_client *client, voice_event_arg *args)
+{
+ int r;
+ rpc_port_voice_event_h voice_event_h = NULL;
+ voice_event_arg *ev = (voice_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->voice_cb_h)
+ {
+ LOGE("Given client doesn't have voice_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_voice_event_create(&voice_event_h);
+ if (r)
+ {
+ LOGE("Failed to create voice_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_voice_event_set_type(voice_event_h, ev->type);
+ rpc_port_voice_event_set_timestamp(voice_event_h, ev->timestamp);
+ rpc_port_voice_event_set_source(voice_event_h, ev->source);
+
+ r = rpc_port_mmifw_voice_event_cb_invoke(client->voice_cb_h, voice_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke voice_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (voice_event_h)
+ rpc_port_voice_event_destroy(voice_event_h);
+
+ return -1;
+}
+
+int
+client_manager_send_action_event(mmi_client *client, action_event_arg *args)
+{
+ int r;
+ rpc_port_action_event_h action_event_h = NULL;
+ action_event_arg *ev = (action_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->action_cb_h)
+ {
+ LOGE("Given client doesn't have action_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_action_event_create(&action_event_h);
+ if (r)
+ {
+ LOGE("Failed to create action_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_action_event_set_type(action_event_h, ev->type);
+ rpc_port_action_event_set_timestamp(action_event_h, ev->timestamp);
+ rpc_port_action_event_set_cmd(action_event_h, ev->cmd);
+ rpc_port_action_event_set_nargs(action_event_h, ev->nargs);
+ rpc_port_action_event_set_source(action_event_h, ev->source);
+ rpc_port_action_event_set_args(action_event_h, ev->args, ev->nargs);
+
+ r = rpc_port_mmifw_action_event_cb_invoke(client->action_cb_h, action_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke action_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (action_event_h)
+ rpc_port_action_event_destroy(action_event_h);
+
+ return -1;
+}
+
+int
+client_manager_send_feedback_event(mmi_client *client, feedback_event_arg *args)
+{
+ int r;
+ rpc_port_feedback_event_h feedback_event_h = NULL;
+ feedback_event_arg *ev = (feedback_event_arg *)args;
+
+ if (!client || !args)
+ {
+ LOGE("Invalid client or args was given !\n");
+ return -1;
+ }
+
+ if (!client->feedback_cb_h)
+ {
+ LOGE("Given client doesn't have feedback_cb handle !\n");
+ return -1;
+ }
+
+ r = rpc_port_feedback_event_create(&feedback_event_h);
+ if (r)
+ {
+ LOGE("Failed to create feedback_event_h ! (error:%d)\n", r);
+ return -1;
+ }
+
+ rpc_port_feedback_event_set_type(feedback_event_h, ev->type);
+ rpc_port_feedback_event_set_timestamp(feedback_event_h, ev->timestamp);
+ rpc_port_feedback_event_set_feedback(feedback_event_h, ev->feedback);
+ rpc_port_feedback_event_set_comment(feedback_event_h, ev->comment);
+
+ r = rpc_port_mmifw_feedback_event_cb_invoke(client->feedback_cb_h, feedback_event_h);
+ if (r)
+ {
+ LOGE("Failed to invoke feedback_event_cb ! (error:%d)\n", r);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (feedback_event_h)
+ rpc_port_feedback_event_destroy(feedback_event_h);
+
+ return -1;
+}
--- /dev/null
+/*
+* 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_CLIENT_H__
+#define __MMI_CLIENT_H__
+
+#include "mmi-common.h"
+#include <sys/types.h>
+
+typedef struct _mmi_client mmi_client;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+mmi_client *client_manager_add_client(const char* sender);
+mmi_client *client_manager_get_client(const char* sender);
+int client_manager_remove_client(const char *sender);
+int client_manager_set_client_uid(mmi_client *client, uid_t uid);
+int client_manager_get_client_uid(mmi_client *client);
+int client_manager_set_client_pid(mmi_client *client, pid_t pid);
+int client_manager_get_client_pid(mmi_client *client);
+mmi_state client_manager_set_client_state(mmi_client *client, mmi_state state);
+mmi_state client_manager_get_client_state(mmi_client *client);
+bool client_manager_set_client_has_focus(mmi_client *client, bool has_focus);
+bool client_manager_get_client_has_focus(mmi_client *client);
+const char *client_manager_get_client_sender(mmi_client *client);
+
+void *client_manager_set_client_focus_cb_handle(mmi_client *client, void *focus_cb_h);
+void *client_manager_get_client_focus_cb_handle(mmi_client *client);
+void *client_manager_set_client_state_change_cb_handle(mmi_client *client, void *state_change_cb_h);
+void *client_manager_get_client_state_change_cb_handle(mmi_client *client);
+void *client_manager_set_client_wakeup_cb_handle(mmi_client *client, void *wakeup_cb_h);
+void *client_manager_get_client_wakeup_cb_handle(mmi_client *client);
+void *client_manager_set_client_key_cb_handle(mmi_client *client, void *key_cb_h);
+void *client_manager_get_client_key_cb_handle(mmi_client *client);
+void *client_manager_set_client_gesture_cb_handle(mmi_client *client, void *gesture_cb_h);
+void *client_manager_get_client_gesture_cb_handle(mmi_client *client);
+void *client_manager_set_client_voice_cb_handle(mmi_client *client, void *voice_cb_h);
+void *client_manager_get_client_voice_cb_handle(mmi_client *client);
+void *client_manager_set_client_action_cb_handle(mmi_client *client, void *action_cb_h);
+void *client_manager_get_client_action_cb_handle(mmi_client *client);
+void *client_manager_set_client_feedback_cb_handle(mmi_client *client, void *feedback_cb_h);
+void *client_manager_get_client_feedback_cb_handle(mmi_client *client);
+
+int client_manager_send_focus_event(mmi_client *client, focus_event_arg *args);
+int client_manager_send_state_change_event(mmi_client *client, state_change_event_arg *args);
+int client_manager_send_wakeup_event(mmi_client *client, wakeup_event_arg *args);
+int client_manager_send_key_event(mmi_client *client, key_event_arg *args);
+int client_manager_send_gesture_event(mmi_client *client, gesture_event_arg *args);
+int client_manager_send_voice_event(mmi_client *client, voice_event_arg *args);
+int client_manager_send_action_event(mmi_client *client, action_event_arg *args);
+int client_manager_send_feedback_event(mmi_client *client, feedback_event_arg *args);
+
+void client_manager_init(void);
+void client_manager_shutdown(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_CLIENT_H__
--- /dev/null
+/*
+* 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-common.h"
+
+MMI_API int MMI_MANAGER_EVENT_FOCUS_CHANGE = -1;
+MMI_API int MMI_MANAGER_EVENT_STATE_CHANGE = -1;
+
+MMI_API int MMI_PROVIDER_EVENT_KEY = -1;
+MMI_API int MMI_PROVIDER_EVENT_GESTURE = -1;
+MMI_API int MMI_PROVIDER_EVENT_VOICE = -1;
+MMI_API int MMI_PROVIDER_EVENT_VISION = -1;
--- /dev/null
+/*
+* 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_COMMON_H__
+#define __MMI_COMMON_H__
+
+#include <stdbool.h>
+
+#ifndef MMI_API
+#define MMI_API __attribute__ ((visibility("default")))
+#endif
+
+MMI_API extern int MMI_PROVIDER_EVENT_KEY;
+MMI_API extern int MMI_PROVIDER_EVENT_GESTURE;
+MMI_API extern int MMI_PROVIDER_EVENT_VOICE;
+MMI_API extern int MMI_PROVIDER_EVENT_VISION;
+
+typedef enum mmi_event_key_type
+{
+ MMI_EVENT_KEY_TYPE_DOWN,
+ MMI_EVENT_KEY_TYPE_UP
+} mmi_event_key_type;
+
+typedef enum mmi_event_gesture_type
+{
+ MMI_EVENT_GESTURE_TYPE_SWIPE_UP,
+ MMI_EVENT_GESTURE_TYPE_SWIPE_DOWN,
+ MMI_EVENT_GESTURE_TYPE_SWIPE_LEFT,
+ MMI_EVENT_GESTURE_TYPE_SWIPE_RIGHT,
+ MMI_EVENT_GESTURE_TYPE_PUSH
+} mmi_event_gesture_type;
+
+typedef enum mmi_event_voice_type
+{
+ MMI_EVENT_VOICE_TYPE_UP,
+ MMI_EVENT_VOICE_TYPE_DOWN,
+ MMI_EVENT_VOICE_TYPE_LEFT,
+ MMI_EVENT_VOICE_TYPE_RIGHT,
+ MMI_EVENT_VOICE_TYPE_CANCEL,
+ MMI_EVENT_VOICE_TYPE_PLAY,
+ MMI_EVENT_VOICE_TYPE_YES,
+ MMI_EVENT_VOICE_TYPE_EXECUTE,
+ MMI_EVENT_VOICE_TYPE_BACK,
+ MMI_EVENT_VOICE_TYPE_EXIT,
+ MMI_EVENT_VOICE_TYPE_STOP,
+ MMI_EVENT_VOICE_TYPE_TERMINATE
+} mmi_event_voice_type;
+
+typedef enum mmi_event_vision_type
+{
+ MMI_EVENT_VISION_TYPE_USER_ENTER,
+ MMI_EVENT_VISION_TYPE_USER_LEAVE,
+ MMI_EVENT_VISION_TYPE_USER_MOVE_AWAY,
+ MMI_EVENT_VISION_TYPE_USER_MOVE_CLOSER,
+ MMI_EVENT_VISION_TYPE_YES,
+ MMI_EVENT_VISION_TYPE_NO,
+ MMI_EVENT_VISION_TYPE_REVOKE,
+ MMI_EVENT_VISION_TYPE_STOP
+} mmi_event_vision_type;
+
+typedef enum mmi_event_wakeup_type
+{
+ MMI_EVENT_WAKEUP_TYPE_WAKEUP
+} mmi_event_wakeup_type;
+
+typedef enum mmi_event_action_type
+{
+ MMI_EVENT_ACTION_TYPE_PLAY,
+ MMI_EVENT_ACTION_TYPE_PAUSE,
+ MMI_EVENT_ACTION_TYPE_RESUME,
+ MMI_EVENT_ACTION_TYPE_STOP,
+ MMI_EVENT_ACTION_TYPE_EXECUTE,
+ MMI_EVENT_ACTION_TYPE_LAUNCH,
+ MMI_EVENT_ACTION_TYPE_REVOKE,
+ MMI_EVENT_ACTION_TYPE_CANCEL
+} mmi_event_action_type;
+
+typedef enum mmi_event_feedback_type
+{
+ MMI_EVENT_FEEDBACK_TYPE_FEEDBACK
+} mmi_event_feedback_type;
+
+typedef enum mmi_event_focus_type
+{
+ MMI_EVENT_FOCUS_TYPE_IN,
+ MMI_EVENT_FOCUS_TYPE_OUT
+} mmi_event_focus_type;
+
+typedef enum mmi_event_state_change_type
+{
+ MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE
+} mmi_event_state_change_type;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ bool focus_in;
+} focus_event_arg;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ int state;
+ int old_state;
+} state_change_event_arg;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ char *source;
+} wakeup_event_arg;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ bool key_down;
+ int keycode;
+ char *keyname;
+ char *source;
+} key_event_arg;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ char *source;
+} gesture_event_arg;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ char *source;
+} voice_event_arg;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ char *cmd;
+ char **args;
+ int nargs;
+ char *source;
+} action_event_arg;
+
+typedef struct
+{
+ int type;
+ int timestamp;
+ char *feedback;
+ char *comment;
+} feedback_event_arg;
+
+typedef struct
+{
+ int type;//down or up
+ int timestamp;
+ int duration;
+ double confidence;
+ int keycode;
+ bool key_down;
+ char *keyname;
+ char *source;//event source information
+} mmi_provider_event_key;
+
+typedef struct
+{
+ int type;//swipe up, down, left, palm open, palm cover
+ int timestamp;
+ int duration;
+ double confidence;
+ char *source;//event source information
+} mmi_provider_event_gesture;
+
+typedef struct
+{
+ int type;//play, pause, ..., yes, no
+ int timestamp;
+ int duration;
+ double confidence;
+ char *cmd;
+ char **args;
+ int nargs;//num of args
+ char *source;//event source information
+} mmi_provider_event_voice;
+
+typedef struct
+{
+ int type;//leave, enter, move away, move closer
+ int timestamp;
+ int duration;
+ double confidence;
+ char *cmd;
+ char **args;
+ int nargs;//num of args
+ char *source;//event source information
+} mmi_provider_event_vision;
+
+typedef unsigned long long ull;
+
+typedef enum mmi_state
+{
+ MMI_STATE_NONE,
+ MMI_STATE_INITIATION,
+ MMI_STATE_EXPLORATION,
+ MMI_STATE_EXECUTION,
+ MMI_STATE_FEEDBACK,
+ MMI_STATE_OBSERVATION,
+ MMI_STATE_TERMINATION
+} mmi_state;
+
+typedef enum mmi_provider_op_mode
+{
+ MODALITY_PROVIDER_MODE_NONE,
+ MODALITY_PROVIDER_MODE_PROPAGATE_EVENT,
+ MODALITY_PROVIDER_MODE_KEEP_EVENT,
+ MODALITY_PROVIDER_MODE_DROP_EVENT,
+} mmi_provider_op_mode;
+
+typedef enum mmi_provider_capability
+{
+ MODALITY_PROVIDER_CAP_NONE = 0,
+ MODALITY_PROVIDER_CAP_KEY_EVENT = (1 << 0),
+ MODALITY_PROVIDER_CAP_MOUSE_EVENT = (1 << 1),
+ MODALITY_PROVIDER_CAP_TOUCH_EVENT = (1 << 2),
+ MODALITY_PROVIDER_CAP_GESTURE_EVENT = (1 << 3),
+ MODALITY_PROVIDER_CAP_VOICE_EVENT = (1 << 4),
+ MODALITY_PROVIDER_CAP_VISION_EVENT = (1 << 5),
+ MODALITY_PROVIDER_CAP_UNKNOWN = ((ull)1 << 62),
+ MODALITY_PROVIDER_CAP_MAX = ((ull)1 << 63)
+} mmi_provider_capability;
+
+typedef enum mmi_provider_result
+{
+ MODALITY_PROVIDER_RESULT_NONE,
+ MODALITY_PROVIDER_RESULT_FAIL,
+ MODALITY_PROVIDER_RESULT_SUCCESS
+} mmi_provider_result;
+
+typedef struct _mmi_provider_module_data mmi_provider_module_data;
+typedef struct _mmi_provider_module mmi_provider_module;
+typedef struct _mmi_provider_handle mmi_provider_handle;
+
+typedef struct _mmi_fusion_module_data mmi_fusion_module_data;
+typedef struct _mmi_fusion_module mmi_fusion_module;
+typedef struct _mmi_fusion_handle mmi_fusion_handle;
+
+#endif //__MMI_COMMON_H__
--- /dev/null
+/*
+* 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-core.h"
+
+void
+mmi_core_init()
+{
+}
+
+void
+mmi_core_shutdown()
+{
+}
+
--- /dev/null
+/*
+* 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_CORE_H__
+#define __MMI_CORE_H__
+
+void mmi_core_init(void);
+void mmi_core_shutdown(void);
+
+#endif //__MMI_CORE_H__
--- /dev/null
+/*
+* 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_FUSION_IFACE_H__
+#define __MMI_FUSION_IFACE_H__
+
+#include "mmi-common.h"
+
+#define MMI_FUSION_ABI_MAJOR_MASK 0xFFFF0000
+#define MMI_FUSION_ABI_MINOR_MASK 0x0000FFFF
+
+#define MMI_FUSION_GET_ABI_MAJOR(m) (((m) & MMI_FUSION_ABI_MAJOR_MASK) >> 16)
+#define MMI_FUSION_GET_ABI_MINOR(m) ((m) & MMI_FUSION_ABI_MINOR_MASK)
+
+#define MMI_FUSION_SET_ABI_VERSION(major, minor) \
+ ((((major) << 16) & MMI_FUSION_ABI_MAJOR_MASK) \
+ | ((minor) & MMI_FUSION_ABI_MINOR_MASK))
+
+#define MMI_FUSION_API __attribute__ ((visibility("default")))
+
+#ifndef bool
+typedef int bool;
+#endif
+
+struct _mmi_fusion_module
+{
+ const char *name; /**< The name of a fusion module */
+ const char *so_name; /**< The shared library name of a fusion module */
+ unsigned long abi_version; /**< The API version of a fusion module */
+
+ mmi_fusion_module_data *(*fusion_init)(void);
+ void (*fusion_deinit)(mmi_fusion_module_data *fusion_data);
+};
+
+struct _mmi_fusion_handle
+{
+ void *fusion_info;
+ mmi_fusion_module *module_info;
+ mmi_fusion_module_data *module_data;
+ mmi_state state;
+};
+
+struct _mmi_fusion_module_data
+{
+ mmi_state (*set_state)(mmi_state state);
+ mmi_state (*get_state)(void);
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//APIs for fusions
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_FUSION_IFACE_H__
--- /dev/null
+/*
+* 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-fusion.h"
+#include "mmi-fusion-iface.h"
+#include "mmi-manager-dbg.h"
+
+#include <Ecore.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+
+#define FUSION_PATH "/lib/fusion/"
+
+Eina_List *_fusion_list = NULL;
+int _loaded_fusion_cnt = 0;
+mmi_fusion_handle *_cur_fusion = NULL;
+
+int
+_fusion_load_module(const char *fusion_name)
+{
+ mmi_fusion_handle *fusion = (mmi_fusion_handle *)calloc(1, sizeof(mmi_fusion_handle));
+
+ if (!fusion)
+ {
+ LOGE("Failed to alloc fusion handle");
+ return 0;
+ }
+
+ void *fusion_info = NULL;
+ mmi_fusion_module *mmi_fusion_module_info = NULL;
+
+ fusion_info = dlopen(fusion_name, RTLD_LAZY);
+
+ if(!fusion_info)
+ {
+ LOGE("Failed to dlopen(error :%s, path :%s)!\n", dlerror(), fusion_name);
+ goto err;
+ }
+
+ mmi_fusion_module_info = dlsym(fusion_info, "mmi_fusion_module_info");
+
+ if(!mmi_fusion_module_info)
+ {
+ LOGE("Module(%s) dosen't have mmi_fusion_module_info \n", fusion_name);
+ goto err;
+ }
+
+ if(!mmi_fusion_module_info->fusion_init || !mmi_fusion_module_info->fusion_deinit)
+ {
+ LOGE("Module(%s) doesn't have init/deinit function\n", fusion_name);
+ goto err;
+ }
+
+ ++_loaded_fusion_cnt;
+
+ fusion->fusion_info = fusion_info;
+ fusion->module_info = mmi_fusion_module_info;
+
+ //FIXME: init() of a fusion module needs to be called in mmi-manager
+ //Right now, we initiate a fusion module found for the first time.
+ if (_loaded_fusion_cnt == 1)
+ {
+ fusion->module_data = fusion->module_info->fusion_init();
+ if (!fusion->module_data)
+ {
+ LOGE("Failed to init of a fusion module (name:%s) !\n", fusion->module_info->name);
+ goto err;
+ }
+ _cur_fusion = fusion;
+ }
+
+ _fusion_list = eina_list_append(_fusion_list, fusion);
+
+ return 1;
+
+err:
+ if(fusion_info)
+ dlclose(fusion_info);
+
+ if(fusion)
+ free(fusion);
+ return 0;
+}
+
+int
+_modality_fusions_lookup(void)
+{
+ int cnt = 0;
+ DIR *dir;
+ struct dirent *entry;
+
+ dir = opendir(FUSION_PATH);
+
+ if(!dir)
+ {
+ LOGE("no dir = %s\n", FUSION_PATH);
+ return -1;
+ }
+
+ while((entry = readdir(dir)) != NULL)
+ {
+ char fusion_name[512];
+ if(strstr(entry->d_name, "fusion") != NULL)
+ {
+ snprintf(fusion_name, sizeof(fusion_name), "%s%s", FUSION_PATH, entry->d_name);
+ LOGD("Fusion full path = %s\n", fusion_name);
+ cnt += _fusion_load_module(fusion_name);
+ }
+ }
+
+ closedir(dir);
+
+ return cnt;
+}
+
+mmi_fusion_handle *
+modality_fusions_get_client_fusion(mmi_client *client)
+{
+ return _cur_fusion;
+}
+
+mmi_state
+modality_fusion_get_state(mmi_fusion_handle *fusion)
+{
+ mmi_state state = MMI_STATE_NONE;
+
+ if (!fusion)
+ {
+ LOGE("Given fusion handle is invalid !\n");
+ return state;
+ }
+
+ state = fusion->module_data->get_state();
+ return state;
+}
+
+mmi_state
+modality_fusion_set_state(mmi_fusion_handle *fusion, mmi_state state)
+{
+ if (!fusion)
+ {
+ LOGE("Given fusion handle is invalid !\n");
+ return MMI_STATE_NONE;
+ }
+
+ return fusion->module_data->set_state(state);
+}
+
+
+void
+modality_fusions_init(void)
+{
+ int fusion_cnt = -1;
+ fusion_cnt = _modality_fusions_lookup();
+
+ if(fusion_cnt < 0)
+ {
+ LOGE("No find any fusion in path = %s\n", FUSION_PATH);
+ return;
+ }
+
+ LOGD("%d fusion modules have been loaded !\n", fusion_cnt);
+}
+
+void
+modality_fusions_shutdown(void)
+{
+ if(!_fusion_list)
+ return;
+
+ Eina_List *l = NULL;
+ mmi_fusion_handle *fusion = NULL;
+ EINA_LIST_FOREACH(_fusion_list, l, fusion)
+ {
+ if(fusion->module_info)
+ {
+ if(fusion->module_data)
+ fusion->module_info->fusion_deinit(fusion->module_data);
+ fusion->module_data = NULL;
+ fusion->module_info = NULL;
+ }
+ if(fusion->fusion_info)
+ dlclose(fusion->fusion_info);
+ }
+
+ _fusion_list = eina_list_free(_fusion_list);
+ _fusion_list = NULL;
+ _loaded_fusion_cnt = 0;
+ _cur_fusion = NULL;
+}
--- /dev/null
+/*
+* 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_FUSION_H__
+#define __MMI_FUSION_H__
+
+#include "mmi-common.h"
+#include "mmi-client.h"
+
+mmi_fusion_handle *modality_fusions_get_client_fusion(mmi_client *client);
+mmi_state modality_fusion_get_state(mmi_fusion_handle *fusion);
+mmi_state modality_fusion_set_state(mmi_fusion_handle *fusion, mmi_state state);
+
+void modality_fusions_init(void);
+void modality_fusions_shutdown(void);
+
+#endif //__MMI_FUSION_H__
--- /dev/null
+/*
+* 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 <Ecore.h>
+#include <json-glib/json-glib.h>
+
+#include "mmi-manager.h"
+#include "iu/mmi_iu_log.h"
+#include "iu/mmi_iu.h"
+
+#define APP_ID "org.tizen.test"
+
+enum event_handlers {
+ EVENT_HANDLER_FOCUS_CHANGE,
+ EVENT_HANDLER_STATE_CHANGE,
+ EVENT_HANDLER_KEY,
+ EVENT_HANDLER_GESTURE,
+ EVENT_HANDLER_VOICE,
+ EVENT_HANDLER_VISION,
+ EVENT_HANDLER_MAX
+};
+
+static Ecore_Event_Handler *_event_handlers[EVENT_HANDLER_MAX];
+static mmi_client *g_client = NULL;
+
+static void output_intent_received_cb(const char *app_id, const char *json_data, void *user_data)
+{
+ JsonParser *parser = json_parser_new();
+ GError *err_msg = NULL;
+ JsonNode *root = NULL;
+ JsonObject *root_obj = NULL;
+ const gchar *action = NULL;
+
+ action_event_arg arg;
+ arg.timestamp = ecore_time_get();
+ char* arr[1] = { "Action" };
+ arg.cmd = NULL;
+ arg.args = arr;
+ arg.nargs = 1;
+ arg.source = NULL;
+
+ json_parser_load_from_data(parser, (char *)json_data, -1, &err_msg);
+ if (err_msg) {
+ LOGE("failed to load json file. error message: %s\n", err_msg->message);
+ goto cleanup;
+ }
+
+ root = json_parser_get_root(parser);
+ if (root == NULL) {
+ LOGE("failed to get root\n");
+ goto cleanup;
+ }
+
+ root_obj = json_node_get_object(root);
+ if (root_obj == NULL) {
+ LOGE("failed to get object\n");
+ goto cleanup;
+ }
+
+ action = json_object_get_string_member(root_obj, "Action");
+ LOGD("Action: %s\n", action);
+
+ if (strcmp(action, "WakeUp") == 0) {
+ wakeup_event_arg arg;
+ arg.type = MMI_EVENT_WAKEUP_TYPE_WAKEUP;
+ arg.source = NULL;
+ arg.timestamp = ecore_time_get();
+
+ client_manager_send_wakeup_event(g_client, &arg);
+ }
+ else if (strcmp(action, "Execute") == 0) {
+ arg.type = MMI_EVENT_ACTION_TYPE_EXECUTE;
+ client_manager_send_action_event(g_client, &arg);
+ }
+ else if (strcmp(action, "Play") == 0) {
+ arg.type = MMI_EVENT_ACTION_TYPE_PLAY;
+ client_manager_send_action_event(g_client, &arg);
+ }
+ else if (strcmp(action, "Cancel") == 0) {
+ arg.type = MMI_EVENT_ACTION_TYPE_CANCEL;
+ client_manager_send_action_event(g_client, &arg);
+ }
+ else if (strcmp(action, "Pause") == 0) {
+ arg.type = MMI_EVENT_ACTION_TYPE_PAUSE;
+ client_manager_send_action_event(g_client, &arg);
+ }
+ else if (strcmp(action, "Stop") == 0) {
+ arg.type = MMI_EVENT_ACTION_TYPE_STOP;
+ client_manager_send_action_event(g_client, &arg);
+ }
+
+cleanup:
+ if (err_msg)
+ g_error_free(err_msg);
+
+ if (parser)
+ g_object_unref(parser);
+}
+
+static Eina_Bool
+_focus_change_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_manager_event_focus_change *ev = (mmi_manager_event_focus_change *)event;
+
+ LOGI("[focus change] cur focus : %p, new focus : %p", ev->cur_focus, ev->new_focus);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_state_change_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_manager_event_state_change *ev = (mmi_manager_event_state_change *)event;
+ g_client = ev->client;
+
+ LOGI("state : %d", ev->to_state);
+ mmi_iu_set_app_state(ev->to_state);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_key_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_key *ev = (mmi_provider_event_key *)event;
+
+ LOGI("[key event] code : %d, name : %s, type : %d, timestamp : %d, source: %s", ev->keycode, ev->keyname, ev->type, ev->timestamp, ev->source);
+
+ if (ev->key_down) {
+ mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_KEY, ev);
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_gesture_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_gesture *ev = (mmi_provider_event_gesture *)event;
+
+ LOGI("[gesture event] type : %d, timestamp : %d", ev->type, ev->timestamp);
+
+ mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_GESTURE, ev);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_voice_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_voice *ev = (mmi_provider_event_voice *)event;
+
+ LOGI("[voice event] type : %d, timestamp : %d", ev->type, ev->timestamp);
+
+ mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_VOICE, ev);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_vision_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_vision *ev = (mmi_provider_event_vision *)event;
+
+ mmi_iu_feed_input_event(APP_ID, MMI_PROVIDER_EVENT_KEY, ev);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+init_event_handler()
+{
+ _event_handlers[EVENT_HANDLER_FOCUS_CHANGE] = ecore_event_handler_add(MMI_MANAGER_EVENT_FOCUS_CHANGE,
+ _focus_change_cb, NULL);
+ _event_handlers[EVENT_HANDLER_STATE_CHANGE] = ecore_event_handler_add(MMI_MANAGER_EVENT_STATE_CHANGE,
+ _state_change_cb, NULL);
+
+ _event_handlers[EVENT_HANDLER_KEY] = ecore_event_handler_add(MMI_PROVIDER_EVENT_KEY,
+ _key_event_cb, NULL);
+ _event_handlers[EVENT_HANDLER_GESTURE] = ecore_event_handler_add(MMI_PROVIDER_EVENT_GESTURE,
+ _gesture_event_cb, NULL);
+ _event_handlers[EVENT_HANDLER_VOICE] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VOICE,
+ _voice_event_cb, NULL);
+ _event_handlers[EVENT_HANDLER_VISION] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VISION,
+ _vision_event_cb, NULL);
+}
+
+static void
+shutdown_event_handler()
+{
+ for (int i=0; i<EVENT_HANDLER_MAX; i++) {
+ if (_event_handlers[i]) {
+ ecore_event_handler_del(_event_handlers[i]);
+ _event_handlers[i] = NULL;
+ }
+ }
+}
+
+int mmi_iu_bridge_init()
+{
+ int ret;
+
+ mmi_iu_init();
+
+ init_event_handler();
+
+ ret = mmi_iu_set_output_intent_received_callback(output_intent_received_cb, NULL);
+ if (ret != MMI_IU_ERROR_NONE) {
+ LOGE("Error code : %d", ret);
+ return ret;
+ }
+
+ return ret;
+}
+
+int mmi_iu_bridge_shutdown()
+{
+ shutdown_event_handler();
+
+ int ret = mmi_iu_shutdown();
+ return ret;
+}
+
--- /dev/null
+/*
+* 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_IU_BRIDGE_H__
+#define __MMI_IU_BRIDGE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void mmi_iu_bridge_init();
+void mmi_iu_bridge_shutdown();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_IU_BRIDGE_H__
--- /dev/null
+/*
+* 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_MANAGER_DBG_H__
+#define __MMI_MANAGER_DBG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MMIMGR"
+
+#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_MANAGER_DBG_H__
--- /dev/null
+/*
+* 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-manager.h"
+#include "mmi-core.h"
+#include "mmi-fusion.h"
+#include "mmi-provider.h"
+#include "mmi-common.h"
+#include "mmi-manager-dbg.h"
+#include "mmi-api-handler.h"
+#include "mmi-iu-bridge.h"
+
+#include <Ecore.h>
+#include <Eina.h>
+
+static Eina_Bool _init_done = false;
+static Eina_List *_focus_candidates = NULL;
+static int _focus_candidates_cnt = 0;
+static mmi_client* _cur_focus_client = NULL;
+Ecore_Event_Handler *_event_handlers[2];
+
+int
+mmi_manager_remove_client_from_focus_candidates(mmi_client *client)
+{
+ if (!client)
+ return -1;
+
+ if (client != eina_list_data_find(_focus_candidates, client))
+ {
+ return -1;
+ }
+
+ _focus_candidates = eina_list_remove(_focus_candidates, client);
+ LOGI("Client(=%s) has been removed from focus_candidates !\n",
+ client_manager_get_client_sender(client));
+ _focus_candidates_cnt--;
+ return 0;
+}
+
+int
+_add_focus_change_event(mmi_client *cur_focus, mmi_client *new_focus)
+{
+ mmi_manager_event_focus_change *ev = NULL;
+ ev = calloc(1, sizeof(mmi_manager_event_focus_change));
+
+ if (!ev)
+ {
+ LOGE("Failed to allocate memory for focus change !\n");
+ return -1;
+ }
+
+ ev->timestamp = ecore_time_get();
+ ev->cur_focus = cur_focus;
+ ev->new_focus = new_focus;
+
+ ecore_event_add(MMI_MANAGER_EVENT_FOCUS_CHANGE, ev, NULL, NULL);
+ return 0;
+}
+
+int
+mmi_manager_remove_focus_client(mmi_client *client)
+{
+ mmi_client *new_focus = NULL;
+
+ if (!client || (client != _cur_focus_client) || !client_manager_get_client_has_focus(client))
+ {
+ LOGE("Invalid client was given !\n");
+ return -1;
+ }
+
+ new_focus = eina_list_nth(_focus_candidates, 0);
+ if(new_focus)
+ mmi_manager_remove_client_from_focus_candidates(new_focus);
+ return _add_focus_change_event(NULL, new_focus);
+}
+
+int
+mmi_manager_set_focus_client(mmi_client *client)
+{
+ if (!client)
+ return -1;
+
+ LOGI("...");
+
+ return _add_focus_change_event(_cur_focus_client, client);
+}
+
+int
+mmi_manager_set_state(mmi_client *client, mmi_state state)
+{
+ mmi_fusion_handle *fusion = NULL;
+
+ if (!client)
+ return -1;
+
+ if (client_manager_get_client_state(client) == state)
+ {
+ LOGI("Given state equals to the current state(=%d) of client !\n", state);
+ return 0;
+ }
+
+ LOGI("...");
+
+ fusion = modality_fusions_get_client_fusion(client);
+ if (!fusion)
+ {
+ LOGE("Failed to get fusion handle from client(%p)\n", client);
+ return 0;
+ }
+
+ if (state == modality_fusion_get_state(fusion))
+ {
+ LOGE("Given state equals to existing state(%d) of fusion !\n", state);
+ return 0;
+ }
+
+ if (state != modality_fusion_set_state(fusion, state))
+ {
+ LOGE("Failed to set state(%d) on fusion !\n", state);
+ return 0;
+ }
+
+ mmi_manager_event_state_change *ev = NULL;
+ ev = calloc(1, sizeof(mmi_manager_event_state_change));
+
+ if (!ev)
+ {
+ LOGE("Failed to allocate memory for state change !\n");
+ goto err;
+ }
+
+ ev->timestamp = ecore_time_get();
+ ev->client = client;
+ ev->from_state = client_manager_get_client_state(client);
+ ev->to_state = state;
+
+ ecore_event_add(MMI_MANAGER_EVENT_STATE_CHANGE, ev, NULL, NULL);
+ return 0;
+err:
+ return -1;
+}
+
+mmi_client *
+mmi_manager_get_focus_client(void)
+{
+ return _cur_focus_client;
+}
+
+static void
+_event_init()
+{
+ MMI_MANAGER_EVENT_FOCUS_CHANGE = ecore_event_type_new();
+ MMI_MANAGER_EVENT_STATE_CHANGE = ecore_event_type_new();
+}
+
+static void
+_event_shutdown()
+{
+ MMI_MANAGER_EVENT_FOCUS_CHANGE = -1;
+ MMI_MANAGER_EVENT_STATE_CHANGE = -1;
+}
+
+static Eina_Bool
+_focus_change_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ int r;
+ focus_event_arg arg;
+
+ LOGI("...");
+
+ mmi_manager_event_focus_change *ev = (mmi_manager_event_focus_change *)event;
+
+ arg.type = MMI_EVENT_FOCUS_TYPE_OUT;
+ arg.timestamp = ecore_time_get();
+ arg.focus_in = false;
+
+ if (ev->cur_focus)
+ {
+ r = client_manager_send_focus_event(ev->cur_focus, &arg);
+ client_manager_set_client_has_focus(ev->cur_focus, false);
+ if (r)
+ LOGE("Failed to send focus event(=%d) to client(%p) !\n",
+ MMI_EVENT_FOCUS_TYPE_OUT, ev->cur_focus);
+ }
+
+ arg.type = MMI_EVENT_FOCUS_TYPE_IN;
+ arg.timestamp = ecore_time_get();
+ arg.focus_in = true;
+
+ if (ev->new_focus)
+ {
+ r = client_manager_send_focus_event(ev->new_focus, &arg);
+ client_manager_set_client_has_focus(ev->new_focus, true);
+ if (r)
+ LOGE("Failed to send focus event(=%d) to client(%p) !\n",
+ MMI_EVENT_FOCUS_TYPE_IN, ev->new_focus);
+ }
+
+ LOGI("Focused client has been changed. (%s -> %s)\n",
+ ev->cur_focus ? client_manager_get_client_sender(ev->cur_focus) : "NONE",
+ client_manager_get_client_sender(ev->new_focus));
+
+ if (ev->cur_focus)
+ {
+ _focus_candidates = eina_list_prepend(_focus_candidates, ev->cur_focus);
+ _focus_candidates_cnt++;
+ }
+
+ _cur_focus_client = ev->new_focus;
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_state_change_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ int r;
+ state_change_event_arg arg;
+
+ LOGI("...");
+
+ mmi_manager_event_state_change *ev = (mmi_manager_event_state_change *)event;
+
+ arg.type = MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE;
+ arg.timestamp = ecore_time_get();
+ arg.state = ev->to_state;
+ arg.old_state = ev->from_state;
+
+ if (ev->client)
+ {
+ if (ev->to_state != client_manager_set_client_state(ev->client, ev->to_state))
+ {
+ LOGE("Failed to set client state ! (client:%p, state=%d)\n",
+ ev->client, ev->to_state);
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ r = client_manager_send_state_change_event(ev->client, &arg);
+ if (r)
+ LOGE("Failed to send state cnahnge event(=%d) to client(%p) !\n",
+ MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE, ev->client);
+ }
+ else
+ {
+ LOGE("Abnormal state change event ! (No client info !)\n");
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ LOGI("State of client(%p) has been changed. (%d->%d)\n", ev->client, ev->from_state, ev->to_state);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+_event_handler_init()
+{
+ _event_handlers[0] = ecore_event_handler_add(MMI_MANAGER_EVENT_FOCUS_CHANGE,
+ _focus_change_cb, NULL);
+ _event_handlers[1] = ecore_event_handler_add(MMI_MANAGER_EVENT_STATE_CHANGE,
+ _state_change_cb, NULL);
+}
+
+static void
+_event_handler_shutdown()
+{
+ ecore_event_handler_del(_event_handlers[0]);
+ ecore_event_handler_del(_event_handlers[1]);
+}
+
+void
+mmi_manager_init()
+{
+ if (_init_done)
+ return;
+
+ ecore_init();
+ _event_init();
+
+ mmi_core_init();
+ modality_providers_init();
+ modality_fusions_init();
+ client_manager_init();
+ mmi_api_handler_init();
+
+ mmi_iu_bridge_init();
+ _event_handler_init();
+
+ _init_done = true;
+}
+
+void
+mmi_manager_loop_begin()
+{
+ ecore_main_loop_begin();
+}
+
+void
+mmi_manager_loop_end()
+{
+ ecore_main_loop_quit();
+}
+
+void
+mmi_manager_shutdown()
+{
+ if (!_init_done)
+ return;
+
+ _event_handler_shutdown();
+ mmi_iu_bridge_shutdown();
+
+ mmi_api_handler_shutdown();
+ client_manager_shutdown();
+ modality_fusions_shutdown();
+ modality_providers_shutdown();
+ mmi_core_shutdown();
+
+ ecore_shutdown();
+ _event_shutdown();
+
+ _init_done = false;
+}
--- /dev/null
+/*
+* 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_MANAGER_H__
+#define __MMI_MANAGER_H__
+
+#include "mmi-client.h"
+
+MMI_API extern int MMI_MANAGER_EVENT_FOCUS_CHANGE;
+MMI_API extern int MMI_MANAGER_EVENT_STATE_CHANGE;
+
+typedef struct
+{
+ int timestamp;
+ mmi_client *cur_focus;
+ mmi_client *new_focus;
+} mmi_manager_event_focus_change;
+
+typedef struct
+{
+ int timestamp;
+ mmi_client *client;
+ mmi_state from_state;
+ mmi_state to_state;
+} mmi_manager_event_state_change;
+
+int mmi_manager_set_focus_client(mmi_client *client);
+int mmi_manager_set_state(mmi_client *client, mmi_state state);
+int mmi_manager_remove_client_from_focus_candidates(mmi_client *client);
+int mmi_manager_remove_focus_client(mmi_client *client);
+
+mmi_client* mmi_manager_get_focus_client(void);
+
+void mmi_manager_init(void);
+void mmi_manager_loop_begin(void);
+void mmi_manager_loop_end(void);
+void mmi_manager_shutdown(void);
+
+#endif //__MMI_MANAGER_H__
--- /dev/null
+/*
+* 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_PROVIDER_IFACE_H__
+#define __MMI_PROVIDER_IFACE_H__
+
+#include "mmi-common.h"
+
+#define MMI_PROVIDER_ABI_MAJOR_MASK 0xFFFF0000
+#define MMI_PROVIDER_ABI_MINOR_MASK 0x0000FFFF
+
+#define MMI_PROVIDER_GET_ABI_MAJOR(m) (((m) & MMI_PROVIDER_ABI_MAJOR_MASK) >> 16)
+#define MMI_PROVIDER_GET_ABI_MINOR(m) ((m) & MMI_PROVIDER_ABI_MINOR_MASK)
+
+#define MMI_PROVIDER_SET_ABI_VERSION(major, minor) \
+ ((((major) << 16) & MMI_PROVIDER_ABI_MAJOR_MASK) \
+ | ((minor) & MMI_PROVIDER_ABI_MINOR_MASK))
+
+#define MMI_PROVIDER_API __attribute__ ((visibility("default")))
+
+#ifndef bool
+typedef int bool;
+#endif
+
+struct _mmi_provider_module
+{
+ const char *name; /**< The name of a provider module */
+ const char *so_name; /**< The shared library name of a provider module */
+ const unsigned long long capabilities; /**< The capabilities provided by a provider module */
+ unsigned long abi_version; /**< The API version of a provider module */
+
+ mmi_provider_module_data *(*provider_init)(void);
+ void (*provider_deinit)(mmi_provider_module_data *provider_data);
+};
+
+struct _mmi_provider_handle
+{
+ void *provider_info;
+ mmi_provider_module *module_info;
+ mmi_provider_module_data *module_data;
+ unsigned long long capabilities;
+ mmi_provider_op_mode op_mode;
+};
+
+struct _mmi_provider_module_data
+{
+ bool (*set_mode)(mmi_provider_op_mode mode);
+ mmi_provider_op_mode (*get_mode)(void);
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//APIs for providers
+int mmi_provider_register_caps(mmi_provider_handle *provider, unsigned long long caps);
+void *mmi_provider_alloc_event(int ev_type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_PROVIDER_IFACE_H__
--- /dev/null
+/*
+* 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-provider-iface.h"
+#include "mmi-manager-dbg.h"
+#include "mmi-common.h"
+
+#include <Ecore.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+
+#define PROVIDER_PATH "/lib/provider/"
+
+Eina_List *_provider_list = NULL;
+Ecore_Event_Handler *_provider_event_handlers[4];
+
+static Eina_Bool
+_key_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_key *ev = (mmi_provider_event_key *)event;
+
+ LOGI("[MMI_PROVIDER_EVENT_KEY] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
+ ev->type, ev->timestamp, ev->duration, ev->confidence);
+ LOGI("... keycode:%d, key_down:%d, keyname=%s, source=%s\n",
+ ev->keycode, ev->key_down, ev->keyname, ev->source);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_gesture_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_gesture *ev = (mmi_provider_event_gesture *)event;
+
+ LOGI("[MMI_PROVIDER_EVENT_GESTURE] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
+ ev->type, ev->timestamp, ev->duration, ev->confidence);
+ LOGI("... source=%s\n", ev->source);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_voice_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_voice *ev = (mmi_provider_event_voice *)event;
+
+ LOGI("[MMI_PROVIDER_EVENT_VOICE] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
+ ev->type, ev->timestamp, ev->duration, ev->confidence);
+ LOGI("... cmd:%s, nargs:%d, source:%s\n", ev->cmd, ev->nargs, ev->source);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_vision_provider_event_cb(void *data EINA_UNUSED, int type, void *event)
+{
+ mmi_provider_event_vision *ev = (mmi_provider_event_vision *)event;
+
+ LOGI("[MMI_PROVIDER_EVENT_VISION] type:%d, timestamp:%d, duration:%d, confidence=%.2f\n",
+ ev->type, ev->timestamp, ev->duration, ev->confidence);
+ LOGI("... cmd:%s, nargs:%d, source:%s\n", ev->cmd, ev->nargs, ev->source);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+int
+mmi_provider_set_op_mode_on_caps(unsigned long long caps, mmi_provider_op_mode mode)
+{
+ Eina_List *l = NULL;
+ mmi_provider_handle *provider = NULL;
+
+ if (!caps)
+ {
+ LOGE("Given caps in empty !\n");
+ return -1;
+ }
+
+ EINA_LIST_FOREACH(_provider_list, l, provider)
+ {
+ if (provider->capabilities & caps)
+ {
+ LOGD("Set op_mode(%d) on provider(%s) !\n", mode, provider->module_info->name);
+ provider->module_data->set_mode(mode);
+ }
+ }
+
+ return 0;
+}
+
+int
+mmi_provider_register_caps(mmi_provider_handle *provider, unsigned long long caps)
+{
+ if (!provider)
+ {
+ LOGE("Given provider is invalid !\n");
+ return -1;
+ }
+
+ if (!caps)
+ {
+ LOGE("Given caps is invalid ! (caps=%lld)\n", caps);
+ return -1;
+ }
+
+ /* Right now, we add the given caps to the existing caps. */
+ provider->capabilities |= caps;
+ return 0;
+}
+
+void *
+mmi_provider_alloc_event(int ev_type)
+{
+ (void) ev_type;
+
+ return (void *)0;
+}
+
+void
+_provider_load_module(const char *provider_name)
+{
+ mmi_provider_handle *provider = (mmi_provider_handle *)calloc(1, sizeof(mmi_provider_handle));
+
+ if (!provider)
+ {
+ LOGE("Failed to alloc provider handle");
+ return;
+ }
+
+ void *provider_info = NULL;
+ mmi_provider_module *mmi_provider_module_info = NULL;
+ mmi_provider_module_data *provider_module_data = NULL;
+
+ provider_info = dlopen(provider_name, RTLD_LAZY);
+
+ if(!provider_info)
+ {
+ LOGE("Failed to dlopen(error :%s, path :%s)!\n", dlerror(), provider_name);
+ goto err;
+ }
+
+ mmi_provider_module_info = dlsym(provider_info, "mmi_provider_module_info");
+
+ if(!mmi_provider_module_info)
+ {
+ LOGE("Module(%s) dosen't have mmi_provider_module_info \n", provider_name);
+ goto err;
+ }
+
+ if(!mmi_provider_module_info->provider_init || !mmi_provider_module_info->provider_deinit)
+ {
+ LOGE("Module(%s) doesn't have init/deinit function\n", provider_name);
+ goto err;
+ }
+
+ provider_module_data = mmi_provider_module_info->provider_init();
+
+ if(!provider_module_data)
+ {
+ LOGE("Failed to init module (%s) !\n", provider_name);
+ goto err;
+ }
+
+ LOGI("moudle info name = %s\n", mmi_provider_module_info->name);
+ provider->provider_info = provider_info;
+ provider->module_info = mmi_provider_module_info;
+ provider->module_data = provider_module_data;
+ provider->capabilities = mmi_provider_module_info->capabilities;
+ provider->op_mode = provider_module_data->get_mode();
+
+ _provider_list = eina_list_append(_provider_list, provider);
+ return;
+
+err:
+ if(mmi_provider_module_info && mmi_provider_module_info->provider_deinit)
+ mmi_provider_module_info->provider_deinit(provider_module_data);
+
+ if(provider_info)
+ dlclose(provider_info);
+
+ if(provider)
+ free(provider);
+ return;
+}
+
+void
+_modality_providers_lookup(void)
+{
+ DIR *dir;
+ struct dirent *entry;
+
+ dir = opendir(PROVIDER_PATH);
+
+ if(!dir)
+ {
+ LOGE("no dir\n");
+ return;
+ }
+
+ while((entry = readdir(dir)) != NULL)
+ {
+ char provider_name[512];
+ if(strstr(entry->d_name, "libmmi_modality") != NULL)
+ {
+ snprintf(provider_name, sizeof(provider_name), "%s%s", PROVIDER_PATH, entry->d_name);
+ LOGD("Provider full path = %s\n", provider_name);
+ _provider_load_module(provider_name);
+ }
+ }
+
+ closedir(dir);
+}
+
+static void
+_event_handler_init()
+{
+ MMI_PROVIDER_EVENT_KEY = ecore_event_type_new();
+ MMI_PROVIDER_EVENT_GESTURE = ecore_event_type_new();
+ MMI_PROVIDER_EVENT_VOICE = ecore_event_type_new();
+ MMI_PROVIDER_EVENT_VISION = ecore_event_type_new();
+
+ LOGD("MMI_PROVIDER_EVENT_KEY=%d\n", MMI_PROVIDER_EVENT_KEY);
+ LOGD("MMI_PROVIDER_EVENT_GESTURE=%d\n", MMI_PROVIDER_EVENT_GESTURE);
+ LOGD("MMI_PROVIDER_EVENT_VOICE=%d\n", MMI_PROVIDER_EVENT_VOICE);
+ LOGD("MMI_PROVIDER_EVENT_VISION=%d\n", MMI_PROVIDER_EVENT_VISION);
+
+ //For debugging
+ _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_KEY,
+ _key_provider_event_cb, NULL);
+ _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_GESTURE,
+ _gesture_provider_event_cb, NULL);
+ _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VOICE,
+ _voice_provider_event_cb, NULL);
+ _provider_event_handlers[0] = ecore_event_handler_add(MMI_PROVIDER_EVENT_VISION,
+ _vision_provider_event_cb, NULL);
+}
+
+static void
+_event_handler_shutdown()
+{
+ //For debugging
+ ecore_event_handler_del(_provider_event_handlers[0]);
+ ecore_event_handler_del(_provider_event_handlers[1]);
+ ecore_event_handler_del(_provider_event_handlers[2]);
+ ecore_event_handler_del(_provider_event_handlers[3]);
+
+ MMI_PROVIDER_EVENT_KEY = -1;
+ MMI_PROVIDER_EVENT_GESTURE = -1;
+ MMI_PROVIDER_EVENT_VOICE = -1;
+ MMI_PROVIDER_EVENT_VISION = -1;
+
+ LOGD("MMI_PROVIDER_EVENT_KEY=%d\n", MMI_PROVIDER_EVENT_KEY);
+ LOGD("MMI_PROVIDER_EVENT_GESTURE=%d\n", MMI_PROVIDER_EVENT_GESTURE);
+ LOGD("MMI_PROVIDER_EVENT_VOICE=%d\n", MMI_PROVIDER_EVENT_VOICE);
+ LOGD("MMI_PROVIDER_EVENT_VISION=%d\n", MMI_PROVIDER_EVENT_VISION);
+}
+
+void
+modality_providers_init(void)
+{
+ //Lookup and init modality providers
+ _event_handler_init();
+ _modality_providers_lookup();
+}
+
+void
+modality_providers_shutdown(void)
+{
+ _event_handler_shutdown();
+
+ //Do shutdown for intialized providers
+ if(!_provider_list)
+ return;
+
+ Eina_List *l = NULL;
+ mmi_provider_handle *provider = NULL;
+ EINA_LIST_FOREACH(_provider_list, l, provider)
+ {
+ if(provider->module_info)
+ {
+ if(provider->module_data)
+ provider->module_info->provider_deinit(provider->module_data);
+ provider->module_data = NULL;
+ provider->module_info = NULL;
+ }
+ if(provider->provider_info)
+ dlclose(provider->provider_info);
+ }
+
+ _provider_list = eina_list_free(_provider_list);
+ _provider_list = NULL;
+}
--- /dev/null
+/*
+* 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_PROVIDER_H__
+#define __MMI_PROVIDER_H__
+
+#include "mmi-common.h"
+
+int mmi_provider_set_op_mode_on_caps(unsigned long long caps, mmi_provider_op_mode mode);
+
+void modality_providers_init(void);
+void modality_providers_shutdown(void);
+
+#endif //__MMI_PROVIDER_H__
'wayland-input.c',
]
-install_headers(
- 'mmi-keyboard-provider.h'
- )
-
-modality_keyboard_include_dirs = include_directories(
- '.',
- )
+modality_keyboard_include_dirs = include_directories('.')
wayland_client_dep = dependency('wayland-client', method : 'pkg-config')
xkbcommon_dep = dependency('xkbcommon', method : 'pkg-config')
tz_extension_dep = dependency('tizen-extension-client', method : 'pkg-config')
+modality_keyboard_deps = [
+ dlog_dep,
+ wayland_client_dep,
+ xkbcommon_dep,
+ tz_extension_dep,
+ ecore_dep,
+ mmimgr_declared_dep
+ ]
+
mmi_provider_prefix_libdir = join_paths(mmi_manager_prefix_libdir, 'provider')
-modality_keyboard_shared = shared_library('mmi_modality_keyboard',
- modality_keyboard_srcs,
- include_directories : [ modality_keyboard_include_dirs, mmi_manager_include_dirs ],
- dependencies : [ dlog_dep, wayland_client_dep, xkbcommon_dep, tz_extension_dep, ecore_dep ],
- install_dir : mmi_provider_prefix_libdir,
- override_options : ['b_lundef=false'],
- install : true)
+modality_keyboard_shared = shared_library(
+ 'mmi_modality_keyboard',
+ modality_keyboard_srcs,
+ include_directories : [modality_keyboard_include_dirs],
+ dependencies : [modality_keyboard_deps],
+ install_dir : mmi_provider_prefix_libdir,
+ install : true,
+ pie : true
+ )
+
'mmi-ref-fusion.c',
]
-install_headers(
- 'mmi-ref-fusion.h'
- )
-
-ref_fusion_include_dirs = include_directories(
- '.',
-)
+ref_fusion_include_dirs = include_directories('.')
-glib_dep = dependency('glib-2.0')
-dlog_dep = dependency('dlog')
+glib_dep = dependency('glib-2.0', method : 'pkg-config')
+dlog_dep = dependency('dlog', method : 'pkg-config')
ecore_dep = dependency('ecore', method : 'pkg-config')
+ref_fusion_deps = [
+ glib_dep,
+ dlog_dep,
+ ecore_dep,
+ mmimgr_declared_dep
+ ]
+
mmi_fusion_prefix_libdir = join_paths(mmi_manager_prefix_libdir, 'fusion')
-ref_fusion_shared = shared_library('mmi_ref_fusion',
- ref_fusion_srcs,
- include_directories : [ ref_fusion_include_dirs, mmi_manager_include_dirs ],
- dependencies : [glib_dep, dlog_dep, ecore_dep ],
- install_dir : mmi_fusion_prefix_libdir,
- override_options : ['b_lundef=false'],
- install : true)
+ref_fusion_shared = shared_library(
+ 'mmi_ref_fusion',
+ ref_fusion_srcs,
+ include_directories : [ref_fusion_include_dirs],
+ dependencies : [ref_fusion_deps],
+ install_dir : mmi_fusion_prefix_libdir,
+ install : true,
+ pie : true
+ )
+
'mmi_iu_noinit_unittests.cpp',
'mmi_iu_unittests.cpp',
'output_intent_unittests.cpp',
- '../../src/mmi-common.c',
- '../../src/iu/input_intent.cpp',
- '../../src/iu/intent_understanding_engine.cpp',
- '../../src/iu/iu_rule.cpp',
- '../../src/iu/mmi_iu.cpp',
- '../../src/iu/output_intent.cpp'
+ '../../src/mmimgr/iu/input_intent.cpp',
+ '../../src/mmimgr/iu/intent_understanding_engine.cpp',
+ '../../src/mmimgr/iu/iu_rule.cpp',
+ '../../src/mmimgr/iu/mmi_iu.cpp',
+ '../../src/mmimgr/iu/output_intent.cpp'
]
gmock_dep = dependency('gmock', method : 'pkg-config')
ecore_dep = dependency('ecore', method : 'pkg-config')
json_glib_dep = dependency('json-glib-1.0', method : 'pkg-config')
-incdir = include_directories('../../src/iu')
+incdir = include_directories('../../src/mmimgr/iu')
executable(
'iu-tests',
iu_tests_srcs,
- dependencies : [mmi_manager_declared_dep, gmock_dep, ecore_dep, json_glib_dep],
+ dependencies : [mmimgr_declared_dep, gmock_dep, ecore_dep, json_glib_dep],
include_directories : incdir,
install_dir : mmi_manager_prefix_bindir,
install : true
executable(
'mmi-manager-tests',
mmi_manager_tests_srcs,
- dependencies : [mmi_manager_declared_dep, gmock_dep, ecore_dep],
+ dependencies : [mmimgr_declared_dep, gmock_dep, ecore_dep],
install_dir : mmi_manager_prefix_bindir,
install : true
)