mmifw: add initial types and data structures 13/264113/1
authorSung-Jin Park <sj76.park@samsung.com>
Mon, 5 Jul 2021 13:50:10 +0000 (22:50 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 13 Sep 2021 12:14:17 +0000 (21:14 +0900)
Change-Id: I1eaffd1db729cebe2745c88d48a220e7b0cf83a4
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
meson.build
packaging/mmifw.spec
src/meson.build
src/mmifw-event-types.h [new file with mode: 0644]
src/mmifw.c
src/mmifw.h

index 3c2a327..3d9cf32 100644 (file)
@@ -3,7 +3,7 @@ project(
        ['c', 'cpp'],
        version : '0.0.1',
        license : 'MIT',
-       default_options : ['c_std=c11', 'cpp_std=c++17', 'b_pie=true']
+       default_options : ['b_pie=true']
 )
 
 mmifw_version = meson.project_version().split('.')
index 3d3c337..0110963 100644 (file)
@@ -27,6 +27,7 @@ MMI(Multi-modal Interaction) Framework Library
 Summary:       Development package for MMI Framework
 Group:         Development/Libraries
 Requires:      %{name} = %{version}-%{release}
+Requires:      pkgconfig(rpc-port)
 %description devel
 Development package for MMI Framework
 
index c44587c..d83df87 100644 (file)
@@ -6,7 +6,8 @@ mmifw_srcs = [
        ]
 
 install_headers(
-       'mmifw.h'
+       'mmifw.h',
+       'mmifw-event-types.h'
        )
 
 glib_dep = dependency('glib-2.0')
diff --git a/src/mmifw-event-types.h b/src/mmifw-event-types.h
new file mode 100644 (file)
index 0000000..60e177a
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMIFW_EVENT_TYPES_H__
+#define __MMIFW_EVENT_TYPES_H__
+
+typedef struct
+{
+   int type;//focus in/out
+   int timestamp;
+   void *user_data;
+   bool focus_in;
+} mmifw_event_focus;
+
+typedef struct {
+   int type;//state change
+   int timestamp;
+   void *user_data;
+   int state;
+   int old_state;
+   void *data;//auxiliary data
+} mmifw_event_state_change;
+
+typedef struct {
+   int type;
+   int timestamp;
+   void *user_data;
+   char *source;//event source information like voice, gesture, key, vision, and so on
+} mmifw_event_wakeup;
+
+typedef struct
+{
+   int type;//up, down, left, right, select, back, ...
+   int timestamp;
+   void *user_data;
+   int keycode;
+   bool key_down;
+   char *keyname;
+   char *source;//event source information
+} mmifw_event_key;
+
+typedef struct {
+   int type;//swipe up, down, left, right, yes, ...
+   int timestamp;
+   void *user_data;
+   char *source;//event source information
+} mmifw_event_gesture;
+
+typedef struct {
+   int type;//voice up, down, left, right, select, back, ...
+   int timestamp;
+   void *user_data;
+   char *source;//event source information
+} mmifw_event_voice;
+
+typedef struct {
+   int type;//action play/pause/resume/stop/execute/launch/revoke/volume ...
+   int timestamp;
+   void *user_data;
+   char *cmd;
+   char **args;
+   int nargs;
+   char *source;//event source information
+} mmifw_event_action;
+
+typedef struct
+{
+   int type;//feedback positive, feedback negative, feedback comment
+   int timestamp;
+   void *user_data;
+   char *feedback;
+   char *comment;
+} mmifw_event_feedback;
+
+#endif //__MMIFW_EVENT_TYPES_H__
index dac2eaf..229d3aa 100644 (file)
 */
 
 #include "mmifw.h"
+#include  <rpc-port/rpc-port.h>
+#include "interface/mmifw_proxy.h"
 
+#define ERR(x)
+
+int MMI_EVENT_FOCUS;
+int MMI_EVENT_STATE_CHANGE;
+int MMI_EVENT_WAKE_UP;
+int MMI_EVENT_KEY;
+int MMI_EVENT_GESTURE;
+int MMI_EVENT_VOICE;
+int MMI_EVENT_ACTION;
+int MMI_EVENT_FEEDBACK;
+
+rpc_port_proxy_mmifw_h rpc_h;
+
+static int _mmi_init_count = 0;
+
+MMIFW_API int
+mmi_init(void)
+{
+       if (++_mmi_init_count != 1)
+               return _mmi_init_count;
+
+       ecore_init();
+
+       MMI_EVENT_FOCUS = ecore_event_type_new();
+       MMI_EVENT_STATE_CHANGE = ecore_event_type_new();
+       MMI_EVENT_WAKE_UP = ecore_event_type_new();
+       MMI_EVENT_KEY = ecore_event_type_new();
+       MMI_EVENT_GESTURE = ecore_event_type_new();
+       MMI_EVENT_VOICE = ecore_event_type_new();
+       MMI_EVENT_ACTION = ecore_event_type_new();
+       MMI_EVENT_FEEDBACK = ecore_event_type_new();
+
+       return _mmi_init_count;
+err:
+       ecore_shutdown();
+       return --_mmi_init_count;
+}
+
+MMIFW_API int
+mmi_shutdown(void)
+{
+       if (_mmi_init_count <= 0)
+       {
+               ERR("Init count must be greater than 0.");
+               return 0;
+       }
+
+       _mmi_init_count--;
+
+       MMI_EVENT_FOCUS = -1;
+       MMI_EVENT_STATE_CHANGE = -1;
+       MMI_EVENT_WAKE_UP = -1;
+       MMI_EVENT_KEY = -1;
+       MMI_EVENT_GESTURE = -1;
+       MMI_EVENT_VOICE = -1;
+       MMI_EVENT_ACTION = -1;
+       MMI_EVENT_FEEDBACK = -1;
+
+       ecore_shutdown();
+       return _mmi_init_count;
+}
+
+MMIFW_API mmi_handle
+mmi_instance_create(const char *app_id)
+{
+       mmi_handle h;
+
+       (void) app_id;
+
+       return h;
+}
+
+MMIFW_API mmi_event_listener *
+mmi_event_add_listener(mmi_handle h, int ev_type, mmi_event_handler_cb func, const void *data)
+{
+       mmi_event_listener *listener;
+
+       (void) h;
+       (void) ev_type;
+       (void) func;
+       (void) data;
+
+       return listener;
+}
+
+MMIFW_API mmi_result
+mmi_request_send_get_focus(mmi_handle h)
+{
+       mmi_result res;
+
+       (void) h;
+
+       return res;
+}
+
+MMIFW_API mmi_state
+mmi_state_get_current_state(mmi_handle h)
+{
+       mmi_state state;
+
+       (void) h;
+
+       return state;
+}
+
+MMIFW_API mmi_result
+mmi_request_send_set_state(mmi_handle h, mmi_state state)
+{
+       mmi_result res;
+
+       (void) h;
+       (void) state;
+
+       return res;
+}
+
+MMIFW_API void *
+mmi_event_remove_listener(mmi_handle h, mmi_event_listener *listener)
+{
+       (void) h;
+       (void) listener;
+
+       return (void *)0;
+}
+
+MMIFW_API void
+mmi_event_remove_all_listeners(mmi_handle h)
+{
+       (void) h;
+}
+
+MMIFW_API void
+mmi_instance_destroy(mmi_handle h)
+{
+       (void) h;
+}
 
index 8d6b00b..ddb25a5 100644 (file)
 #ifndef __MMIFW_H__
 #define __MMIFW_H__
 
+#include <Ecore.h>
+#include <rpc-port/rpc-port.h>
+#include <mmifw-event-types.h>
+
+#define MMIFW_API __attribute__ ((visibility("default")))
+
+MMIFW_API extern int MMI_EVENT_FOCUS;
+MMIFW_API extern int MMI_EVENT_STATE_CHANGE;
+MMIFW_API extern int MMI_EVENT_WAKE_UP;
+MMIFW_API extern int MMI_EVENT_KEY;
+MMIFW_API extern int MMI_EVENT_GESTURE;
+MMIFW_API extern int MMI_EVENT_VOICE;
+MMIFW_API extern int MMI_EVENT_ACTION;
+MMIFW_API extern int MMI_EVENT_FEEDBACK;
+
+typedef void* mmifw_rpc_h;
+typedef Eina_Bool mmi_bool;
+typedef Ecore_Event_Handler mmi_event_listener;
+typedef Ecore_Event_Handler_Cb mmi_evnt_handler_cb;
+typedef mmi_bool (*mmi_event_handler_cb)(void *data, int ev_type, void *event);
+
+typedef enum
+{
+       MMI_RESULT_NONE,
+       MMI_RESULT_FAIL,
+       MMI_RESULT_SUCCESS
+} mmi_result;
+
+typedef enum
+{
+       MMI_STATE_INITIATION,
+       MMI_STATE_EXPLORATION,
+       MMI_STATE_EXECUTION,
+       MMI_STATE_FEEDBACK,
+       MMI_STATE_OBSERVATION,
+       MMI_STATE_TERMINATION
+} mmi_state;
+
+struct _mmi_struct
+{
+       mmifw_rpc_h rpc_h;
+       const char *sender_id;
+       bool connected;
+       int uid;
+       int state;
+       const char *stub_appid;
+};
+
+typedef struct _mmi_struct* mmi_handle;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+MMIFW_API int mmi_init(void);
+MMIFW_API int mmi_shutdown(void);
+MMIFW_API mmi_handle mmi_instance_create(const char *app_id);
+MMIFW_API void mmi_instance_destroy(mmi_handle h);
+
+MMIFW_API mmi_event_listener *mmi_event_add_listener(mmi_handle h, int ev_type, mmi_event_handler_cb func, const void *data);
+MMIFW_API mmi_result mmi_request_send_get_focus(mmi_handle h);
+MMIFW_API mmi_state mmi_state_get_current_state(mmi_handle h);
+MMIFW_API mmi_result mmi_request_send_set_state(mmi_handle h, mmi_state state);
+MMIFW_API void *mmi_event_remove_listener(mmi_handle h, mmi_event_listener *listener);
+MMIFW_API void mmi_event_remove_all_listeners(mmi_handle h);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif //__MMIFW_H__