-# MMI(Multi-modal Interaction) Framework Library
+# MMI(Multi-modal Interaction) Framework
+### Build & Install
+Build this project using `gbs` and install the artifacts into the Tizen device via `sdb` command
+
+### Run
+Execute `mmi-manager` program.
+```console
+$ mmi-manager
```
-[Source Tree]
-.
-├── capi
-│  ├── meson.build
-│  ├── mmi-attribute.h
-│  ├── mmi-data.h
-│  ├── mmi-error.h
-│  ├── mmi.h
-│  ├── mmi-node-gate.h
-│  ├── mmi-node.h
-│  ├── mmi-node-processor.h
-│  ├── mmi-node-source.h
-│  ├── mmi-port.h
-│  ├── mmi-primitive-value.h
-│  ├── mmi-signal.h
-│  └── mmi-workflow.h
-├── CODEOWNERS
-├── COPYING
-├── meson.build
-├── meson_options.txt
-├── packaging
-│  ├── mmi.manifest
-│  └── mmi.spec
-├── README.md
-├── src
-│  ├── common
-│  │  ├── mmi-communication-channel.h
-│  │  ├── mmi-communication-message.h
-│  │  └── mmi-event-observer.h
-│  ├── meson.build
-│  ├── mmi-attribute.cpp
-│  ├── mmi-client-manager.h
-│  ├── mmi.cpp
-│  ├── mmi-data.cpp
-│  ├── mmi-ipc-tidl.cpp
-│  ├── mmi-ipc-tidl.h
-│  ├── mmi-log.h
-│  ├── mmi-node.cpp
-│  ├── mmi-node-gate.cpp
-│  ├── mmi-node-processor.cpp
-│  ├── mmi-node-source.cpp
-│  ├── mmi-port.cpp
-│  ├── mmi-primitive-value.cpp
-│  ├── mmi-signal.cpp
-│  ├── mmi-workflow.cpp
-│  └── mmi-workflow-instance-manager.h
-├── tests
-│  ├── meson.build
-│  ├── mmi-attribute-test.cpp
-│  ├── mmi-data-test.cpp
-│  ├── mmi-ipc-test.cpp
-│  ├── mmi-main-test.cpp
-│  ├── mmi-primitive-value-test.cpp
-│  ├── mmi-tests.cpp
-│  └── mmi-tests.h
-└── tidl
- └── mmi.tidl
+
+### Test
+You can write your own program using the headers and libraries
+provided by the package `mmi-devel`, but it is also possible to
+use our CLI program to test the basic functions and capabilities.
+```console
+$ dlogutil MMI MMIMGR & # To check the log
+$ mmi-cli
+State changed to 1
+cli> create 1
+Creating instance of type 1
+cli> activate
+Activating instance
+
+<Logs will be printed>
+....
```
'mmi-node-logic.h',
'mmi-node-controller.h',
'mmi-node-action.h',
+ 'mmi-node-custom.h',
'mmi-port.h',
'mmi-signal.h',
'mmi-defines.h',
#endif
-enum mmi_standard_node_action_type_e {
- MMI_STANDARD_NODE_ACTION_TYPE_NONE,
+enum mmi_node_action_type_e {
+ MMI_NODE_ACTION_TYPE_NONE,
/* - Description : Emits a mouse event
- Attributes :
Data Type : MMI_DATA_TYPE_COORDINATE
Description : When a coordinate data is received, emits a mouse event
*/
- MMI_STANDARD_NODE_ACTION_TYPE_MOUSE_EVENT,
+ MMI_NODE_ACTION_TYPE_MOUSE_EVENT,
- MMI_STANDARD_NODE_ACTION_TYPE_KEY_EVENT,
+ MMI_NODE_ACTION_TYPE_KEY_EVENT,
};
-int mmi_standard_node_create_action(mmi_standard_node_action_type_e type, mmi_node_h *node);
+int mmi_node_create_action(mmi_node_action_type_e type, mmi_node_h *node);
-int mmi_standard_node_get_action_type(mmi_node_h node, mmi_standard_node_action_type_e *type);
-
-int mmi_standard_node_register_action(mmi_standard_node_action_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node);
+int mmi_node_get_action_type(mmi_node_h node, mmi_node_action_type_e *type);
#ifdef __cplusplus
}
#endif
-enum mmi_standard_node_controller_type_e {
- MMI_STANDARD_NODE_CONTROLLER_TYPE_NONE,
+enum mmi_node_controller_type_e {
+ MMI_NODE_CONTROLLER_TYPE_NONE,
/* - Description : Turns the node with a name specified in the attribute "TARGET" on or off
- Attributes :
Name : "VALUE"
Data Type : MMI_DATA_TYPE_BOOLEAN
*/
- MMI_STANDARD_NODE_CONTROLLER_TYPE_SWITCH,
+ MMI_NODE_CONTROLLER_TYPE_SWITCH,
};
-int mmi_standard_node_create_controller(mmi_standard_node_controller_type_e type, mmi_node_h *node);
+int mmi_node_create_controller(mmi_node_controller_type_e type, mmi_node_h *node);
-int mmi_standard_node_get_controller_type(mmi_node_h node, mmi_standard_node_controller_type_e *type);
-
-int mmi_standard_node_register_controller(mmi_standard_node_controller_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node);
+int mmi_node_get_controller_type(mmi_node_h node, mmi_node_controller_type_e *type);
#ifdef __cplusplus
}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#ifndef __TIZEN_UIX_MMI_NODE_CUSTOM_H__
+#define __TIZEN_UIX_MMI_NODE_CUSTOM_H__
+
+
+
+#include <mmi-node.h>
+
+/**
+* @file mmi-node-custom.h
+*/
+
+
+/**
+* @addtogroup CAPI_UIX_MMI_MODULE
+* @{
+*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mmi_node_create_custom(const char *custom_type_id, mmi_node_h *node);
+
+int mmi_node_get_custom_type(mmi_node_h node, const char **custom_type_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __TIZEN_UIX_MMI_NODE_CUSTOM_H__ */
#endif
-enum mmi_standard_node_logic_type_e {
- MMI_STANDARD_NODE_LOGIC_TYPE_NONE,
+enum mmi_node_logic_type_e {
+ MMI_NODE_LOGIC_TYPE_NONE,
/*
- Description : Compares the text received from the input port 1 ("TEXT") with
Name : "MATCHED_STRUCT_ARRAY"
Data Type : MMI_DATA_TYPE_STRUCT
*/
- MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH,
+ MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH,
/*
- Description : Tests if the regex strings specified in the attribute "REGEX" with
Name : "MATCHED_STRUCT_ARRAY"
Data Type : MMI_DATA_TYPE_STRUCT
*/
- MMI_STANDARD_NODE_LOGIC_TYPE_REGEX_STRING_MATCH,
+ MMI_NODE_LOGIC_TYPE_REGEX_STRING_MATCH,
/*
Name : "COMPARISON_RESULT"
Data Type : MMI_DATA_TYPE_USER_IDENTIFICATION
*/
- MMI_STANDARD_NODE_LOGIC_TYPE_USER_COMPARISON,
+ MMI_NODE_LOGIC_TYPE_USER_COMPARISON,
};
-int mmi_standard_node_create_logic(mmi_standard_node_logic_type_e type, mmi_node_h *node);
+int mmi_node_create_logic(mmi_node_logic_type_e type, mmi_node_h *node);
-int mmi_standard_node_get_logic_type(mmi_node_h node, mmi_standard_node_logic_type_e *type);
-
-int mmi_standard_node_register_logic(mmi_standard_node_logic_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node);
+int mmi_node_get_logic_type(mmi_node_h node, mmi_node_logic_type_e *type);
#ifdef __cplusplus
}
#endif
-enum mmi_standard_node_processor_type_e {
- MMI_STANDARD_NODE_PROCESSOR_TYPE_NONE,
+enum mmi_node_processor_type_e {
+ MMI_NODE_PROCESSOR_TYPE_NONE,
/*
- Attributes : None
Name : "FINAL"
Data Type : MMI_DATA_TYPE_TEXT
*/
- MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR,
+ MMI_NODE_PROCESSOR_TYPE_ASR,
/*
- Attributes : None
Name : "VIDEO_OUT"
Data Type : MMI_DATA_TYPE_VIDEO
*/
- MMI_STANDARD_NODE_PROCESSOR_TYPE_VIDEO_CONVERTER,
+ MMI_NODE_PROCESSOR_TYPE_VIDEO_CONVERTER,
/*
- Attributes : None
- "USER" : MMI_DATA_TYPE_USER_IDENTIFICATION
- "SCORE" : MMI_DATA_TYPE_FLOAT
*/
- MMI_STANDARD_NODE_PROCESSOR_TYPE_FACE_RECOGNITION,
+ MMI_NODE_PROCESSOR_TYPE_FACE_RECOGNITION,
/*
- Attributes : None
- "USER" : MMI_DATA_TYPE_USER_IDENTIFICATION
- "SCORE" : MMI_DATA_TYPE_FLOAT
*/
- MMI_STANDARD_NODE_PROCESSOR_TYPE_SPEAKER_RECOGNITION,
+ MMI_NODE_PROCESSOR_TYPE_SPEAKER_RECOGNITION,
/*
- Attributes :
Name : "REJECTED"
Data Type : MMI_DATA_TYPE_TEXT
*/
- MMI_STANDARD_NODE_PROCESSOR_TYPE_VOICE_TOUCH,
-};
+ MMI_NODE_PROCESSOR_TYPE_VOICE_TOUCH,
-int mmi_standard_node_create_processor(mmi_standard_node_processor_type_e type, mmi_node_h *node);
+ /*
+ - Attributes : None
+ - Input Port 1
+ Name : "AUDIO"
+ Data Type : MMI_DATA_TYPE_AUDIO
+ - Output Port 1
+ Name : "DETECTED_BOS"
+ Data Type : MMI_DATA_TYPE_BOOLEAN
+ - Output Port 2
+ Name : "DETECTED_EOS"
+ Data Type : MMI_DATA_TYPE_BOOLEAN
+ */
+ MMI_NODE_PROCESSOR_TYPE_VOICE_ACTIVITY_DETECTOR,
+};
-int mmi_standard_node_get_processor_type(mmi_node_h node, mmi_standard_node_processor_type_e *type);
+int mmi_node_create_processor(mmi_node_processor_type_e type, mmi_node_h *node);
-int mmi_standard_node_register_processor(mmi_standard_node_processor_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node);
+int mmi_node_get_processor_type(mmi_node_h node, mmi_node_processor_type_e *type);
#ifdef __cplusplus
}
extern "C" {
#endif
-enum mmi_standard_node_source_type_e {
- MMI_STANDARD_NODE_SOURCE_TYPE_NONE,
+enum mmi_node_source_type_e {
+ MMI_NODE_SOURCE_TYPE_NONE,
/*
- Description : A microphone that captures sound all the time.
Type : OUT
Data Type : MMI_DATA_TYPE_AUDIO
*/
- MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT,
+ MMI_NODE_SOURCE_TYPE_MIC_AMBIENT,
/*
- Description : A camera that captures video.
Type : OUT
Data Type : MMI_DATA_TYPE_VIDEO
*/
- MMI_STANDARD_NODE_SOURCE_TYPE_CAMERA,
+ MMI_NODE_SOURCE_TYPE_CAMERA,
/*
- Description : A screen analyzer that gets screen info when rescanning occur.
"role": MMI_DATA_TYPE_TEXT,
}
*/
- MMI_STANDARD_NODE_SOURCE_TYPE_SCREEN_ANALYZER,
+ MMI_NODE_SOURCE_TYPE_SCREEN_ANALYZER,
};
-int mmi_standard_node_create_source(mmi_standard_node_source_type_e type, mmi_node_h *node);
+int mmi_node_create_source(mmi_node_source_type_e type, mmi_node_h *node);
-int mmi_standard_node_get_source_type(mmi_node_h node, mmi_standard_node_source_type_e *type);
+int mmi_node_get_source_type(mmi_node_h node, mmi_node_source_type_e *type);
#ifdef __cplusplus
}
extern "C" {
#endif
-enum mmi_standard_node_type_e {
- MMI_STANDARD_NODE_TYPE_NONE,
- MMI_STANDARD_NODE_TYPE_SOURCE,
- MMI_STANDARD_NODE_TYPE_PROCESSOR,
- MMI_STANDARD_NODE_TYPE_LOGIC,
- MMI_STANDARD_NODE_TYPE_CONTROLLER,
- MMI_STANDARD_NODE_TYPE_ACTION,
+enum mmi_node_type_e {
+ MMI_NODE_TYPE_NONE,
+ MMI_NODE_TYPE_SOURCE,
+ MMI_NODE_TYPE_PROCESSOR,
+ MMI_NODE_TYPE_LOGIC,
+ MMI_NODE_TYPE_CONTROLLER,
+ MMI_NODE_TYPE_ACTION,
+ MMI_NODE_TYPE_CUSTOM,
};
typedef void* mmi_node_instance_h;
} mmi_node_callbacks;
typedef struct {
- mmi_standard_node_type_e type;
+ mmi_node_type_e type;
int sub_type;
+ char custom_type_id[MMI_NAME_MAX_LENGTH];
mmi_port_h *ports;
size_t port_count;
mmi_node_callbacks callbacks;
int mmi_node_find_port(mmi_node_h node, mmi_port_type_e port_type, const char *port_name, mmi_port_h *port);
/* Retrieves the type of a node. */
-int mmi_node_get_type(mmi_node_h node, mmi_standard_node_type_e *type);
+int mmi_node_get_type(mmi_node_h node, mmi_node_type_e *type);
/* Retrieves the number of ports in a node. */
int mmi_node_get_port_count(mmi_node_h node, size_t *port_count);
#include <mmi-node-logic.h>
#include <mmi-node-controller.h>
#include <mmi-node-action.h>
+#include <mmi-node-custom.h>
#include <mmi-workflow.h>
/**
/* Clones a workflow. */
int mmi_workflow_clone(mmi_workflow_h workflow, mmi_workflow_h *cloned);
+/* Create a workflow prototype from a script */
+int mmi_workflow_create_from_script(const char *script, mmi_workflow_h *workflow);
+
/* Create a workflow prototype from a script file */
-int mmi_workflow_create_from_script(const char *script_path, mmi_workflow_h *workflow);
+int mmi_workflow_create_from_script_file(const char *script_path, mmi_workflow_h *workflow);
/* Destroy a workflow prototype */
int mmi_workflow_destroy(mmi_workflow_h workflow);
/* Instantiate a workflow from a workflow prototype */
int mmi_standard_workflow_instance_create(mmi_standard_workflow_type_e type, mmi_workflow_instance_h *instance);
+/* Instantiate a workflow from a workflow script */
+int mmi_custom_workflow_instance_create_from_script(const char *workflow_script, mmi_workflow_instance_h *instance);
+
+/* Instantiate a workflow from a workflow script file */
+int mmi_custom_workflow_instance_create_from_script_file(const char *workflow_script_path, mmi_workflow_instance_h *instance);
+
/* Destroy a workflow instance */
int mmi_workflow_instance_destroy(mmi_workflow_instance_h instance);
/* Emit a signal to a workflow instance */
int mmi_workflow_instance_emit_signal(mmi_workflow_instance_h instance, mmi_signal_h signal);
+/* Feed data to a port of a node with given name pair */
+int mmi_workflow_instance_feed_data(mmi_workflow_instance_h instance, const char *node_name, const char *port_name, mmi_data_h data);
+
/* Set a callback function to receive workflow output */
int mmi_workflow_instance_set_output_callback(mmi_workflow_instance_h instance, const char *name, mmi_workflow_output_cb callback, void *user_data);
mmi_extra_flags = ''.join(['-DMMI_INSTALL_PREFIX="', mmi_prefix, '"'])
add_global_arguments(mmi_extra_flags, language : ['c', 'cpp'])
+add_global_arguments('-Werror', language : ['c', 'cpp'])
pkgconfig = import('pkgconfig')
--- /dev/null
+<?xml version="1.0"?>
+<mmi-config>
+ <confidence>0.5f</confidence>
+</mmi-config>
Name: mmi
-Version: 2.0.2
+Version: 2.1.0
Release: 0
Summary: Multi-modal Interaction Framework
License: MIT
#include <stdio.h>
#define EXPORT_API
-static char *get_error_message(int err) { return "Unknown"; }
+[[maybe_unused]] static const char *get_error_message(int err) { return "Unknown"; }
#define MMI_DEFAULT_CONFIG "/usr/local/mmi/configs/mmi-config.xml"
auto const ext = entry.path().string().substr(pos + 1);
if (ext == "mws") {
mmi_workflow_h workflow = nullptr;
- mmi_workflow_create_from_script(entry.path().string().c_str(), &workflow);
+ mmi_workflow_create_from_script_file(entry.path().string().c_str(), &workflow);
mmi_standard_workflow_register(workflow);
mmi_workflow_destroy(workflow);
}
mmi_workflow_set_type(workflow, MMI_STANDARD_WORKFLOW_VOICE_TOUCH);
mmi_node_h node_mic = nullptr;
- mmi_standard_node_create_source(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
+ mmi_node_create_source(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
mmi_workflow_node_add(workflow, NODE_NAME_MIC, node_mic);
mmi_node_h node_asr = nullptr;
- mmi_standard_node_create_processor(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR, &node_asr);
+ mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_ASR, &node_asr);
mmi_workflow_node_add(workflow, NODE_NAME_ASR, node_asr);
mmi_node_h node_match_mode_commands = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match_mode_commands);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match_mode_commands);
mmi_workflow_node_add(workflow, NODE_NAME_MATCH_MODE_COMMANDS, node_match_mode_commands);
mmi_node_h node_match_predefined_commands = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match_predefined_commands);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match_predefined_commands);
mmi_workflow_node_add(workflow, NODE_NAME_MATCH_PREDEFINED_COMMANDS, node_match_predefined_commands);
mmi_node_h node_voice_touch = nullptr;
- mmi_standard_node_create_processor(MMI_STANDARD_NODE_PROCESSOR_TYPE_VOICE_TOUCH, &node_voice_touch);
+ mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_VOICE_TOUCH, &node_voice_touch);
mmi_workflow_node_add(workflow, NODE_NAME_VOICE_TOUCH_PROCESSOR, node_voice_touch);
mmi_node_h node_screen_analyzer = nullptr;
- mmi_standard_node_create_source(MMI_STANDARD_NODE_SOURCE_TYPE_SCREEN_ANALYZER, &node_screen_analyzer);
+ mmi_node_create_source(MMI_NODE_SOURCE_TYPE_SCREEN_ANALYZER, &node_screen_analyzer);
mmi_workflow_node_add(workflow, NODE_NAME_SCREEN_ANALYZER, node_screen_analyzer);
#ifdef ENABLE_TEMP_RESCAN
/* This is a temporary node for rescanning the screen, it will be removed when the signal mechanism is ready */
mmi_node_h temp_node_match_rescan_command = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &temp_node_match_rescan_command);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &temp_node_match_rescan_command);
mmi_workflow_node_add(workflow, "TEMP_RESCAN", temp_node_match_rescan_command);
#endif
mmi_node_h node_mic = nullptr;
/* FIXME: node should be 'found' instead of 'created' */
- mmi_standard_node_create_source(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
+ mmi_node_create_source(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
mmi_workflow_node_add(workflow, "MIC", node_mic);
mmi_node_h node_asr = nullptr;
- mmi_standard_node_create_processor(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR, &node_asr);
+ mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_ASR, &node_asr);
mmi_workflow_node_add(workflow, "ASR", node_asr);
mmi_node_h node_match = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match);
mmi_workflow_node_add(workflow, "MATCH", node_match);
mmi_workflow_link_nodes_by_names(workflow, "MIC", "AUDIO", "ASR", "AUDIO");
WORKFLOW_INSTANCE_DESTROY,
WORKFLOW_INSTANCE_SET_ATTRIBUTE,
WORKFLOW_INSTANCE_EMIT_SIGNAL,
+ WORKFLOW_INSTANCE_FEED_DATA,
WORKFLOW_INSTANCE_ACTIVATE,
WORKFLOW_INSTANCE_DEACTIVATE,
/* Manager to Client */
struct ClientMessageWorkflowInstanceCreate : public ClientMessage {
ClientMessageWorkflowInstanceCreate() : ClientMessage{CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_CREATE} {}
mmi_standard_workflow_type_e workflow_type{MMI_STANDARD_WORKFLOW_NONE};
+ bool script_from_file{false};
+ std::string script_info;
int local_workflow_instance_id{0};
void *user_data{nullptr};
};
mmi_signal_h signal{nullptr};
};
+struct ClientMessageWorkflowInstanceFeedData : public ClientMessage {
+ ClientMessageWorkflowInstanceFeedData() : ClientMessage{CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_FEED_DATA} {}
+ int local_workflow_instance_id{0};
+ std::string node_name;
+ std::string port_name;
+ mmi_data_h data{nullptr};
+};
+
struct ClientMessageWorkflowInstanceActivate : public ClientMessage {
ClientMessageWorkflowInstanceActivate() : ClientMessage{CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_ACTIVATE} {}
int local_workflow_instance_id{0};
printf("%s(%d) > " fmt "\n", __func__, __LINE__, ##arg); \
} while (0); })
-#define _D(fmt, args...) MMI_CLI_LOG_(fmt, ##args)
-#define _I(fmt, args...) MMI_CLI_LOG_(fmt, ##args)
-#define _W(fmt, args...) MMI_CLI_LOG_(fmt, ##args)
-#define _E(fmt, args...) MMI_CLI_LOG_(fmt, ##args)
-
class Program;
struct PortInstance
struct NodeInstance
{
- mmi_standard_node_type_e m_node_type;
+ mmi_node_type_e m_node_type;
mmi_node_callbacks m_callbacks{nullptr,};
_D("node_list.count: %zu", m_node_list.node_count);
for (size_t i = 0;i < m_node_list.node_count;i++) {
mmi_node_h node = m_node_list.nodes[i];
- mmi_standard_node_type_e type;
+ mmi_node_type_e type;
mmi_node_get_type(node, &type);
mmi_node_callbacks callbacks;
mmi_node_get_callbacks(node, &callbacks);
/* Currently only one node is supported */
mmi_node_h node = m_node_list.nodes[0];
- mmi_standard_node_type_e type;
+ mmi_node_type_e type;
mmi_node_get_type(node, &type);
mmi_node_callbacks callbacks;
mmi_node_get_callbacks(node, &callbacks);
std::string name = read_string_value("Enter port name: ");
for (auto port_instance : node_instance->m_ports) {
if (port_instance->m_name == name) {
- mmi_data_h data = nullptr;
-
size_t entry_index = static_cast<size_t>(DataTestType::MaxCount);
for (size_t i = 0;i < sizeof(g_data_test_entries) / sizeof(g_data_test_entries[0]);i++) {
if (g_data_test_entries[i].type == type) {
},
nullptr);
}
+ void create_instance_from_script() {
+ if (m_instance) {
+ std::cout << "Instance already created" << std::endl;
+ return;
+ }
+
+ std::string script = R"(
+@workflow
+
+@node-list
+[Source] MIC_AMBIENT as MIC
+[Processor] ASR as ASR
+[Logic] FIXED_STRING_MATCH as MATCH
+
+@link-list
+MIC.AUDIO -> ASR.AUDIO
+ASR.FINAL_ASR -> MATCH.TEXT
+
+@attribute-list
+MATCH.CANDIDATES as COMMANDS
+
+@output-list
+MATCH.COMMAND as MATCHED_CANDIDATE
+ )";
+ std::cout << "Creating instance of script : " << std::endl << script << std::endl;
+ mmi_custom_workflow_instance_create_from_script(script.c_str(), &m_instance);
+ mmi_workflow_instance_set_output_callback(m_instance, "COMMAND",
+ [](mmi_workflow_instance_h instance, const char *name, mmi_data_h data, void *user_data) {
+ std::cout << "OUTPUT data received : " << std::string(name ? name : "") << std::endl;
+ },
+ nullptr);
+ }
+ void create_instance_from_file(std::string path) {
+ if (m_instance) {
+ std::cout << "Instance already created" << std::endl;
+ return;
+ }
+
+ std::cout << "Creating instance of script with path : " << path << std::endl;
+ mmi_custom_workflow_instance_create_from_script_file(path.c_str(), &m_instance);
+ mmi_workflow_instance_set_output_callback(m_instance, "COMMAND",
+ [](mmi_workflow_instance_h instance, const char *name, mmi_data_h data, void *user_data) {
+ std::cout << "OUTPUT data received : " << std::string(name ? name : "") << std::endl;
+ },
+ nullptr);
+ }
void destroy_instance() {
if (!m_instance) {
std::cout << "No instance to destroy" << std::endl;
std::cout << "Deactivating instance" << std::endl;
mmi_workflow_instance_deactivate(m_instance);
}
- void set_attribute() {
+ void set_attribute(std::string name, std::string type, std::string value) {
if (!m_instance) {
std::cout << "No instance to set attribute" << std::endl;
return;
std::cout << "Setting attribute " << std::endl;
- mmi_attribute_h attribute = nullptr;
- constexpr size_t COMMAND_NUM = 2;
- const char *commands[] = {"Open", "Close"};
- mmi_attribute_create_string_array("COMMANDS", commands, COMMAND_NUM, &attribute);
-
- mmi_workflow_instance_set_attribute(m_instance, attribute);
-
- mmi_attribute_destroy(attribute);
-
- attribute = nullptr;
- mmi_primitive_value_h lang_value = nullptr;
- mmi_primitive_value_create_string("ko-KR", &lang_value);
- mmi_attribute_create(lang_value, "LANGUAGE", &attribute);
- mmi_workflow_instance_set_attribute(m_instance, attribute);
- mmi_attribute_destroy(attribute);
- mmi_primitive_value_destroy(lang_value);
-
- attribute = nullptr;
- mmi_primitive_value_h stop_method_value = nullptr;
- mmi_primitive_value_create_int(1, &stop_method_value); // 1 : silence detection
- mmi_attribute_create(stop_method_value, "STOP_METHOD", &attribute);
- mmi_workflow_instance_set_attribute(m_instance, attribute);
- mmi_attribute_destroy(attribute);
- mmi_primitive_value_destroy(stop_method_value);
+ if (type.compare("int") == 0) {
+ mmi_attribute_h attribute = nullptr;
+ mmi_primitive_value_h int_value = nullptr;
+ mmi_primitive_value_create_int(std::stoi(value), &int_value);
+ mmi_attribute_create(int_value, name.c_str(), &attribute);
+ mmi_workflow_instance_set_attribute(m_instance, attribute);
+ mmi_attribute_destroy(attribute);
+ mmi_primitive_value_destroy(int_value);
+ } else if (type.compare("string") == 0) {
+ mmi_attribute_h attribute = nullptr;
+ mmi_primitive_value_h string_value = nullptr;
+ mmi_primitive_value_create_string(value.c_str(), &string_value);
+ mmi_attribute_create(string_value, name.c_str(), &attribute);
+ mmi_workflow_instance_set_attribute(m_instance, attribute);
+ mmi_attribute_destroy(attribute);
+ mmi_primitive_value_destroy(string_value);
+ } else if (type.compare("string_array") == 0) {
+ mmi_attribute_h attribute = nullptr;
+
+ std::vector<std::string> strings;
+ std::istringstream ss{value};
+ std::string temp;
+
+ while (getline(ss, temp, ',')) {
+ strings.push_back(temp);
+ }
+
+ mmi_primitive_value_h array = nullptr;
+ mmi_primitive_value_create_array(&array);
+
+ for (size_t i = 0; i < strings.size(); i++) {
+ mmi_primitive_value_h element = nullptr;
+ mmi_primitive_value_create_string(strings.at(i).c_str(), &element);
+ mmi_primitive_value_add_array_element(array, element);
+ }
+
+ mmi_attribute_create(array, name.c_str(), &attribute);
+
+ mmi_workflow_instance_set_attribute(m_instance, attribute);
+
+ mmi_primitive_value_destroy(array);
+ mmi_attribute_destroy(attribute);
+ }
}
void emit_signal() {
if (!m_instance) {
mmi_signal_parameter_destroy(signal_parameter_2);
mmi_primitive_value_destroy(signal_parameter_value_2);
}
+ void feed_data(std::string node_name, std::string port_name, std::string type, std::string value) {
+ if (!m_instance) {
+ std::cout << "No instance to feed data" << std::endl;
+ return;
+ }
+
+ std::cout << "Feeding data " << std::endl;
+
+ mmi_data_h data = nullptr;
+ if (type.compare("int") == 0) {
+ mmi_data_create_int(std::stoi(value), &data);
+ } else if (type.compare("text") == 0) {
+ mmi_data_create_text(value.c_str(), &data);
+ }
+ mmi_workflow_instance_feed_data(m_instance, node_name.c_str(), port_name.c_str(), data);
+ mmi_data_destroy(data);
+ }
static int state_changed_cb(mmi_state_e state, void *user_data) {
},
"Creates a new workflow instance");
+ rootMenu->Insert("create_from_script", [](std::ostream& out) {
+ g_program.create_instance_from_script();
+ },
+ "Creates a new workflow instance from the predefined script data");
+
+ rootMenu->Insert("create_from_file", [](std::ostream& out, std::string path) {
+ g_program.create_instance_from_file(path);
+ },
+ "Creates a new workflow instance from a script file");
+
rootMenu->Insert("destroy", [](std::ostream& out) {
g_program.destroy_instance();
},
"Destroys the current workflow instance");
- rootMenu->Insert("set_attribute", [](std::ostream& out) {
- g_program.set_attribute();
+ rootMenu->Insert("set_attribute", [](std::ostream& out, std::string name, std::string type, std::string value) {
+ g_program.set_attribute(name, type, value);
+ },
+ "Set attributes for the current workflow instance");
+
+ rootMenu->Insert("feed_data", [](std::ostream& out, std::string node_name, std::string port_name, std::string type, std::string value) {
+ g_program.feed_data(node_name, port_name, type, value);
},
"Set attributes for the current workflow instance");
void CommunicationChannelEcoreIPC::on_client_message(Ecore_Ipc_Client *client, void *data, int size)
{
- if (size < sizeof(CLIENT_MESSAGE_TYPE)) {
- _E("Data Size too small : %d", size)
+ size_t data_size = static_cast<size_t>(size);
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE)) {
+ _E("Data Size too small : %zu", data_size)
return;
}
struct workflow_instance_create_payload {
int local_workflow_instance_id;
mmi_standard_workflow_type_e workflow_type;
+ bool script_from_file;
+ size_t script_info_size;
} payload;
- if (size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
- _E("Data Size too small : %d", size)
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
+ _E("Data Size too small : %zu", data_size)
return;
}
- memcpy(&payload, data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
+ memcpy(&payload, (unsigned char*)data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
ClientMessageWorkflowInstanceCreate message;
message.sender = sender;
message.local_workflow_instance_id = payload.local_workflow_instance_id;
message.workflow_type = payload.workflow_type;
+ message.script_from_file = payload.script_from_file;
+ message.script_info = std::string(
+ (const char*)((unsigned char*)(data) +
+ sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)),
+ payload.script_info_size);
notify_observers(
COMMUNICATION_CHANNEL_EVENT_TYPE::MESSAGE_RECEIVED,
static_cast<Message*>(&message));
struct workflow_instance_destroy_payload {
int local_workflow_instance_id;
} payload;
- if (size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
- _E("Data Size too small : %d", size)
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
+ _E("Data Size too small : %zu", data_size)
return;
}
- memcpy(&payload, data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
+ memcpy(&payload, (unsigned char*)data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
ClientMessageWorkflowInstanceDestroy message;
message.sender = sender;
message.local_workflow_instance_id = payload.local_workflow_instance_id;
char attribute_name[MMI_NAME_MAX_LENGTH];
size_t value_size;
} payload;
- if (size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
- _E("Data Size too small : %d", size)
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
+ _E("Data Size too small : %zu", data_size)
return;
}
- memcpy(&payload, data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
+ memcpy(&payload, (unsigned char*)data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
mmi_primitive_value_h value = nullptr;
int index = sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload);
mmi_primitive_value_from_bytes((unsigned char *)data + index, payload.value_size, &value);
char signal_name[MMI_NAME_MAX_LENGTH];
int signal_parameter_count;
} payload;
- if (size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
- _E("Data Size too small : %d", size)
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
+ _E("Data Size too small : %zu", data_size)
return;
}
- memcpy(&payload, data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
+ memcpy(&payload, (unsigned char*)data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
int index = sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload);
_D("Signal Name %s, Parameter Count : %d", payload.signal_name, payload.signal_parameter_count);
for (int loop = 0;loop < payload.signal_parameter_count;loop++) {
char parameter_name[MMI_NAME_MAX_LENGTH];
- memcpy(parameter_name, data + index, MMI_NAME_MAX_LENGTH);
+ memcpy(parameter_name, (unsigned char*)data + index, MMI_NAME_MAX_LENGTH);
index += MMI_NAME_MAX_LENGTH;
_D("Parameter Name : %s", parameter_name);
int value_size = 0;
- memcpy(&value_size, data + index, sizeof(int));
+ memcpy(&value_size, (unsigned char*)data + index, sizeof(int));
index += sizeof(int);
mmi_primitive_value_h value;
mmi_signal_destroy(signal);
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_FEED_DATA:
+ {
+ struct workflow_instance_feed_data_payload {
+ int local_workflow_instance_id;
+ char node_name[MMI_NAME_MAX_LENGTH];
+ char port_name[MMI_NAME_MAX_LENGTH];
+ } payload;
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
+ _E("Data Size too small : %zu", data_size)
+ return;
+ }
+ memcpy(&payload, (unsigned char*)data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
+ int index = sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload);
+ _D("Node Name %s, Port Name %s", payload.node_name, payload.port_name);
+
+ int data_size = 0;
+ memcpy(&data_size, (unsigned char*)data + index, sizeof(size_t));
+ index += sizeof(size_t);
+
+ mmi_data_h restored_data;
+ mmi_data_from_bytes((unsigned char*)data + index, data_size, &restored_data);
+ index += data_size;
+
+ ClientMessageWorkflowInstanceFeedData message;
+ message.sender = sender;
+ message.local_workflow_instance_id = payload.local_workflow_instance_id;
+ message.node_name = payload.node_name;
+ message.port_name = payload.port_name;
+ message.data = restored_data;
+ notify_observers(
+ COMMUNICATION_CHANNEL_EVENT_TYPE::MESSAGE_RECEIVED,
+ static_cast<Message*>(&message));
+
+ mmi_data_destroy(restored_data);
+ }
+ break;
case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_ACTIVATE:
{
struct workflow_instance_activate_payload {
int local_workflow_instance_id;
} payload;
- if (size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
- _E("Data Size too small : %d", size)
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
+ _E("Data Size too small : %zu", data_size)
return;
}
- memcpy(&payload, data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
+ memcpy(&payload, (unsigned char*)data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
ClientMessageWorkflowInstanceActivate message;
message.sender = sender;
message.local_workflow_instance_id = payload.local_workflow_instance_id;
struct workflow_instance_deactivate_payload {
int local_workflow_instance_id;
} payload;
- if (size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
- _E("Data Size too small : %d", size)
+ if (data_size < sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload)) {
+ _E("Data Size too small : %zu", data_size)
return;
}
- memcpy(&payload, data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
+ memcpy(&payload, (unsigned char*)data + sizeof(CLIENT_MESSAGE_TYPE), sizeof(payload));
ClientMessageWorkflowInstanceDeactivate message;
message.sender = sender;
message.local_workflow_instance_id = payload.local_workflow_instance_id;
static_cast<Message*>(&message));
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_OUTPUT:
+ {
+ _E("Error : Manager to Client message received");
+ }
+ break;
}
}
workflow_instance_destroy,
workflow_instance_set_attribute,
workflow_instance_emit_signal,
+ workflow_instance_feed_data,
workflow_instance_activate,
workflow_instance_deactivate,
workflow_instance_register_result_callback,
}
int CommunicationChannelTIDL::workflow_instance_create(rpc_port_stub_mmi_context_h context,
- int local_workflow_instance_id, int workflow_type, void *user_data) {
+ int local_workflow_instance_id, int workflow_type, bool script_from_file,
+ const char *script_info, void *user_data) {
CommunicationChannelTIDL *channel = static_cast<CommunicationChannelTIDL*>(user_data);
std::string sender;
msg.sender = sender;
msg.local_workflow_instance_id = local_workflow_instance_id;
msg.workflow_type = static_cast<mmi_standard_workflow_type_e>(workflow_type);
+ msg.script_from_file = script_from_file;
+ msg.script_info = script_info ? std::string{script_info} : std::string();
return notify_message_received(channel, static_cast<Message*>(&msg));
}
return MMI_ERROR_NONE;
}
+int CommunicationChannelTIDL::workflow_instance_feed_data(rpc_port_stub_mmi_context_h context,
+ int local_workflow_instance_id, const char *node_name, const char *port_name, bundle *data, void *user_data) {
+ CommunicationChannelTIDL *channel = static_cast<CommunicationChannelTIDL*>(user_data);
+
+ std::string sender;
+ if (!get_sender_string(context, channel, sender))
+ return MMI_ERROR_INVALID_PARAMETER;
+
+ size_t byte_size;
+
+ size_t *value_size = nullptr;
+ bundle_get_byte(data, "size", (void **)&value_size, &byte_size);
+
+ unsigned char *value_bytes = nullptr;
+ bundle_get_byte(data, "data", (void **)&value_bytes, &byte_size);
+
+ mmi_data_h restored_data;
+ mmi_data_from_bytes(value_bytes, *value_size, &restored_data);
+
+ ClientMessageWorkflowInstanceFeedData msg;
+ msg.sender = sender;
+ msg.local_workflow_instance_id = local_workflow_instance_id;
+ if (node_name) msg.node_name = node_name;
+ if (port_name) msg.port_name = port_name;
+ msg.data = restored_data;
+
+ notify_message_received(channel, static_cast<Message*>(&msg));
+
+ mmi_data_destroy(restored_data);
+
+ return MMI_ERROR_NONE;
+}
+
int CommunicationChannelTIDL::workflow_instance_activate(rpc_port_stub_mmi_context_h context,
int local_workflow_instance_id, void *user_data) {
CommunicationChannelTIDL *channel = static_cast<CommunicationChannelTIDL*>(user_data);
static void on_terminate(rpc_port_stub_mmi_context_h context, void *user_data);
static int workflow_instance_create(rpc_port_stub_mmi_context_h context,
- int local_workflow_instance_id, int workflow_type, void *user_data);
+ int local_workflow_instance_id, int workflow_type, bool script_from_file, const char *script_info, void *user_data);
static int workflow_instance_destroy(rpc_port_stub_mmi_context_h context,
int local_workflow_instance_id, void *user_data);
static int workflow_instance_set_attribute(rpc_port_stub_mmi_context_h context,
int workflow_instance, bundle *attribute, void *user_data);
static int workflow_instance_emit_signal(rpc_port_stub_mmi_context_h context,
int workflow_instance, bundle *signal, void *user_data);
+ static int workflow_instance_feed_data(rpc_port_stub_mmi_context_h context,
+ int workflow_instance, const char *node_name, const char *port_name, bundle *signal, void *user_data);
static int workflow_instance_activate(rpc_port_stub_mmi_context_h context,
int local_workflow_instance_id, void *user_data);
static int workflow_instance_deactivate(rpc_port_stub_mmi_context_h context,
}
std::shared_ptr<NodeInstance> NodeInstanceManager::create_node_instance(
- mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type) {
+ mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type) {
std::shared_ptr<NodeInstance> ret;
ret = std::make_shared<NodeInstance>(node_type, node_sub_type);
virtual ~INodeInstanceManager() = default;
virtual std::shared_ptr<NodeInstance> create_node_instance(
- mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type) = 0;
+ mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type) = 0;
virtual bool destroy_node_instance(
std::shared_ptr<NodeInstance> node_instance) = 0;
virtual bool link_node_instances(
virtual ~NodeInstanceManager();
virtual std::shared_ptr<NodeInstance> create_node_instance(
- mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type) override;
+ mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type) override;
virtual bool destroy_node_instance(
std::shared_ptr<NodeInstance> node_instance) override;
virtual bool link_node_instances(
namespace mmi {
NodeInstance::NodeInstance(
- mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type)
+ mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type)
: m_node_type(node_type)
, m_node_sub_type(node_sub_type) {
_D("Node instance is created : %s %s",
static bool node_type_and_subtype_matches(
mmi_node_h node,
- mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type) {
- mmi_standard_node_type_e type;
+ mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type) {
+ mmi_node_type_e type;
mmi_node_get_type(node, &type);
if (type != node_type) {
}
try {
- if (node_type == MMI_STANDARD_NODE_TYPE_SOURCE) {
- mmi_standard_node_source_type_e source_type;
- mmi_standard_node_get_source_type(node, &source_type);
- return source_type == std::get<mmi_standard_node_source_type_e>(node_sub_type);
- } else if (node_type == MMI_STANDARD_NODE_TYPE_PROCESSOR) {
- mmi_standard_node_processor_type_e processor_type;
- mmi_standard_node_get_processor_type(node, &processor_type);
- return processor_type == std::get<mmi_standard_node_processor_type_e>(node_sub_type);
- } else if (node_type == MMI_STANDARD_NODE_TYPE_LOGIC) {
- mmi_standard_node_logic_type_e logic_type;
- mmi_standard_node_get_logic_type(node, &logic_type);
- return logic_type == std::get<mmi_standard_node_logic_type_e>(node_sub_type);
- } else if (node_type == MMI_STANDARD_NODE_TYPE_CONTROLLER) {
- mmi_standard_node_controller_type_e controller_type;
- mmi_standard_node_get_controller_type(node, &controller_type);
- return controller_type == std::get<mmi_standard_node_controller_type_e>(node_sub_type);
- } else if (node_type == MMI_STANDARD_NODE_TYPE_ACTION) {
- mmi_standard_node_action_type_e action_type;
- mmi_standard_node_get_action_type(node, &action_type);
- return action_type == std::get<mmi_standard_node_action_type_e>(node_sub_type);
+ if (node_type == MMI_NODE_TYPE_SOURCE) {
+ mmi_node_source_type_e source_type;
+ mmi_node_get_source_type(node, &source_type);
+ return source_type == std::get<mmi_node_source_type_e>(node_sub_type);
+ } else if (node_type == MMI_NODE_TYPE_PROCESSOR) {
+ mmi_node_processor_type_e processor_type;
+ mmi_node_get_processor_type(node, &processor_type);
+ return processor_type == std::get<mmi_node_processor_type_e>(node_sub_type);
+ } else if (node_type == MMI_NODE_TYPE_LOGIC) {
+ mmi_node_logic_type_e logic_type;
+ mmi_node_get_logic_type(node, &logic_type);
+ return logic_type == std::get<mmi_node_logic_type_e>(node_sub_type);
+ } else if (node_type == MMI_NODE_TYPE_CONTROLLER) {
+ mmi_node_controller_type_e controller_type;
+ mmi_node_get_controller_type(node, &controller_type);
+ return controller_type == std::get<mmi_node_controller_type_e>(node_sub_type);
+ } else if (node_type == MMI_NODE_TYPE_ACTION) {
+ mmi_node_action_type_e action_type;
+ mmi_node_get_action_type(node, &action_type);
+ return action_type == std::get<mmi_node_action_type_e>(node_sub_type);
+ } else if (node_type == MMI_NODE_TYPE_CUSTOM) {
+ const char *custom_type_id = nullptr;
+ mmi_node_get_custom_type(node, &custom_type_id);
+ if (custom_type_id == nullptr) return false;
+ return (std::get<std::string>(node_sub_type).compare(std::string(custom_type_id)) == 0);
}
} catch (const std::bad_variant_access &e) {
_E("Failed to get node sub type : %s", e.what());
size_t port_count = 0;
mmi_plugin_module_node_list_s node_list_s = m_plugin_module_proxy->load_node_prototypes();
- for (int i = 0; i < node_list_s.node_count; i++) {
+ for (size_t i = 0; i < node_list_s.node_count; i++) {
mmi_node_h node = node_list_s.nodes[i];
if (node_type_and_subtype_matches(node, m_node_type, m_node_sub_type)) {
mmi_node_get_callbacks(node, &m_callbacks);
mmi_node_get_port_count(node, &port_count);
- for (size_t i = 0; i < port_count; i++) {
+ for (size_t j = 0; j < port_count; j++) {
mmi_port_h port;
- mmi_node_get_port(node, i, &port);
+ mmi_node_get_port(node, j, &port);
ports.push_back(port);
}
break;
}
}
-mmi_standard_node_type_e NodeInstance::get_node_type() {
+mmi_node_type_e NodeInstance::get_node_type() {
return m_node_type;
}
-mmi_standard_node_sub_type_e NodeInstance::get_node_sub_type() {
+mmi_node_sub_type_e NodeInstance::get_node_sub_type() {
return m_node_sub_type;
}
m_callbacks.signal_received_cb(static_cast<mmi_node_instance_h>(this), signal);
return true;
}
+
+bool NodeInstance::feed_data(std::string port_name, mmi_data_h data)
+{
+ try {
+ std::shared_ptr<PortInstance> target_port_instance =
+ m_port_instances.at(port_name);
+ if (target_port_instance) {
+ target_port_instance->on_output_data_received(data);
+ } else {
+ _E("Could not find target port instance : %s", port_name.c_str());
+ }
+ } catch (std::out_of_range& e) {
+ _E("Failed to find port instance : %s", port_name.c_str());
+ }
+
+ return true;
+}
+
} // namespace mmi
class NodeInstance {
public:
- NodeInstance(mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type);
+ NodeInstance(mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type);
virtual ~NodeInstance();
bool initialize();
void add_data_gateway(std::string port_name,
std::shared_ptr<DataGateway> gateway);
- mmi_standard_node_type_e get_node_type();
- mmi_standard_node_sub_type_e get_node_sub_type();
+ mmi_node_type_e get_node_type();
+ mmi_node_sub_type_e get_node_sub_type();
bool activate();
bool deactivate();
virtual bool set_attribute(mmi_attribute_h attribute);
virtual bool handle_signal(mmi_signal_h signal);
+ virtual bool feed_data(std::string port_name, mmi_data_h data);
protected:
std::shared_ptr<INodePrototypeStore> m_prototype_store;
std::shared_ptr<IPluginModuleProxyProvider> m_plugin_module_proxy_provider;
std::shared_ptr<IPluginModuleProxy> m_plugin_module_proxy;
std::map<std::string, std::shared_ptr<PortInstance>> m_port_instances;
- mmi_standard_node_type_e m_node_type;
- mmi_standard_node_sub_type_e m_node_sub_type;
+ mmi_node_type_e m_node_type;
+ mmi_node_sub_type_e m_node_sub_type;
mmi_node_callbacks m_callbacks{nullptr,};
namespace mmi {
+std::shared_ptr<NodePrototype> NodePrototypeHelper::create_node_prototype(mmi_node_h node) {
+ if (!node) {
+ _E("Invalid argument");
+ return nullptr;
+ }
+
+ auto prototype = std::make_shared<NodePrototype>();
+
+ if (prototype) {
+ mmi_node_type_e type;
+ mmi_node_get_type(node, &type);
+
+ prototype->set_type(type);
+ switch (type) {
+ case MMI_NODE_TYPE_NONE: {
+ _E("Node type is NONE");
+ return nullptr;
+ break;
+ }
+ case MMI_NODE_TYPE_SOURCE: {
+ mmi_node_source_type_e source_type;
+ mmi_node_get_source_type(node, &source_type);
+ prototype->set_sub_type(source_type);
+ break;
+ }
+ case MMI_NODE_TYPE_PROCESSOR: {
+ mmi_node_processor_type_e processor_type;
+ mmi_node_get_processor_type(node, &processor_type);
+ prototype->set_sub_type(processor_type);
+ break;
+ }
+ case MMI_NODE_TYPE_LOGIC: {
+ mmi_node_logic_type_e logic_type;
+ mmi_node_get_logic_type(node, &logic_type);
+ prototype->set_sub_type(logic_type);
+ break;
+ }
+ case MMI_NODE_TYPE_CONTROLLER: {
+ mmi_node_controller_type_e controller_type;
+ mmi_node_get_controller_type(node, &controller_type);
+ prototype->set_sub_type(controller_type);
+ break;
+ }
+ case MMI_NODE_TYPE_ACTION: {
+ mmi_node_action_type_e action_type;
+ mmi_node_get_action_type(node, &action_type);
+ prototype->set_sub_type(action_type);
+ break;
+ }
+ case MMI_NODE_TYPE_CUSTOM: {
+ const char *custom_type_id = nullptr;
+ mmi_node_get_custom_type(node, &custom_type_id);
+ if (custom_type_id) {
+ prototype->set_sub_type(std::string(custom_type_id));
+ }
+ break;
+ }
+ }
+
+ size_t port_count;
+ mmi_node_get_port_count(node, &port_count);
+ for (size_t i = 0; i < port_count; i++) {
+ mmi_port_h port;
+ mmi_node_get_port(node, i, &port);
+
+ char *name = nullptr;
+ size_t name_length = 0;
+ mmi_port_get_name(port, &name, &name_length);
+
+ mmi_port_type_e type;
+ mmi_port_get_type(port, &type);
+
+ mmi_data_type_e data_type;
+ mmi_port_get_data_type(port, &data_type);
+
+ PortInfo port_info;
+ port_info.name = name;
+ port_info.port_type = type;
+ port_info.data_type = data_type;
+ prototype->add_port_info(port_info);
+ }
+ } else {
+ _E("Failed to create node prototype");
+ }
+
+ return prototype;
+}
+
NodePrototypeManager::NodePrototypeManager() {
}
}
std::shared_ptr<NodePrototype> NodePrototypeManager::get_node_prototype(
- mmi_standard_node_type_e type, mmi_standard_node_sub_type_e sub_type) {
+ mmi_node_type_e type, mmi_node_sub_type_e sub_type) {
std::shared_ptr<NodePrototype> ret;
for (auto& elem : m_prototypes) {
namespace mmi {
struct INodePrototypeStore {
+ INodePrototypeStore() {}
+ virtual ~INodePrototypeStore() {}
virtual bool add_node_prototype(std::shared_ptr<NodePrototype> prototype) = 0;
virtual std::shared_ptr<NodePrototype> get_node_prototype(
- mmi_standard_node_type_e type, mmi_standard_node_sub_type_e sub_type) = 0;
+ mmi_node_type_e type, mmi_node_sub_type_e sub_type) = 0;
+};
+
+struct NodePrototypeHelper {
+ static std::shared_ptr<NodePrototype> create_node_prototype(mmi_node_h node);
};
class NodePrototypeManager : public INodePrototypeStore {
virtual bool add_node_prototype(std::shared_ptr<NodePrototype> prototype) override;
virtual std::shared_ptr<NodePrototype> get_node_prototype(
- mmi_standard_node_type_e type, mmi_standard_node_sub_type_e sub_type) override;
+ mmi_node_type_e type, mmi_node_sub_type_e sub_type) override;
void initialize();
void deinitialize();
/* Make sure that the m_sub_type is a valid match for m_type */
try {
switch (m_type.value()) {
- case mmi_standard_node_type_e::MMI_STANDARD_NODE_TYPE_SOURCE: {
- auto subclass =
- std::get<mmi_standard_node_source_type_e>(m_sub_type.value());
- valid = true;
+ case mmi_node_type_e::MMI_NODE_TYPE_NONE: {
+ _E("Node Type is NONE");
+ return false;
+ }
+ break;
+ case mmi_node_type_e::MMI_NODE_TYPE_SOURCE: {
+ valid = std::holds_alternative<mmi_node_source_type_e>(m_sub_type.value());
+ }
+ break;
+ case mmi_node_type_e::MMI_NODE_TYPE_PROCESSOR: {
+ valid = std::holds_alternative<mmi_node_processor_type_e>(m_sub_type.value());
}
break;
- case mmi_standard_node_type_e::MMI_STANDARD_NODE_TYPE_PROCESSOR: {
- auto subclass =
- std::get<mmi_standard_node_processor_type_e>(m_sub_type.value());
- valid = true;
+ case mmi_node_type_e::MMI_NODE_TYPE_LOGIC: {
+ valid = std::holds_alternative<mmi_node_logic_type_e>(m_sub_type.value());
}
break;
- case mmi_standard_node_type_e::MMI_STANDARD_NODE_TYPE_LOGIC: {
- auto subclass =
- std::get<mmi_standard_node_logic_type_e>(m_sub_type.value());
- valid = true;
+ case mmi_node_type_e::MMI_NODE_TYPE_CONTROLLER: {
+ valid = std::holds_alternative<mmi_node_controller_type_e>(m_sub_type.value());
}
break;
- case mmi_standard_node_type_e::MMI_STANDARD_NODE_TYPE_CONTROLLER: {
- auto subclass =
- std::get<mmi_standard_node_controller_type_e>(m_sub_type.value());
- valid = true;
+ case mmi_node_type_e::MMI_NODE_TYPE_ACTION: {
+ valid = std::holds_alternative<mmi_node_action_type_e>(m_sub_type.value());
}
break;
- case mmi_standard_node_type_e::MMI_STANDARD_NODE_TYPE_ACTION: {
- auto subclass =
- std::get<mmi_standard_node_action_type_e>(m_sub_type.value());
- valid = true;
+ case mmi_node_type_e::MMI_NODE_TYPE_CUSTOM: {
+ valid = std::holds_alternative<std::string>(m_sub_type.value());
}
break;
}
- } catch (const std::bad_variant_access& e) {
- _E("[std::bad_variant_access] Failed to create node prototype: %s", e.what());
} catch (const std::bad_optional_access& e) {
_E("[std::bad_optional_access] Failed to create node prototype: %s", e.what());
}
return valid;
}
-void NodePrototype::set_type(mmi_standard_node_type_e type) {
+void NodePrototype::set_type(mmi_node_type_e type) {
m_type = type;
}
-void NodePrototype::set_sub_type(mmi_standard_node_sub_type_e sub_type) {
+void NodePrototype::set_sub_type(mmi_node_sub_type_e sub_type) {
m_sub_type = sub_type;
}
return true;
}
-mmi_standard_node_type_e NodePrototype::get_type() {
- mmi_standard_node_type_e ret = MMI_STANDARD_NODE_TYPE_NONE;
+mmi_node_type_e NodePrototype::get_type() {
+ mmi_node_type_e ret = MMI_NODE_TYPE_NONE;
try {
ret = m_type.value();
} catch (const std::bad_optional_access &e) {
return ret;
}
-mmi_standard_node_sub_type_e NodePrototype::get_sub_type() {
- mmi_standard_node_sub_type_e ret = std::monostate{};
+mmi_node_sub_type_e NodePrototype::get_sub_type() {
+ mmi_node_sub_type_e ret = std::monostate{};
try {
ret = m_sub_type.value();
} catch (const std::bad_optional_access &e) {
#include "mmi-node-logic.h"
#include "mmi-node-controller.h"
#include "mmi-node-action.h"
+#include "mmi-node-custom.h"
#include "mmi-plugin-module-proxy.h"
#include "mmi-manager-log.h"
typedef std::variant<
std::monostate,
- mmi_standard_node_source_type_e,
- mmi_standard_node_processor_type_e,
- mmi_standard_node_logic_type_e,
- mmi_standard_node_controller_type_e,
- mmi_standard_node_action_type_e
- > mmi_standard_node_sub_type_e;
-
-static std::string to_string(mmi_standard_node_sub_type_e sub_type) {
+ mmi_node_source_type_e,
+ mmi_node_processor_type_e,
+ mmi_node_logic_type_e,
+ mmi_node_controller_type_e,
+ mmi_node_action_type_e,
+ std::string /* custom type id */
+ > mmi_node_sub_type_e;
+
+[[maybe_unused]] static std::string to_string(mmi_node_sub_type_e sub_type) {
try {
return std::visit([](auto&& arg) -> std::string {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, std::monostate>)
return std::string("Unknown");
+ else if constexpr (std::is_same_v<T, std::string>)
+ return arg;
else
return enum_to_string(arg);
}, sub_type);
return m_plugin_module_info;
}
- void set_type(mmi_standard_node_type_e type);
- void set_sub_type(mmi_standard_node_sub_type_e sub_type);
+ void set_type(mmi_node_type_e type);
+ void set_sub_type(mmi_node_sub_type_e sub_type);
bool add_port_info(PortInfo &port_info);
bool add_attribute_info(AttributeInfo &attribute_info);
- mmi_standard_node_type_e get_type();
- mmi_standard_node_sub_type_e get_sub_type();
+ mmi_node_type_e get_type();
+ mmi_node_sub_type_e get_sub_type();
std::vector<PortInfo> get_port_infos();
std::vector<AttributeInfo> get_attribute_infos();
private:
PluginModuleInfo m_plugin_module_info;
- std::optional<mmi_standard_node_type_e> m_type;
- std::optional<mmi_standard_node_sub_type_e> m_sub_type;
+ std::optional<mmi_node_type_e> m_type;
+ std::optional<mmi_node_sub_type_e> m_sub_type;
std::vector<PortInfo> m_port_infos;
std::vector<AttributeInfo> m_attribute_infos;
_D("node_list.count: %zu", node_list.node_count);
for (size_t i = 0;i < node_list.node_count;i++) {
mmi_node_h node = node_list.nodes[i];
- mmi_standard_node_type_e type;
+ mmi_node_type_e type;
mmi_node_get_type(node, &type);
mmi_node_callbacks callbacks;
mmi_node_get_callbacks(node, &callbacks);
_D("workflow_info[%zu].node_info_count: %zu", i, workflow_info->node_info_count);
for (size_t j = 0;j < workflow_info->node_info_count;j++) {
mmi_workflow_node_info_s *node_info = &(workflow_info->node_infos[j]);
- mmi_standard_node_type_e type;
+ mmi_node_type_e type;
mmi_node_get_type(workflow_info->node_infos[j].node, &type);
_D("workflow_info[%zu].node_info[%zu].name: %s", i, j, node_info->name);
_D("workflow_info[%zu].node_info[%zu].type: %d", i, j, type);
};
struct IPluginModuleProxyProvider {
+ IPluginModuleProxyProvider() {}
+ virtual ~IPluginModuleProxyProvider() {}
virtual std::shared_ptr<IPluginModuleProxy> get_plugin_module_proxy(
const PluginModuleInfo plugin_module_info) = 0;
};
m_workflow_prototype_store = workflow_prototype_store;
}
-/* FIXME : Check if this function needs to be moved to INodePrototypeStore */
-static std::shared_ptr<NodePrototype> create_node_prototype(mmi_node_h node) {
- if (!node) {
- _E("Invalid argument");
- return nullptr;
- }
-
- auto prototype = std::make_shared<NodePrototype>();
-
- if (prototype) {
- mmi_standard_node_type_e type;
- mmi_node_get_type(node, &type);
-
- prototype->set_type(type);
- switch (type) {
- case MMI_STANDARD_NODE_TYPE_SOURCE: {
- mmi_standard_node_source_type_e source_type;
- mmi_standard_node_get_source_type(node, &source_type);
- prototype->set_sub_type(source_type);
- break;
- }
- case MMI_STANDARD_NODE_TYPE_PROCESSOR: {
- mmi_standard_node_processor_type_e processor_type;
- mmi_standard_node_get_processor_type(node, &processor_type);
- prototype->set_sub_type(processor_type);
- break;
- }
- case MMI_STANDARD_NODE_TYPE_LOGIC: {
- mmi_standard_node_logic_type_e logic_type;
- mmi_standard_node_get_logic_type(node, &logic_type);
- prototype->set_sub_type(logic_type);
- break;
- }
- case MMI_STANDARD_NODE_TYPE_CONTROLLER: {
- mmi_standard_node_controller_type_e controller_type;
- mmi_standard_node_get_controller_type(node, &controller_type);
- prototype->set_sub_type(controller_type);
- break;
- }
- case MMI_STANDARD_NODE_TYPE_ACTION: {
- mmi_standard_node_action_type_e action_type;
- mmi_standard_node_get_action_type(node, &action_type);
- prototype->set_sub_type(action_type);
- break;
- }
- }
-
- size_t port_count;
- mmi_node_get_port_count(node, &port_count);
- for (size_t i = 0; i < port_count; i++) {
- mmi_port_h port;
- mmi_node_get_port(node, i, &port);
-
- char *name = nullptr;
- size_t name_length = 0;
- mmi_port_get_name(port, &name, &name_length);
-
- mmi_port_type_e type;
- mmi_port_get_type(port, &type);
-
- mmi_data_type_e data_type;
- mmi_port_get_data_type(port, &data_type);
-
- PortInfo port_info;
- port_info.name = name;
- port_info.port_type = type;
- port_info.data_type = data_type;
- prototype->add_port_info(port_info);
- }
- } else {
- _E("Failed to create node prototype");
- }
-
- return prototype;
-}
-
bool PluginModuleRegistry::load_node_prototypes() {
if (!m_node_prototype_store) {
_E("Node prototype store is not set");
if (ptr) {
mmi_plugin_module_node_list_s node_list = ptr->load_node_prototypes();
for (size_t i = 0; i < node_list.node_count; i++) {
- auto prototype = create_node_prototype(node_list.nodes[i]);
+ auto prototype = NodePrototypeHelper::create_node_prototype(node_list.nodes[i]);
if (prototype) {
prototype->set_plugin_module_info(plugin_module_info);
bool ret = m_node_prototype_store->add_node_prototype(prototype);
return true;
}
-/* FIXME : Check if this function needs to be moved to IWorkflowPrototypeStore */
-static std::shared_ptr<WorkflowPrototype> create_workflow_prototype(mmi_workflow_h workflow) {
- if (!workflow) {
- _E("Invalid argument");
- return nullptr;
- }
-
- auto prototype = std::make_shared<WorkflowPrototype>();
-
- if (prototype) {
- mmi_standard_workflow_type_e type;
- mmi_workflow_get_type(workflow, &type);
-
- prototype->set_type(type);
-
- mmi_workflow_s *workflow_info = static_cast<mmi_workflow_s*>(workflow);
- for (size_t i = 0; i < workflow_info->node_info_count; i++) {
- NodeInfo node_info;
- node_info.name = workflow_info->node_infos[i].name;
- mmi_node_get_type(workflow_info->node_infos[i].node, &node_info.node_type);
- switch (node_info.node_type) {
- case MMI_STANDARD_NODE_TYPE_SOURCE: {
- mmi_standard_node_source_type_e source_type;
- mmi_standard_node_get_source_type(workflow_info->node_infos[i].node, &source_type);
- node_info.node_sub_type = source_type;
- }
- break;
- case MMI_STANDARD_NODE_TYPE_PROCESSOR: {
- mmi_standard_node_processor_type_e processor_type;
- mmi_standard_node_get_processor_type(workflow_info->node_infos[i].node, &processor_type);
- node_info.node_sub_type = processor_type;
- }
- break;
- case MMI_STANDARD_NODE_TYPE_LOGIC: {
- mmi_standard_node_logic_type_e logic_type;
- mmi_standard_node_get_logic_type(workflow_info->node_infos[i].node, &logic_type);
- node_info.node_sub_type = logic_type;
- }
- break;
- case MMI_STANDARD_NODE_TYPE_CONTROLLER: {
- mmi_standard_node_controller_type_e controller_type;
- mmi_standard_node_get_controller_type(workflow_info->node_infos[i].node, &controller_type);
- node_info.node_sub_type = controller_type;
- }
- break;
- case MMI_STANDARD_NODE_TYPE_ACTION: {
- mmi_standard_node_action_type_e action_type;
- mmi_standard_node_get_action_type(workflow_info->node_infos[i].node, &action_type);
- node_info.node_sub_type = action_type;
- }
- break;
- default: {
- _E("Invalid node type");
- return nullptr;
- }
- }
-
- prototype->add_node_info(node_info);
- }
-
- for (size_t i = 0; i < workflow_info->link_info_count; i++) {
- LinkInfo link_info;
- link_info.from_node_name = workflow_info->link_infos[i].from_node_name;
- link_info.from_port_name = workflow_info->link_infos[i].from_port_name;
- link_info.to_node_name = workflow_info->link_infos[i].to_node_name;
- link_info.to_port_name = workflow_info->link_infos[i].to_port_name;
-
- prototype->add_link_info(link_info);
- }
-
- for (size_t i = 0; i < workflow_info->attribute_assignment_info_count; i++) {
- AttributeAssignmentInfo attribute_assignment_info;
- attribute_assignment_info.attribute_name = workflow_info->attribute_assignment_infos[i].attribute_name;
- attribute_assignment_info.target_node_name = workflow_info->attribute_assignment_infos[i].target_node_name;
- attribute_assignment_info.target_attribute_name = workflow_info->attribute_assignment_infos[i].target_attribute_name;
-
- prototype->add_attribute_assignment_info(attribute_assignment_info);
- }
-
- for (size_t i = 0; i < workflow_info->attribute_default_value_info_count; i++) {
- AttributeDefaultValueInfo attribute_default_value_info;
- mmi_attribute_h default_value = nullptr;
- int ret = mmi_attribute_from_bytes(
- workflow_info->attribute_default_value_infos[i].serialized_default_value,
- workflow_info->attribute_default_value_infos[i].serialized_default_value_size,
- &default_value);
- if (MMI_ERROR_NONE != ret) {
- _E("Failed to create attribute from bytes");
- }
- attribute_default_value_info.default_value = default_value;
-
- prototype->add_attribute_default_value_info(attribute_default_value_info);
-
- mmi_attribute_destroy(default_value);
- }
-
- for (size_t i = 0; i < workflow_info->signal_assignment_info_count; i++) {
- SignalAssignmentInfo signal_assignment_info;
- signal_assignment_info.signal_name = workflow_info->signal_assignment_infos[i].signal_name;
- signal_assignment_info.target_node_name = workflow_info->signal_assignment_infos[i].target_node_name;
- signal_assignment_info.target_signal_name = workflow_info->signal_assignment_infos[i].target_signal_name;
-
- prototype->add_signal_assignment_info(signal_assignment_info);
- }
-
- for (size_t i = 0; i < workflow_info->output_assignment_info_count; i++) {
- OutputAssignmentInfo output_assignment_info;
- output_assignment_info.output_name = workflow_info->output_assignment_infos[i].output_name;
- output_assignment_info.from_node_name = workflow_info->output_assignment_infos[i].from_node_name;
- output_assignment_info.from_port_name = workflow_info->output_assignment_infos[i].from_port_name;
-
- prototype->add_output_assignment_info(output_assignment_info);
- }
- } else {
- _E("Failed to create workflow prototype");
- }
-
- return prototype;
-}
-
bool PluginModuleRegistry::load_workflow_prototypes() {
if (!m_workflow_prototype_store) {
_E("Workflow prototype store is not set");
if (ptr) {
mmi_plugin_module_workflow_list_s workflow_list = ptr->load_workflow_prototypes();
for (size_t i = 0; i < workflow_list.workflow_count; i++) {
- auto prototype = create_workflow_prototype(workflow_list.workflows[i]);
+ auto prototype = WorkflowPrototypeHelper::create_workflow_prototype(workflow_list.workflows[i]);
if (prototype) {
prototype->set_plugin_module_info(plugin_module_info);
m_workflow_prototype_store->add_workflow_prototype(prototype);
}
}
- auto plugin_module = reinterpret_cast<TestNodePluginModuleMIC*>(instance);
-
int value = 100;
mmi_data_h output_data = reinterpret_cast<mmi_data_h>(&value);
mmi_port_set_callbacks(mic_audio_port, m_node_mic.m_audio_port_callbacks);
mmi_node_h mic_node = nullptr;
- mmi_standard_node_create_source(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT, &mic_node);
+ mmi_node_create_source(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT, &mic_node);
mmi_node_add_port(mic_node, mic_audio_port);
mmi_node_set_callbacks(mic_node, m_node_mic.m_node_callbacks);
mmi_node_register(mic_node);
mmi_port_set_callbacks(asr_final_result_port, m_node_asr.m_audio_port_callbacks);
mmi_node_h asr_node = nullptr;
- mmi_standard_node_create_processor(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR, &asr_node);
+ mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_ASR, &asr_node);
mmi_node_add_port(asr_node, asr_audio_port);
mmi_node_add_port(asr_node, asr_partial_result_port);
mmi_node_add_port(asr_node, asr_final_result_port);
mmi_port_set_callbacks(match_candidate_port, m_node_match.m_text_port_callbacks);
mmi_node_h match_node = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &match_node);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &match_node);
mmi_node_add_port(match_node, match_text_port);
mmi_node_add_port(match_node, match_candidate_port);
mmi_node_set_callbacks(match_node, m_node_match.m_node_callbacks);
mmi_workflow_set_type(workflow, MMI_STANDARD_WORKFLOW_WAKEUPLESS_COMMAND);
mmi_node_h node_mic = nullptr;
- mmi_standard_node_create_source(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
+ mmi_node_create_source(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
mmi_workflow_node_add(workflow, "MIC", node_mic);
mmi_node_h node_asr = nullptr;
- mmi_standard_node_create_processor(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR, &node_asr);
+ mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_ASR, &node_asr);
mmi_workflow_node_add(workflow, "ASR", node_asr);
mmi_node_h node_match = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match);
mmi_workflow_node_add(workflow, "MATCH", node_match);
mmi_workflow_link_nodes_by_names(workflow, "MIC", "AUDIO", "ASR", "AUDIO");
#include "mmi-workflow-instance-manager.h"
+#include <fstream>
+#include <sstream>
+
#include "mmi-manager-log.h"
namespace mmi {
handle_emit_signal(msg);
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_FEED_DATA: {
+ auto *msg = static_cast<ClientMessageWorkflowInstanceFeedData*>(message);
+ handle_feed_data(msg);
+ }
+ break;
case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_ACTIVATE: {
auto *msg = static_cast<ClientMessageWorkflowInstanceActivate*>(message);
handle_activate(msg);
handle_deactivate(msg);
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_OUTPUT: {
+ LOGE("Error : Manager to Client message is received");
+ }
+ break;
}
}
instance->set_local_workflow_instance_id(message->local_workflow_instance_id);
instance->set_type(message->workflow_type);
- instance->set_workflow_prototype_store(m_prototype_store);
+ if (message->workflow_type == MMI_STANDARD_WORKFLOW_NONE) {
+ mmi_workflow_h workflow = nullptr;
+ if (message->script_from_file) {
+ mmi_workflow_create_from_script_file(message->script_info.c_str(), &workflow);
+ } else {
+ mmi_workflow_create_from_script(message->script_info.c_str(), &workflow);
+ }
+
+ std::shared_ptr<IWorkflowPrototypeStore> prototype_store =
+ std::make_shared<WorkflowPrototypeScriptStore>();
+
+ auto prototype = WorkflowPrototypeHelper::create_workflow_prototype(workflow);
+ prototype_store->add_workflow_prototype(prototype);
+ instance->set_workflow_prototype_store(prototype_store);
+ mmi_workflow_destroy(workflow);
+ } else {
+ instance->set_workflow_prototype_store(m_prototype_store);
+ }
+
instance->set_plugin_module_proxy_provider(m_plugin_module_proxy_provider);
instance->set_node_instance_manager(m_node_instance_manager);
instance->deinitialize();
}
+ auto custom_prototype_it = m_custom_prototype_store.find(instance);
+ if (custom_prototype_it!= m_custom_prototype_store.end()) {
+ m_custom_prototype_store.erase(custom_prototype_it);
+ }
+
auto it = m_workflow_instances.begin();
while (it != m_workflow_instances.end()) {
if ((*it)->get_client_id() == message->sender &&
}
}
+void WorkflowInstanceManager::handle_feed_data(
+ ClientMessageWorkflowInstanceFeedData *message) {
+ if (nullptr == message) {
+ LOGE("Message is null");
+ return;
+ }
+
+ std::shared_ptr<WorkflowInstance> instance =
+ get_workflow_instance(message->sender, message->local_workflow_instance_id);
+ if (instance) {
+ instance->feed_data(message->node_name, message->port_name, message->data);
+ }
+}
+
void WorkflowInstanceManager::handle_activate(
ClientMessageWorkflowInstanceActivate *message) {
if (nullptr == message) {
using namespace communication;
+class WorkflowPrototypeScriptStore : public IWorkflowPrototypeStore {
+public:
+ WorkflowPrototypeScriptStore() {}
+ virtual ~WorkflowPrototypeScriptStore() {}
+ bool add_workflow_prototype(std::shared_ptr<WorkflowPrototype> prototype) override {
+ m_workflow_prototype = prototype;
+ return true;
+ }
+ std::shared_ptr<WorkflowPrototype> get_workflow_prototype(mmi_standard_workflow_type_e type) override {
+ return m_workflow_prototype;
+ }
+ std::shared_ptr<WorkflowPrototype> m_workflow_prototype;
+};
+
class WorkflowInstanceManager :
public SimpleEventObserver<COMMUNICATION_CHANNEL_EVENT_TYPE>,
public SimpleEventObservable<WORKFLOW_EVENT_TYPE> {
void handle_destroy(ClientMessageWorkflowInstanceDestroy *message);
void handle_set_attribute(ClientMessageWorkflowInstanceSetAttribute *message);
void handle_emit_signal(ClientMessageWorkflowInstanceEmitSignal *message);
+ void handle_feed_data(ClientMessageWorkflowInstanceFeedData *message);
void handle_activate(ClientMessageWorkflowInstanceActivate *message);
void handle_deactivate(ClientMessageWorkflowInstanceDeactivate *message);
protected:
std::shared_ptr<INodeInstanceManager> m_node_instance_manager;
std::vector<std::shared_ptr<WorkflowInstance>> m_workflow_instances;
+ std::map<std::shared_ptr<WorkflowInstance>, std::shared_ptr<IWorkflowPrototypeStore>>
+ m_custom_prototype_store;
};
} // namespace mmi
return true;
}
+bool WorkflowInstance::feed_data(std::string node_name, std::string port_name, mmi_data_h data) {
+ _D("Feeding Data : %s %s %p", node_name.c_str(), port_name.c_str(), data);
+
+ try {
+ std::shared_ptr<NodeInstance> target_node_instance =
+ m_node_instances.at(node_name);
+ if (target_node_instance) {
+ target_node_instance->feed_data(port_name, data);
+ } else {
+ _E("Could not find target node instance : %s", node_name.c_str());
+ }
+ } catch (std::out_of_range& e) {
+ _E("Failed to find node instance : %s", node_name.c_str());
+ }
+
+ return true;
+}
+
// LCOV_EXCL_START
void WorkflowInstance::on_observer_event(
const PLUGIN_MODULE_EVENT_TYPE &event, std::any data) {
bool set_attribute_default_values();
bool handle_signal(mmi_signal_h signal);
+ bool feed_data(std::string node_name, std::string port_name, mmi_data_h data);
void on_observer_event(
const PLUGIN_MODULE_EVENT_TYPE &event, std::any data) override;
namespace mmi {
+std::shared_ptr<WorkflowPrototype> WorkflowPrototypeHelper::create_workflow_prototype(mmi_workflow_h workflow) {
+ if (!workflow) {
+ _E("Invalid argument");
+ return nullptr;
+ }
+
+ auto prototype = std::make_shared<WorkflowPrototype>();
+
+ if (prototype) {
+ mmi_standard_workflow_type_e type;
+ mmi_workflow_get_type(workflow, &type);
+
+ prototype->set_type(type);
+
+ mmi_workflow_s *workflow_info = static_cast<mmi_workflow_s*>(workflow);
+ for (size_t i = 0; i < workflow_info->node_info_count; i++) {
+ NodeInfo node_info;
+ node_info.name = workflow_info->node_infos[i].name;
+ mmi_node_get_type(workflow_info->node_infos[i].node, &node_info.node_type);
+ switch (node_info.node_type) {
+ case MMI_NODE_TYPE_SOURCE: {
+ mmi_node_source_type_e source_type;
+ mmi_node_get_source_type(workflow_info->node_infos[i].node, &source_type);
+ node_info.node_sub_type = source_type;
+ }
+ break;
+ case MMI_NODE_TYPE_PROCESSOR: {
+ mmi_node_processor_type_e processor_type;
+ mmi_node_get_processor_type(workflow_info->node_infos[i].node, &processor_type);
+ node_info.node_sub_type = processor_type;
+ }
+ break;
+ case MMI_NODE_TYPE_LOGIC: {
+ mmi_node_logic_type_e logic_type;
+ mmi_node_get_logic_type(workflow_info->node_infos[i].node, &logic_type);
+ node_info.node_sub_type = logic_type;
+ }
+ break;
+ case MMI_NODE_TYPE_CONTROLLER: {
+ mmi_node_controller_type_e controller_type;
+ mmi_node_get_controller_type(workflow_info->node_infos[i].node, &controller_type);
+ node_info.node_sub_type = controller_type;
+ }
+ break;
+ case MMI_NODE_TYPE_ACTION: {
+ mmi_node_action_type_e action_type;
+ mmi_node_get_action_type(workflow_info->node_infos[i].node, &action_type);
+ node_info.node_sub_type = action_type;
+ }
+ break;
+ case MMI_NODE_TYPE_CUSTOM: {
+ const char *custom_type_id = nullptr;
+ mmi_node_get_custom_type(workflow_info->node_infos[i].node, &custom_type_id);
+ if (custom_type_id) {
+ node_info.node_sub_type = std::string(custom_type_id);
+ }
+ }
+ break;
+ default: {
+ _E("Invalid node type");
+ return nullptr;
+ }
+ }
+
+ prototype->add_node_info(node_info);
+ }
+
+ for (size_t i = 0; i < workflow_info->link_info_count; i++) {
+ LinkInfo link_info;
+ link_info.from_node_name = workflow_info->link_infos[i].from_node_name;
+ link_info.from_port_name = workflow_info->link_infos[i].from_port_name;
+ link_info.to_node_name = workflow_info->link_infos[i].to_node_name;
+ link_info.to_port_name = workflow_info->link_infos[i].to_port_name;
+
+ prototype->add_link_info(link_info);
+ }
+
+ for (size_t i = 0; i < workflow_info->attribute_assignment_info_count; i++) {
+ AttributeAssignmentInfo attribute_assignment_info;
+ attribute_assignment_info.attribute_name = workflow_info->attribute_assignment_infos[i].attribute_name;
+ attribute_assignment_info.target_node_name = workflow_info->attribute_assignment_infos[i].target_node_name;
+ attribute_assignment_info.target_attribute_name = workflow_info->attribute_assignment_infos[i].target_attribute_name;
+
+ prototype->add_attribute_assignment_info(attribute_assignment_info);
+ }
+
+ for (size_t i = 0; i < workflow_info->attribute_default_value_info_count; i++) {
+ AttributeDefaultValueInfo attribute_default_value_info;
+ mmi_attribute_h default_value = nullptr;
+ int ret = mmi_attribute_from_bytes(
+ workflow_info->attribute_default_value_infos[i].serialized_default_value,
+ workflow_info->attribute_default_value_infos[i].serialized_default_value_size,
+ &default_value);
+ if (MMI_ERROR_NONE != ret) {
+ _E("Failed to create attribute from bytes");
+ }
+ attribute_default_value_info.default_value = default_value;
+
+ prototype->add_attribute_default_value_info(attribute_default_value_info);
+
+ mmi_attribute_destroy(default_value);
+ }
+
+ for (size_t i = 0; i < workflow_info->signal_assignment_info_count; i++) {
+ SignalAssignmentInfo signal_assignment_info;
+ signal_assignment_info.signal_name = workflow_info->signal_assignment_infos[i].signal_name;
+ signal_assignment_info.target_node_name = workflow_info->signal_assignment_infos[i].target_node_name;
+ signal_assignment_info.target_signal_name = workflow_info->signal_assignment_infos[i].target_signal_name;
+
+ prototype->add_signal_assignment_info(signal_assignment_info);
+ }
+
+ for (size_t i = 0; i < workflow_info->output_assignment_info_count; i++) {
+ OutputAssignmentInfo output_assignment_info;
+ output_assignment_info.output_name = workflow_info->output_assignment_infos[i].output_name;
+ output_assignment_info.from_node_name = workflow_info->output_assignment_infos[i].from_node_name;
+ output_assignment_info.from_port_name = workflow_info->output_assignment_infos[i].from_port_name;
+
+ prototype->add_output_assignment_info(output_assignment_info);
+ }
+ } else {
+ _E("Failed to create workflow prototype");
+ }
+
+ return prototype;
+}
WorkflowPrototypeManager::WorkflowPrototypeManager() {
}
namespace mmi {
struct IWorkflowPrototypeStore {
+ IWorkflowPrototypeStore() {}
+ virtual ~IWorkflowPrototypeStore() {}
virtual bool add_workflow_prototype(std::shared_ptr<WorkflowPrototype> prototype) = 0;
virtual std::shared_ptr<WorkflowPrototype> get_workflow_prototype(mmi_standard_workflow_type_e type) = 0;
};
+struct WorkflowPrototypeHelper {
+ static std::shared_ptr<WorkflowPrototype> create_workflow_prototype(mmi_workflow_h workflow);
+};
+
class WorkflowPrototypeManager : public IWorkflowPrototypeStore {
public:
WorkflowPrototypeManager();
typedef struct {
std::string name;
- mmi_standard_node_type_e node_type;
- mmi_standard_node_sub_type_e node_sub_type;
+ mmi_node_type_e node_type;
+ mmi_node_sub_type_e node_sub_type;
} NodeInfo;
typedef struct {
'mmi-node-logic.cpp',
'mmi-node-controller.cpp',
'mmi-node-action.cpp',
+ 'mmi-node-custom.cpp',
'mmi-port.cpp',
'mmi-signal.cpp',
'mmi-plugin-storage.cpp',
return MMI_ERROR_INVALID_PARAMETER;
}
+
*name = strdup(attribute->name);
if (nullptr == *name) {
_E("[ERROR] Fail to allocate memory for name string");
using namespace mmi::communication;
struct ICommunicationChannelFactory {
+ ICommunicationChannelFactory() {}
+ virtual ~ICommunicationChannelFactory() {}
virtual CommunicationChannel* create_channel() = 0;
virtual void destroy_channel(CommunicationChannel* channel) = 0;
};
return;
}
auto client_message = static_cast<ClientMessage*>(message);
- switch (client_message->message_type) {
- case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_OUTPUT: {
+ if (client_message->message_type ==
+ CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_OUTPUT) {
handle_output(static_cast<ClientMessageWorkflowInstanceOutput*>(message));
- }
- break;
}
} catch (const std::bad_any_cast &e) {
LOGE("Failed to cast message data: %s", e.what());
size_t datalen = 0;
memcpy(&datalen, current, sizeof(size_t));
current += sizeof(size_t);
- void *buf = nullptr;
auto value = reinterpret_cast<mmi_data_h>(malloc(sizeof(mmi_data_s)));
value->type = type;
value->datalen = 0;
if (m_server) {
return MMI_ERROR_OPERATION_FAILED;
}
- m_server = ecore_ipc_server_connect(ECORE_IPC_REMOTE_SYSTEM, "localhost", 9999, this);
+ char addr[] = {"localhost"};
+ m_server = ecore_ipc_server_connect(ECORE_IPC_REMOTE_SYSTEM, addr, 9999, this);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, handler_server_add, this);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, handler_server_del, this);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, handler_server_data, this);
struct workflow_instance_create_payload {
int local_workflow_instance_id;
mmi_standard_workflow_type_e workflow_type;
+ bool script_from_file;
+ size_t script_info_size;
} payload;
payload.local_workflow_instance_id = subclass->local_workflow_instance_id;
payload.workflow_type = subclass->workflow_type;
- size_t byte_size = sizeof(CLIENT_MESSAGE_TYPE) + sizeof(workflow_instance_create_payload);
+ payload.script_from_file = subclass->script_from_file;
+ payload.script_info_size = subclass->script_info.size();
+ size_t byte_size = sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload);
+ byte_size += payload.script_info_size;
unsigned char *bytes = (unsigned char*)(malloc(byte_size));
+ size_t index = 0;
if (bytes) {
memcpy(bytes, &type, sizeof(CLIENT_MESSAGE_TYPE));
- memcpy(bytes + sizeof(CLIENT_MESSAGE_TYPE), &payload, sizeof(payload));
+ index += sizeof(CLIENT_MESSAGE_TYPE);
+ memcpy(bytes + index, &payload, sizeof(payload));
+ index += sizeof(payload);
+ memcpy(bytes + index, subclass->script_info.c_str(), payload.script_info_size);
ecore_ipc_server_send(m_server, 0, 0, 0, 0, 0, bytes, byte_size);
free(bytes);
}
free(signal_name);
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_FEED_DATA:
+ {
+ auto subclass = static_cast<ClientMessageWorkflowInstanceFeedData *>(message);
+
+ struct workflow_instance_feed_data_payload {
+ int local_workflow_instance_id;
+ char node_name[MMI_NAME_MAX_LENGTH];
+ char port_name[MMI_NAME_MAX_LENGTH];
+ } payload;
+
+ payload.local_workflow_instance_id = subclass->local_workflow_instance_id;
+ strncpy(payload.node_name, subclass->node_name.c_str(), MMI_NAME_MAX_LENGTH - 1);
+ payload.node_name[MMI_NAME_MAX_LENGTH - 1] = '\0';
+ strncpy(payload.port_name, subclass->port_name.c_str(), MMI_NAME_MAX_LENGTH - 1);
+ payload.port_name[MMI_NAME_MAX_LENGTH - 1] = '\0';
+
+ unsigned char *data_bytes = nullptr;
+ size_t data_size = 0;
+ mmi_data_to_bytes(subclass->data, &data_bytes, &data_size);
+
+ int index = 0;
+ size_t byte_size = sizeof(CLIENT_MESSAGE_TYPE) + sizeof(payload) + sizeof(size_t) + data_size;
+ unsigned char *bytes = (unsigned char*)(malloc(byte_size));
+ if (!bytes) return MMI_ERROR_OPERATION_FAILED;
+
+ memcpy(bytes, &type, sizeof(CLIENT_MESSAGE_TYPE));
+ index = sizeof(CLIENT_MESSAGE_TYPE);
+ memcpy(bytes + index, &payload, sizeof(payload));
+ index += sizeof(payload);
+
+ memcpy(bytes + index, &data_size, sizeof(size_t));
+ index += (sizeof(size_t));
+ memcpy(bytes + index, data_bytes, data_size);
+ index += (data_size);
+
+ free(data_bytes);
+
+ if (bytes) {
+ ecore_ipc_server_send(m_server, 0, 0, 0, 0, 0, bytes, byte_size);
+ free(bytes);
+ }
+ }
+ break;
case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_ACTIVATE:
{
auto subclass = static_cast<ClientMessageWorkflowInstanceActivate *>(message);
}
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_OUTPUT:
+ {
+ _E("Error : Manager to Client message is requested");
+ }
+ break;
};
return 0;
}
ClientMessageWorkflowInstanceOutput message;
size_t index = 0;
- memcpy(&(message.local_workflow_instance_id), e->data + index, sizeof(int));
+ memcpy(&(message.local_workflow_instance_id),
+ (unsigned char*)(e->data) + index, sizeof(int));
index += sizeof(int);
size_t source_name_length = 0;
- memcpy(&(source_name_length), e->data + index, sizeof(size_t));
+ memcpy(&(source_name_length),
+ (unsigned char*)(e->data) + index, sizeof(size_t));
index += sizeof(size_t);
char *bytes = (char*)(malloc(source_name_length + 1));
- memcpy(bytes, e->data + index, source_name_length);
+ memcpy(bytes,
+ (unsigned char*)(e->data) + index, source_name_length);
bytes[source_name_length] = '\0';
message.source_name = (char*)bytes;
free(bytes);
size_t data_size = 0;
- memcpy(&(data_size), e->data + index, sizeof(size_t));
+ memcpy(&(data_size),
+ (unsigned char*)(e->data) + index, sizeof(size_t));
index += sizeof(size_t);
-
+
mmi_data_h output_data = nullptr;
if (MMI_ERROR_NONE !=
- mmi_data_from_bytes((unsigned char*)(e->data + index), data_size, &(output_data))) {
+ mmi_data_from_bytes((unsigned char*)(e->data) + index, data_size, &(output_data))) {
LOGE("[ERROR] Failed to restore data from bytes");
return EINA_TRUE;
}
switch(type) {
case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_CREATE: {
auto subclass = static_cast<ClientMessageWorkflowInstanceCreate*>(message);
- workflow_instance_create(subclass->local_workflow_instance_id, subclass->workflow_type, subclass->user_data);
+ workflow_instance_create(subclass->local_workflow_instance_id, subclass->workflow_type,
+ subclass->script_from_file, subclass->script_info, subclass->user_data);
}
break;
case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_DESTROY: {
workflow_instance_emit_signal(subclass->local_workflow_instance_id, subclass->signal);
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_FEED_DATA: {
+ auto subclass = static_cast<ClientMessageWorkflowInstanceFeedData*>(message);
+ workflow_instance_feed_data(
+ subclass->local_workflow_instance_id, subclass->node_name, subclass->port_name, subclass->data);
+ }
+ break;
case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_ACTIVATE: {
auto subclass = static_cast<ClientMessageWorkflowInstanceActivate*>(message);
workflow_instance_activate(subclass->local_workflow_instance_id);
workflow_instance_deactivate(subclass->local_workflow_instance_id);
}
break;
+ case CLIENT_MESSAGE_TYPE::WORKFLOW_INSTANCE_OUTPUT: {
+ LOGE("Error : Manager to Client message requested");
+ }
+ break;
};
return MMI_ERROR_NONE;
return MMI_ERROR_NONE;
}
-int CommunicationChannelTIDL::workflow_instance_create(int local_workflow_instance_id, mmi_standard_workflow_type_e workflow_type, void *user_data) {
+int CommunicationChannelTIDL::workflow_instance_create(int local_workflow_instance_id,
+ mmi_standard_workflow_type_e workflow_type, bool script_from_file, std::string script_info, void *user_data) {
LOGI("Creating workflow instance of type (%d) for id (%d)",
workflow_type, local_workflow_instance_id);
}
int ret = rpc_port_proxy_mmi_invoke_workflow_instance_create(
- rpc_h, local_workflow_instance_id, workflow_type);
+ rpc_h, local_workflow_instance_id, workflow_type, script_from_file, script_info.c_str());
if (RPC_PORT_ERROR_NONE != ret) {
LOGE("Failed to create workflow instance(%d)\n", ret);
return MMI_ERROR_OPERATION_FAILED;
std::string data_string = std::string("parameter_data_") + std::to_string(loop);
bundle_add_byte(encoded, data_string.c_str(), value_bytes, value_size);
+ free(value_bytes);
mmi_primitive_value_destroy(value);
mmi_signal_parameter_destroy(parameter);
}
return ret;
}
+int CommunicationChannelTIDL::workflow_instance_feed_data(
+ int local_workflow_instance_id, std::string node_name, std::string port_name, mmi_data_h data) {
+ LOGI("Feeding data for workflow instance (%d), %s %s", local_workflow_instance_id, node_name.c_str(), port_name.c_str());
+ int ret = MMI_ERROR_NONE;
+
+ if (NULL == data) {
+ LOGE("Parameter is NULL or empty");
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+
+ rpc_port_proxy_mmi_h rpc_h = static_cast<rpc_port_proxy_mmi_h>(m_rpc_h);
+ if (NULL == rpc_h) {
+ LOGE("Fail to get tidl rpc info");
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+
+ if (false == is_connected()) {
+ LOGE("Try to connect again");
+ int ret = retry_connection(rpc_h);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ LOGE("Fail to retry connection(%d)", ret);
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ bundle *encoded = bundle_create();
+
+ unsigned char *data_bytes = nullptr;
+ size_t data_size = 0;
+
+ mmi_data_to_bytes(data, &data_bytes, &data_size);
+
+ bundle_add_byte(encoded, "size", &data_size, sizeof(size_t));
+ bundle_add_byte(encoded, "data", data_bytes, data_size);
+
+ if (encoded) {
+ int ret = rpc_port_proxy_mmi_invoke_workflow_instance_feed_data(rpc_h,
+ local_workflow_instance_id, node_name.c_str(), port_name.c_str(), encoded);
+ bundle_free(encoded);
+
+ if (RPC_PORT_ERROR_NONE != ret) {
+ LOGE("Failed to feed data to workflow (%d)\n", ret);
+ ret = MMI_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ free(data_bytes);
+ return ret;
+}
+
int CommunicationChannelTIDL::workflow_instance_activate(int local_workflow_instance_id) {
LOGI("Activating workflow instance of id (%d)", local_workflow_instance_id);
int send(communication::Message *message) override;
private:
- int workflow_instance_create(int local_workflow_instance_id, mmi_standard_workflow_type_e workflow_type, void *user_data);
+ int workflow_instance_create(int local_workflow_instance_id, mmi_standard_workflow_type_e workflow_type,
+ bool script_from_file, std::string script_info, void *user_data);
int workflow_instance_destroy(int local_workflow_instance_id);
int workflow_instance_set_attribute(int local_workflow_instance_id, mmi_attribute_h attribute);
int workflow_instance_emit_signal(int local_workflow_instance_id, mmi_signal_h signal);
+ int workflow_instance_feed_data(int local_workflow_instance_id, std::string node_name, std::string port_name, mmi_data_h data);
int workflow_instance_activate(int local_workflow_instance_id);
int workflow_instance_deactivate(int local_workflow_instance_id);
int workflow_instance_register_result_callback(int local_workflow_instance_id, void *user_data);
#include "mmi-log.h"
-int mmi_standard_node_create_action(mmi_standard_node_action_type_e type, mmi_node_h *node) {
+int mmi_node_create_action(mmi_node_action_type_e type, mmi_node_h *node) {
if (nullptr == node) {
return MMI_ERROR_INVALID_PARAMETER;
}
*node = new mmi_node_s;
- (*node)->type = MMI_STANDARD_NODE_TYPE_ACTION;
+ (*node)->type = MMI_NODE_TYPE_ACTION;
(*node)->sub_type = (int)type;
+ (*node)->custom_type_id[0] = '\0';
(*node)->ports = nullptr;
(*node)->port_count = 0;
memset(&(*node)->callbacks, 0, sizeof(mmi_node_callbacks));
return MMI_ERROR_NONE;
}
-int mmi_standard_node_get_action_type(mmi_node_h node, mmi_standard_node_action_type_e *type) {
+int mmi_node_get_action_type(mmi_node_h node, mmi_node_action_type_e *type) {
if (nullptr == node || nullptr == type) {
return MMI_ERROR_INVALID_PARAMETER;
}
- *type = (mmi_standard_node_action_type_e)node->sub_type;
- return MMI_ERROR_NONE;
-}
-
-int mmi_standard_node_register_action(mmi_standard_node_action_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node) {
- if (nullptr == callbacks || nullptr == node) {
- return MMI_ERROR_INVALID_PARAMETER;
- }
+ *type = (mmi_node_action_type_e)node->sub_type;
return MMI_ERROR_NONE;
}
#include "mmi-log.h"
-int mmi_standard_node_create_controller(mmi_standard_node_controller_type_e type, mmi_node_h *node) {
+int mmi_node_create_controller(mmi_node_controller_type_e type, mmi_node_h *node) {
if (nullptr == node) {
return MMI_ERROR_INVALID_PARAMETER;
}
*node = new mmi_node_s;
- (*node)->type = MMI_STANDARD_NODE_TYPE_CONTROLLER;
+ (*node)->type = MMI_NODE_TYPE_CONTROLLER;
(*node)->sub_type = (int)type;
+ (*node)->custom_type_id[0] = '\0';
(*node)->ports = nullptr;
(*node)->port_count = 0;
memset(&(*node)->callbacks, 0, sizeof(mmi_node_callbacks));
return MMI_ERROR_NONE;
}
-int mmi_standard_node_get_controller_type(mmi_node_h node, mmi_standard_node_controller_type_e *type) {
+int mmi_node_get_controller_type(mmi_node_h node, mmi_node_controller_type_e *type) {
if (nullptr == node || nullptr == type) {
return MMI_ERROR_INVALID_PARAMETER;
}
- *type = (mmi_standard_node_controller_type_e)node->sub_type;
- return MMI_ERROR_NONE;
-}
-
-int mmi_standard_node_register_controller(mmi_standard_node_controller_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node) {
- if (nullptr == callbacks || nullptr == node) {
- return MMI_ERROR_INVALID_PARAMETER;
- }
+ *type = (mmi_node_controller_type_e)node->sub_type;
return MMI_ERROR_NONE;
}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#include "mmi.h"
+#include "mmi-node-custom.h"
+
+#include "mmi-log.h"
+
+
+
+int mmi_node_create_custom(const char *custom_type_id, mmi_node_h *node) {
+ if (nullptr == node) {
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+ *node = new mmi_node_s;
+ (*node)->type = MMI_NODE_TYPE_CUSTOM;
+ (*node)->sub_type = 0;
+ strncpy((*node)->custom_type_id, custom_type_id, MMI_NAME_MAX_LENGTH);
+ (*node)->custom_type_id[MMI_NAME_MAX_LENGTH - 1] = '\0';
+ (*node)->ports = nullptr;
+ (*node)->port_count = 0;
+ memset(&(*node)->callbacks, 0, sizeof(mmi_node_callbacks));
+ return MMI_ERROR_NONE;
+}
+
+int mmi_node_get_custom_type(mmi_node_h node, const char **custom_type_id) {
+ if (nullptr == node || nullptr == custom_type_id) {
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+ *custom_type_id = node->custom_type_id;
+ return MMI_ERROR_NONE;
+}
+
#include "mmi-log.h"
-int mmi_standard_node_create_logic(mmi_standard_node_logic_type_e type, mmi_node_h *node) {
+int mmi_node_create_logic(mmi_node_logic_type_e type, mmi_node_h *node) {
if (nullptr == node) {
return MMI_ERROR_INVALID_PARAMETER;
}
*node = new mmi_node_s;
- (*node)->type = MMI_STANDARD_NODE_TYPE_LOGIC;
+ (*node)->type = MMI_NODE_TYPE_LOGIC;
(*node)->sub_type = (int)type;
+ (*node)->custom_type_id[0] = '\0';
(*node)->ports = nullptr;
(*node)->port_count = 0;
memset(&(*node)->callbacks, 0, sizeof(mmi_node_callbacks));
return MMI_ERROR_NONE;
}
-int mmi_standard_node_get_logic_type(mmi_node_h node, mmi_standard_node_logic_type_e *type) {
+int mmi_node_get_logic_type(mmi_node_h node, mmi_node_logic_type_e *type) {
if (nullptr == node) {
return MMI_ERROR_INVALID_PARAMETER;
}
- *type = (mmi_standard_node_logic_type_e)node->sub_type;
+ *type = (mmi_node_logic_type_e)node->sub_type;
return MMI_ERROR_NONE;
}
-// LCOV_EXCL_START
-int mmi_standard_node_register_logic(mmi_standard_node_logic_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node) {
- if (nullptr == callbacks || nullptr == node) {
- return MMI_ERROR_INVALID_PARAMETER;
- }
- return MMI_ERROR_NONE;
-}
-// LCOV_EXCL_STOP
-
#include "mmi-log.h"
-int mmi_standard_node_create_processor(mmi_standard_node_processor_type_e type, mmi_node_h *node) {
+int mmi_node_create_processor(mmi_node_processor_type_e type, mmi_node_h *node) {
if (nullptr == node) {
return MMI_ERROR_INVALID_PARAMETER;
}
*node = new mmi_node_s;
- (*node)->type = MMI_STANDARD_NODE_TYPE_PROCESSOR;
+ (*node)->type = MMI_NODE_TYPE_PROCESSOR;
(*node)->sub_type = (int)type;
+ (*node)->custom_type_id[0] = '\0';
(*node)->ports = nullptr;
(*node)->port_count = 0;
memset(&(*node)->callbacks, 0, sizeof(mmi_node_callbacks));
return MMI_ERROR_NONE;
}
-int mmi_standard_node_get_processor_type(mmi_node_h node, mmi_standard_node_processor_type_e *type) {
+int mmi_node_get_processor_type(mmi_node_h node, mmi_node_processor_type_e *type) {
if (nullptr == node || nullptr == type) {
return MMI_ERROR_INVALID_PARAMETER;
}
- *type = (mmi_standard_node_processor_type_e)node->sub_type;
+ *type = (mmi_node_processor_type_e)node->sub_type;
return MMI_ERROR_NONE;
}
-// LCOV_EXCL_START
-int mmi_standard_node_register_processor(mmi_standard_node_processor_type_e type, mmi_node_callbacks *callbacks, mmi_node_h node) {
- if (nullptr == callbacks || nullptr == node) {
- return MMI_ERROR_INVALID_PARAMETER;
- }
- return MMI_ERROR_NONE;
-}
-// LCOV_EXCL_STOP
-
#include "mmi-log.h"
-int mmi_standard_node_create_source(mmi_standard_node_source_type_e type, mmi_node_h *node) {
+int mmi_node_create_source(mmi_node_source_type_e type, mmi_node_h *node) {
if (nullptr == node) {
return MMI_ERROR_INVALID_PARAMETER;
}
*node = new mmi_node_s;
- (*node)->type = MMI_STANDARD_NODE_TYPE_SOURCE;
+ (*node)->type = MMI_NODE_TYPE_SOURCE;
(*node)->sub_type = (int)type;
+ (*node)->custom_type_id[0] = '\0';
(*node)->ports = nullptr;
(*node)->port_count = 0;
memset(&(*node)->callbacks, 0, sizeof(mmi_node_callbacks));
return MMI_ERROR_NONE;
}
-int mmi_standard_node_get_source_type(mmi_node_h node, mmi_standard_node_source_type_e *type) {
+int mmi_node_get_source_type(mmi_node_h node, mmi_node_source_type_e *type) {
if (nullptr == type || nullptr == node) {
return MMI_ERROR_INVALID_PARAMETER;
}
- *type = (mmi_standard_node_source_type_e)node->sub_type;
+ *type = (mmi_node_source_type_e)node->sub_type;
return MMI_ERROR_NONE;
}
}
// LCOV_EXCL_STOP
-int mmi_node_get_type(mmi_node_h node, mmi_standard_node_type_e *type) {
+int mmi_node_get_type(mmi_node_h node, mmi_node_type_e *type) {
if (nullptr == node || nullptr == type) {
LOGE("[ERROR] parameter is null");
return MMI_ERROR_INVALID_PARAMETER;
}
- *type = (mmi_standard_node_type_e)node->type;
+ *type = (mmi_node_type_e)node->type;
return MMI_ERROR_NONE;
}
return MMI_ERROR_INVALID_PARAMETER;
}
- mmi_standard_node_type_e node_type;
+ mmi_node_type_e node_type;
mmi_node_get_type(node, &node_type);
const char *identifier = mmi_plugin_storage_get_current_module_identifier();
bool duplicated = false;
for (size_t i = 0; i < node_count; i++) {
- mmi_standard_node_type_e type;
+ mmi_node_type_e type;
mmi_node_get_type(nodes[i], &type);
if (type == node_type) {
switch (type) {
- case MMI_STANDARD_NODE_TYPE_SOURCE: {
- mmi_standard_node_source_type_e node_source_type;
- mmi_standard_node_get_source_type(node, &node_source_type);
- mmi_standard_node_source_type_e source_type;
- mmi_standard_node_get_source_type(nodes[i], &source_type);
+ case MMI_NODE_TYPE_NONE: {
+ LOGE("[ERROR] Node Type is NONE");
+ break;
+ }
+ case MMI_NODE_TYPE_SOURCE: {
+ mmi_node_source_type_e node_source_type;
+ mmi_node_get_source_type(node, &node_source_type);
+ mmi_node_source_type_e source_type;
+ mmi_node_get_source_type(nodes[i], &source_type);
if (node_source_type == source_type) {
duplicated = true;
}
break;
}
- case MMI_STANDARD_NODE_TYPE_PROCESSOR: {
- mmi_standard_node_processor_type_e node_processor_type;
- mmi_standard_node_get_processor_type(node, &node_processor_type);
- mmi_standard_node_processor_type_e processor_type;
- mmi_standard_node_get_processor_type(nodes[i], &processor_type);
+ case MMI_NODE_TYPE_PROCESSOR: {
+ mmi_node_processor_type_e node_processor_type;
+ mmi_node_get_processor_type(node, &node_processor_type);
+ mmi_node_processor_type_e processor_type;
+ mmi_node_get_processor_type(nodes[i], &processor_type);
if (node_processor_type == processor_type) {
duplicated = true;
}
break;
}
- case MMI_STANDARD_NODE_TYPE_LOGIC: {
- mmi_standard_node_logic_type_e node_logic_type;
- mmi_standard_node_get_logic_type(node, &node_logic_type);
- mmi_standard_node_logic_type_e logic_type;
- mmi_standard_node_get_logic_type(nodes[i], &logic_type);
+ case MMI_NODE_TYPE_LOGIC: {
+ mmi_node_logic_type_e node_logic_type;
+ mmi_node_get_logic_type(node, &node_logic_type);
+ mmi_node_logic_type_e logic_type;
+ mmi_node_get_logic_type(nodes[i], &logic_type);
if (node_logic_type == logic_type) {
duplicated = true;
}
break;
}
// LCOV_EXCL_START
- case MMI_STANDARD_NODE_TYPE_CONTROLLER: {
- mmi_standard_node_controller_type_e node_controller_type;
- mmi_standard_node_get_controller_type(node, &node_controller_type);
- mmi_standard_node_controller_type_e controller_type;
- mmi_standard_node_get_controller_type(nodes[i], &controller_type);
+ case MMI_NODE_TYPE_CONTROLLER: {
+ mmi_node_controller_type_e node_controller_type;
+ mmi_node_get_controller_type(node, &node_controller_type);
+ mmi_node_controller_type_e controller_type;
+ mmi_node_get_controller_type(nodes[i], &controller_type);
if (node_controller_type == controller_type) {
duplicated = true;
}
break;
}
- case MMI_STANDARD_NODE_TYPE_ACTION: {
- mmi_standard_node_action_type_e node_action_type;
- mmi_standard_node_get_action_type(node, &node_action_type);
- mmi_standard_node_action_type_e action_type;
- mmi_standard_node_get_action_type(nodes[i], &action_type);
+ case MMI_NODE_TYPE_ACTION: {
+ mmi_node_action_type_e node_action_type;
+ mmi_node_get_action_type(node, &node_action_type);
+ mmi_node_action_type_e action_type;
+ mmi_node_get_action_type(nodes[i], &action_type);
if (node_action_type == action_type) {
duplicated = true;
}
break;
}
+ case MMI_NODE_TYPE_CUSTOM: {
+ const char *node_custom_type_id = nullptr;
+ mmi_node_get_custom_type(node, &node_custom_type_id);
+ const char *custom_type_id = nullptr;
+ mmi_node_get_custom_type(nodes[i], &custom_type_id);
+ if (strncmp(node_custom_type_id, custom_type_id, MMI_NAME_MAX_LENGTH) == 0) {
+ duplicated = true;
+ }
+ break;
+ }
// LCOV_EXCL_STOP
}
}
cloned_ptr->type = node_ptr->type;
cloned_ptr->sub_type = node_ptr->sub_type;
+ memcpy(cloned_ptr->custom_type_id, node_ptr->custom_type_id, MMI_NAME_MAX_LENGTH);
cloned_ptr->port_count = node_ptr->port_count;
cloned_ptr->callbacks = node_ptr->callbacks;
return MMI_ERROR_OUT_OF_MEMORY;
}
- for (int i = 0; i < node_ptr->port_count; i++) {
+ for (size_t i = 0; i < node_ptr->port_count; i++) {
mmi_port_clone(node_ptr->ports[i], &cloned_ptr->ports[i]);
}
return MMI_ERROR_INVALID_PARAMETER;
}
- for (int i = 0; i < node->port_count; i++) {
+ for (size_t i = 0; i < node->port_count; i++) {
mmi_port_destroy(node->ports[i]);
}
delete [] node->ports;
~PluginStorageImpl() {
for (auto &it : m_node_lists) {
- for (int loop = 0; loop < it.second.node_count; loop++) {
+ for (size_t loop = 0; loop < it.second.node_count; loop++) {
mmi_node_destroy(it.second.nodes[loop]);
}
delete [] it.second.nodes;
}
for (auto &it : m_workflow_lists) {
- for (int loop = 0; loop < it.second.workflow_count; loop++) {
+ for (size_t loop = 0; loop < it.second.workflow_count; loop++) {
mmi_workflow_destroy(it.second.workflows[loop]);
}
delete [] it.second.workflows;
mmi_port_instance_h find_port_instance(mmi_node_instance_h node_instance, const char *port_name) {
for (auto &info : m_node_instance_infos) {
if (info.node == node_instance) {
- for (int loop = 0; loop < info.port_info_count; loop++) {
+ for (size_t loop = 0; loop < info.port_info_count; loop++) {
if (strncmp(info.port_infos[loop].name, port_name, MMI_NAME_MAX_LENGTH) == 0) {
return info.port_infos[loop].port;
}
mmi_node_instance_h find_node_instance_by_port_instance(mmi_port_instance_h port_instance) {
for (auto &info : m_node_instance_infos) {
- for (int loop = 0; loop < info.port_info_count; loop++) {
+ for (size_t loop = 0; loop < info.port_info_count; loop++) {
if (info.port_infos[loop].port == port_instance) {
return info.node;
}
/* This datalen variable will not be used for array type */
memcpy(&datalen, current, sizeof(size_t));
current += sizeof(size_t);
- void *data = nullptr;
auto value = reinterpret_cast<mmi_primitive_value_s *>(malloc(sizeof(mmi_primitive_value_s)));
value->type = type;
value->datalen = 0;
class WorkflowInstance {
public:
- WorkflowInstance(int local_workflow_instance_id, mmi_standard_workflow_type_e workflow_type)
- : m_local_workflow_instance_id(local_workflow_instance_id), m_workflow_type(workflow_type) {
+ WorkflowInstance(int local_workflow_instance_id)
+ : m_local_workflow_instance_id(local_workflow_instance_id) {
}
virtual ~WorkflowInstance() {}
return m_local_workflow_instance_id;
}
- mmi_standard_workflow_type_e get_workflow_type() {
- return m_workflow_type;
- }
-
// LCOV_EXCL_START
bool add_output_callback(std::string key, mmi_workflow_output_cb callback, void *user_data) {
bool ret = false;
private:
int m_local_workflow_instance_id;
- mmi_standard_workflow_type_e m_workflow_type;
// TODO: make duplicate possible
std::map<std::string, std::pair<mmi_workflow_output_cb, void *>> callbacks;
};
return true;
}
- WorkflowInstance* create(mmi_standard_workflow_type_e type) {
- WorkflowInstance *newInstance = new(std::nothrow) WorkflowInstance(m_last_local_workflow_instance_id++, type);
+ WorkflowInstance* create() {
+ WorkflowInstance *newInstance = new(std::nothrow) WorkflowInstance(m_last_local_workflow_instance_id++);
m_instances.push_back(newInstance);
return newInstance;
}
return MMI_ERROR_OPERATION_FAILED;
}
- WorkflowInstance *workflow_instance = workflow_instance_manager->create(type);
+ WorkflowInstance *workflow_instance = workflow_instance_manager->create();
if (workflow_instance) {
*instance = static_cast<void*>(workflow_instance);
return MMI_ERROR_NONE;
}
+MMI_API int mmi_custom_workflow_instance_create_from_script(const char *workflow_script, mmi_workflow_instance_h *instance)
+{
+ if (nullptr == instance || nullptr == workflow_script) {
+ LOGE("[ERROR] parameter is null");
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+
+ WorkflowInstanceManager *workflow_instance_manager = g_mmi_client_manager.get_workflow_instance_manager();
+ if (nullptr == workflow_instance_manager) {
+ LOGE("[ERROR] Failed to get workflow instance manager");
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+
+ WorkflowInstance *workflow_instance = workflow_instance_manager->create();
+ if (workflow_instance) {
+ *instance = static_cast<void*>(workflow_instance);
+
+ std::shared_ptr<CommunicationChannelClient> channel = g_mmi_client_manager.get_communication_channel();
+ if (channel) {
+ ClientMessageWorkflowInstanceCreate msg;
+ msg.local_workflow_instance_id =
+ workflow_instance->get_local_workflow_instance_id();
+ msg.workflow_type = MMI_STANDARD_WORKFLOW_NONE;
+ msg.script_from_file = false;
+ msg.script_info = std::string{workflow_script};
+ msg.user_data = workflow_instance;
+
+ channel->send(&msg);
+ }
+ } else {
+ return MMI_ERROR_OUT_OF_MEMORY;
+ }
+
+ return MMI_ERROR_NONE;
+}
+
+MMI_API int mmi_custom_workflow_instance_create_from_script_file(const char *workflow_script_path, mmi_workflow_instance_h *instance)
+{
+ if (nullptr == instance || nullptr == workflow_script_path) {
+ LOGE("[ERROR] parameter is null");
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+
+ WorkflowInstanceManager *workflow_instance_manager = g_mmi_client_manager.get_workflow_instance_manager();
+ if (nullptr == workflow_instance_manager) {
+ LOGE("[ERROR] Failed to get workflow instance manager");
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+
+ WorkflowInstance *workflow_instance = workflow_instance_manager->create();
+ if (workflow_instance) {
+ *instance = static_cast<void*>(workflow_instance);
+
+ std::shared_ptr<CommunicationChannelClient> channel = g_mmi_client_manager.get_communication_channel();
+ if (channel) {
+ ClientMessageWorkflowInstanceCreate msg;
+ msg.local_workflow_instance_id =
+ workflow_instance->get_local_workflow_instance_id();
+ msg.workflow_type = MMI_STANDARD_WORKFLOW_NONE;
+ msg.script_from_file = true;
+ msg.script_info = std::string{workflow_script_path};
+ msg.user_data = workflow_instance;
+
+ channel->send(&msg);
+ }
+ } else {
+ return MMI_ERROR_OUT_OF_MEMORY;
+ }
+
+ return MMI_ERROR_NONE;
+}
+
// LCOV_EXCL_START
MMI_API int mmi_workflow_instance_destroy(mmi_workflow_instance_h instance) {
if (nullptr == instance) {
return MMI_ERROR_NONE;
}
+MMI_API int mmi_workflow_instance_feed_data(mmi_workflow_instance_h instance, const char *node_name, const char *port_name, mmi_data_h data) {
+ if (nullptr == instance || nullptr == node_name || nullptr == port_name) {
+ LOGE("[ERROR] parameter is null");
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+
+ std::shared_ptr<CommunicationChannelClient> channel = g_mmi_client_manager.get_communication_channel();
+ if (nullptr == channel) {
+ LOGE("[ERROR] Failed to get channel");
+ return MMI_ERROR_OPERATION_FAILED;
+ }
+
+ WorkflowInstance *workflow_instance = static_cast<WorkflowInstance*>(instance);
+
+ ClientMessageWorkflowInstanceFeedData msg;
+ msg.local_workflow_instance_id = workflow_instance->get_local_workflow_instance_id();
+ msg.node_name = node_name;
+ msg.port_name = port_name;
+ msg.data = data;
+
+ channel->send(&msg);
+
+ return MMI_ERROR_NONE;
+}
+
// LCOV_EXCL_START
MMI_API int mmi_workflow_instance_set_output_callback(mmi_workflow_instance_h instance, const char *name, mmi_workflow_output_cb callback, void *user_data) {
if (nullptr == instance) {
#include "mmi-node-logic.h"
#include "mmi-node-controller.h"
#include "mmi-node-action.h"
+#include "mmi-node-custom.h"
enum class WorkflowScriptSection {
NONE,
} StandardWorkflowName;
typedef struct {
- mmi_standard_node_source_type_e type;
+ mmi_node_source_type_e type;
std::string name;
} StandardNodeSourceName;
typedef struct {
- mmi_standard_node_processor_type_e type;
+ mmi_node_processor_type_e type;
std::string name;
} StandardNodeProcessorName;
typedef struct {
- mmi_standard_node_logic_type_e type;
+ mmi_node_logic_type_e type;
std::string name;
} StandardNodeLogicName;
typedef struct {
- mmi_standard_node_controller_type_e type;
+ mmi_node_controller_type_e type;
std::string name;
} StandardNodeControllerName;
+typedef struct {
+ mmi_node_action_type_e type;
+ std::string name;
+} StandardNodeActionName;
+
// trim from start (in place)
static inline void ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
m_section_names.push_back({WorkflowScriptSection::OUTPUT_LIST, "@output-list"});
m_section_patterns.push_back({WorkflowScriptSection::WORKFLOW_INFO, std::regex("^name : ([a-zA-Z_]+)$")});
- m_section_patterns.push_back({WorkflowScriptSection::NODE_LIST, std::regex("^\\[([a-zA-Z]+)\\] ([a-zA-Z_]+) as ([a-zA-Z0-9_]+)$")});
+ m_section_patterns.push_back({WorkflowScriptSection::NODE_LIST, std::regex("^\\[([a-zA-Z]+)\\] ([a-zA-Z_\\-.]+) as ([a-zA-Z0-9_]+)$")});
m_section_patterns.push_back({WorkflowScriptSection::LINK_LIST, std::regex("^([a-zA-Z0-9_.]+) -> ([a-zA-Z0-9_.]+)$")});
m_section_patterns.push_back({WorkflowScriptSection::ATTRIBUTE_LIST, std::regex("^([a-zA-Z0-9_.]+) as ([a-zA-Z0-9_]+)$")});
m_section_patterns.push_back({WorkflowScriptSection::OUTPUT_LIST, std::regex("^([a-zA-Z0-9_.]+) as ([a-zA-Z0-9_]+)$")});
m_standard_workflow_names.push_back({MMI_STANDARD_WORKFLOW_VOICE_TOUCH, "VOICE_TOUCH"});
m_standard_workflow_names.push_back({MMI_STANDARD_WORKFLOW_USER_RECOGNITION, "USER_RECOGNITION"});
- m_standard_node_source_names.push_back({MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT, "MIC_AMBIENT"});
- m_standard_node_source_names.push_back({MMI_STANDARD_NODE_SOURCE_TYPE_CAMERA, "CAMERA"});
+ m_node_source_names.push_back({MMI_NODE_SOURCE_TYPE_MIC_AMBIENT, "MIC_AMBIENT"});
+ m_node_source_names.push_back({MMI_NODE_SOURCE_TYPE_CAMERA, "CAMERA"});
- m_standard_node_processor_names.push_back({MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR, "ASR"});
- m_standard_node_processor_names.push_back({MMI_STANDARD_NODE_PROCESSOR_TYPE_VIDEO_CONVERTER, "VIDEO_CONVERTER"});
- m_standard_node_processor_names.push_back({MMI_STANDARD_NODE_PROCESSOR_TYPE_FACE_RECOGNITION, "FACE_RECOGNITION"});
- m_standard_node_processor_names.push_back({MMI_STANDARD_NODE_PROCESSOR_TYPE_SPEAKER_RECOGNITION, "SPEAKER_RECOGNITION"});
+ m_node_processor_names.push_back({MMI_NODE_PROCESSOR_TYPE_ASR, "ASR"});
+ m_node_processor_names.push_back({MMI_NODE_PROCESSOR_TYPE_VIDEO_CONVERTER, "VIDEO_CONVERTER"});
+ m_node_processor_names.push_back({MMI_NODE_PROCESSOR_TYPE_FACE_RECOGNITION, "FACE_RECOGNITION"});
+ m_node_processor_names.push_back({MMI_NODE_PROCESSOR_TYPE_SPEAKER_RECOGNITION, "SPEAKER_RECOGNITION"});
- m_standard_node_logic_names.push_back({MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, "FIXED_STRING_MATCH"});
- m_standard_node_logic_names.push_back({MMI_STANDARD_NODE_LOGIC_TYPE_USER_COMPARISON, "USER_COMPARISON"});
+ m_node_logic_names.push_back({MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, "FIXED_STRING_MATCH"});
+ m_node_logic_names.push_back({MMI_NODE_LOGIC_TYPE_USER_COMPARISON, "USER_COMPARISON"});
- m_standard_node_controller_names.push_back({MMI_STANDARD_NODE_CONTROLLER_TYPE_SWITCH, "SWITCH"});
+ m_node_controller_names.push_back({MMI_NODE_CONTROLLER_TYPE_SWITCH, "SWITCH"});
}
virtual ~WorkflowScriptParser() {
}
std::ssub_match sub_match_type = matches[1];
std::string type = sub_match_type.str();
- if (type.compare("Source") == 0) {
- std::ssub_match sub_match_name = matches[2];
- std::string name = sub_match_name.str();
+ std::ssub_match sub_match_name = matches[2];
+ std::string name = sub_match_name.str();
- std::ssub_match sub_match_alias = matches[3];
- std::string alias = sub_match_alias.str();
+ std::ssub_match sub_match_alias = matches[3];
+ std::string alias = sub_match_alias.str();
- for (auto &standard_node_source_name : m_standard_node_source_names) {
- if (name == standard_node_source_name.name) {
+ if (type.compare(m_node_source_identifier) == 0) {
+ for (auto &node_source_name : m_node_source_names) {
+ if (name == node_source_name.name) {
LOGD("standard node source name matched: %s", name.c_str());
- mmi_standard_node_source_type_e sub_type = standard_node_source_name.type;
+ mmi_node_source_type_e sub_type = node_source_name.type;
mmi_node_h node = nullptr;
- if (mmi_standard_node_create_source(sub_type, &node) != MMI_ERROR_NONE) {
+ if (mmi_node_create_source(sub_type, &node) != MMI_ERROR_NONE) {
LOGE("[ERROR] Failed to create standard node source");
return false;
}
break;
}
}
- } else if (type.compare("Processor") == 0) {
- std::ssub_match sub_match_name = matches[2];
- std::string name = sub_match_name.str();
-
- std::ssub_match sub_match_alias = matches[3];
- std::string alias = sub_match_alias.str();
-
- for (auto &standard_node_processor_name : m_standard_node_processor_names) {
- if (name == standard_node_processor_name.name) {
+ } else if (type.compare(m_node_processor_identifier) == 0) {
+ for (auto &node_processor_name : m_node_processor_names) {
+ if (name == node_processor_name.name) {
LOGD("standard node processor name matched: %s", name.c_str());
- mmi_standard_node_processor_type_e sub_type = standard_node_processor_name.type;
+ mmi_node_processor_type_e sub_type = node_processor_name.type;
mmi_node_h node = nullptr;
- if (mmi_standard_node_create_processor(sub_type, &node) != MMI_ERROR_NONE) {
+ if (mmi_node_create_processor(sub_type, &node) != MMI_ERROR_NONE) {
LOGE("[ERROR] Failed to create standard node processor");
return false;
}
break;
}
}
- } else if (type.compare("Logic") == 0) {
- std::ssub_match sub_match_name = matches[2];
- std::string name = sub_match_name.str();
-
- std::ssub_match sub_match_alias = matches[3];
- std::string alias = sub_match_alias.str();
-
- for (auto &standard_node_logic_name : m_standard_node_logic_names) {
- if (name == standard_node_logic_name.name) {
+ } else if (type.compare(m_node_logic_identifier) == 0) {
+ for (auto &node_logic_name : m_node_logic_names) {
+ if (name == node_logic_name.name) {
LOGD("standard node logic name matched: %s", name.c_str());
- mmi_standard_node_logic_type_e sub_type = standard_node_logic_name.type;
+ mmi_node_logic_type_e sub_type = node_logic_name.type;
mmi_node_h node = nullptr;
- if (mmi_standard_node_create_logic(sub_type, &node) != MMI_ERROR_NONE) {
+ if (mmi_node_create_logic(sub_type, &node) != MMI_ERROR_NONE) {
LOGE("[ERROR] Failed to create standard node logic");
return false;
}
break;
}
}
- } else if (type.compare("Controller") == 0) {
- std::ssub_match sub_match_name = matches[2];
- std::string name = sub_match_name.str();
-
- std::ssub_match sub_match_alias = matches[3];
- std::string alias = sub_match_alias.str();
-
- for (auto &standard_node_controller_name : m_standard_node_controller_names) {
- if (name == standard_node_controller_name.name) {
+ } else if (type.compare(m_node_controller_identifier) == 0) {
+ for (auto &node_controller_name : m_node_controller_names) {
+ if (name == node_controller_name.name) {
LOGD("standard node controller name matched: %s", name.c_str());
- mmi_standard_node_controller_type_e sub_type = standard_node_controller_name.type;
+ mmi_node_controller_type_e sub_type = node_controller_name.type;
mmi_node_h node = nullptr;
- if (mmi_standard_node_create_controller(sub_type, &node) != MMI_ERROR_NONE) {
+ if (mmi_node_create_controller(sub_type, &node) != MMI_ERROR_NONE) {
LOGE("[ERROR] Failed to create standard node controller");
return false;
}
break;
}
}
+ } else if (type.compare(m_node_action_identifier) == 0) {
+ for (auto &node_action_name : m_node_action_names) {
+ if (name == node_action_name.name) {
+ LOGD("standard node action name matched: %s", name.c_str());
+ mmi_node_action_type_e sub_type = node_action_name.type;
+ mmi_node_h node = nullptr;
+ if (mmi_node_create_action(sub_type, &node) != MMI_ERROR_NONE) {
+ LOGE("[ERROR] Failed to create standard node action");
+ return false;
+ }
+ LOGD("Adding action node %s as %s", name.c_str(), alias.c_str());
+ mmi_workflow_node_add(workflow, alias.c_str(), node);
+ mmi_node_destroy(node);
+ break;
+ }
+ }
+ } else if (type.compare(m_node_custom_identifier) == 0) {
+ mmi_node_h node = nullptr;
+ if (mmi_node_create_custom(name.c_str(), &node) != MMI_ERROR_NONE) {
+ LOGE("[ERROR] Failed to create standard node custom");
+ return false;
+ }
+ LOGD("Adding custom node %s as %s", name.c_str(), alias.c_str());
+ mmi_workflow_node_add(workflow, alias.c_str(), node);
+ mmi_node_destroy(node);
}
}
return true;
std::vector<StandardWorkflowName> m_standard_workflow_names;
- std::vector<StandardNodeSourceName> m_standard_node_source_names;
- std::vector<StandardNodeProcessorName> m_standard_node_processor_names;
- std::vector<StandardNodeLogicName> m_standard_node_logic_names;
- std::vector<StandardNodeControllerName> m_standard_node_controller_names;
+ std::string m_node_source_identifier{"Source"};
+ std::vector<StandardNodeSourceName> m_node_source_names;
+ std::string m_node_processor_identifier{"Processor"};
+ std::vector<StandardNodeProcessorName> m_node_processor_names;
+ std::string m_node_logic_identifier{"Logic"};
+ std::vector<StandardNodeLogicName> m_node_logic_names;
+ std::string m_node_controller_identifier{"Controller"};
+ std::vector<StandardNodeControllerName> m_node_controller_names;
+ std::string m_node_action_identifier{"Action"};
+ std::vector<StandardNodeActionName> m_node_action_names;
+ std::string m_node_custom_identifier{"Custom"};
};
#include "mmi-workflow-script-parser.h"
#include <fstream>
+#include <sstream>
-MMI_API int mmi_workflow_create_from_script(const char *script_path, mmi_workflow_h *workflow) {
+MMI_API int mmi_workflow_create_from_script(const char *script, mmi_workflow_h *workflow) {
+ if (script == nullptr || workflow == nullptr) {
+ LOGE("[ERROR] parameter is null");
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+
+ std::istringstream iss(script);
+ std::vector<std::string> lines;
+
+ std::string line;
+ while (getline(iss, line)) {
+ lines.push_back(line);
+ }
+
+ WorkflowScriptParser parser;
+ *workflow = nullptr;
+ bool result = parser.parse(lines, workflow);
+ if (!result || *workflow == nullptr) {
+ LOGE("[ERROR] Failed to create workflow from data");
+ return MMI_ERROR_INVALID_PARAMETER;
+ }
+
+ return MMI_ERROR_NONE;
+}
+
+
+MMI_API int mmi_workflow_create_from_script_file(const char *script_path, mmi_workflow_h *workflow) {
if (script_path == nullptr || workflow == nullptr) {
LOGE("[ERROR] parameter is null");
return MMI_ERROR_INVALID_PARAMETER;
}
std::ifstream script_file(script_path);
+ std::vector<std::string> lines;
if (!script_file.is_open()) {
LOGE("[ERROR] Failed to open script file");
return MMI_ERROR_INVALID_PARAMETER;
}
std::string line;
- std::vector<std::string> lines;
while (std::getline(script_file, line)) {
lines.push_back(line);
}
cloned_s->node_infos = new(std::nothrow) mmi_workflow_node_info_s[workflow_s->node_info_count];
memcpy(cloned_s->node_infos, workflow_s->node_infos, sizeof(mmi_workflow_node_info_s) * workflow_s->node_info_count);
- for (int i = 0; i < workflow_s->node_info_count; i++) {
+ for (size_t i = 0; i < workflow_s->node_info_count; i++) {
mmi_node_clone(workflow_s->node_infos[i].node, &(cloned_s->node_infos[i].node));
}
if (workflow_s->attribute_default_value_info_count > 0) {
cloned_s->attribute_default_value_infos = new(std::nothrow) mmi_workflow_attribute_default_value_info_s[workflow_s->attribute_default_value_info_count];
- for (int i = 0; i < workflow_s->attribute_default_value_info_count; i++) {
+ for (size_t i = 0; i < workflow_s->attribute_default_value_info_count; i++) {
cloned_s->attribute_default_value_infos[i].serialized_default_value =
new(std::nothrow) unsigned char[workflow_s->attribute_default_value_infos[i].serialized_default_value_size];
memcpy(cloned_s->attribute_default_value_infos[i].serialized_default_value,
mmi_workflow_s *workflow_s = static_cast<mmi_workflow_s*>(workflow);
- for (int i = 0; i < workflow_s->node_info_count; i++) {
+ for (size_t i = 0; i < workflow_s->node_info_count; i++) {
mmi_node_destroy(workflow_s->node_infos[i].node);
}
delete [] workflow_s->node_infos;
return true;
}
virtual std::shared_ptr<NodePrototype> get_node_prototype(
- mmi_standard_node_type_e type, mmi_standard_node_sub_type_e sub_type) override {
+ mmi_node_type_e type, mmi_node_sub_type_e sub_type) override {
last_query = std::make_pair(type, sub_type);
return nullptr;
}
- std::pair<mmi_standard_node_type_e, mmi_standard_node_sub_type_e> last_query;
+ std::pair<mmi_node_type_e, mmi_node_sub_type_e> last_query;
};
class PluginModuleProxyProviderDummy : public IPluginModuleProxyProvider {
TEST_F(NodeInstanceManagerTest, ProperNodePrototypeQueriedWhenCreatingNodeInstance) {
prototype_store->last_query = std::make_pair(
- MMI_STANDARD_NODE_TYPE_NONE, std::monostate{});
+ MMI_NODE_TYPE_NONE, std::monostate{});
std::shared_ptr<NodeInstance> instance = manager.create_node_instance(
- MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR );
+ MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR );
- ASSERT_EQ(prototype_store->last_query.first, MMI_STANDARD_NODE_TYPE_PROCESSOR);
- ASSERT_EQ(prototype_store->last_query.second, mmi_standard_node_sub_type_e{MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ ASSERT_EQ(prototype_store->last_query.first, MMI_NODE_TYPE_PROCESSOR);
+ ASSERT_EQ(prototype_store->last_query.second, mmi_node_sub_type_e{MMI_NODE_PROCESSOR_TYPE_ASR});
}
} // namespace
valid_prototype->set_plugin_module_info(
PluginModuleInfo{mmi_plugin_module_type_e::SHARED_LIBRARY, "test.so"});
- valid_prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
- valid_prototype->set_sub_type(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT);
+ valid_prototype->set_type(MMI_NODE_TYPE_SOURCE);
+ valid_prototype->set_sub_type(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT);
ASSERT_TRUE(valid_prototype->is_valid());
}
TEST_F(NodePrototypeManagerTest, NodePrototypeManagerRefusesInvalidPrototype_n) {
auto invalid_prototype = std::make_shared<NodePrototype>();
- invalid_prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
- invalid_prototype->set_sub_type(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ invalid_prototype->set_type(MMI_NODE_TYPE_SOURCE);
+ invalid_prototype->set_sub_type(MMI_NODE_PROCESSOR_TYPE_ASR);
manager.add_node_prototype(invalid_prototype);
prototype->set_plugin_module_info(
PluginModuleInfo{mmi_plugin_module_type_e::SHARED_LIBRARY, "test.so"});
- prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
- prototype->set_sub_type(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT);
+ prototype->set_type(MMI_NODE_TYPE_SOURCE);
+ prototype->set_sub_type(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT);
ASSERT_TRUE(prototype->is_valid());
- prototype->set_type(MMI_STANDARD_NODE_TYPE_PROCESSOR);
- prototype->set_sub_type(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ prototype->set_type(MMI_NODE_TYPE_PROCESSOR);
+ prototype->set_sub_type(MMI_NODE_PROCESSOR_TYPE_ASR);
ASSERT_TRUE(prototype->is_valid());
- prototype->set_type(MMI_STANDARD_NODE_TYPE_LOGIC);
- prototype->set_sub_type(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH);
+ prototype->set_type(MMI_NODE_TYPE_LOGIC);
+ prototype->set_sub_type(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH);
+ ASSERT_TRUE(prototype->is_valid());
+
+ prototype->set_type(MMI_NODE_TYPE_CUSTOM);
+ prototype->set_sub_type("com.samsung.tizen.custom-node-llm");
ASSERT_TRUE(prototype->is_valid());
}
prototype->set_plugin_module_info(
PluginModuleInfo{mmi_plugin_module_type_e::SHARED_LIBRARY, "test.so"});
- prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
+ prototype->set_type(MMI_NODE_TYPE_SOURCE);
/* No sub type provided */
ASSERT_FALSE(prototype->is_valid());
prototype->set_plugin_module_info(
PluginModuleInfo{mmi_plugin_module_type_e::SHARED_LIBRARY, "test.so"});
- prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
+ prototype->set_type(MMI_NODE_TYPE_SOURCE);
/* PROCESSOR sub type for SOURCE type */
- prototype->set_sub_type(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ prototype->set_sub_type(MMI_NODE_PROCESSOR_TYPE_ASR);
ASSERT_FALSE(prototype->is_valid());
}
PluginModuleInfo{mmi_plugin_module_type_e::SHARED_LIBRARY, ""});
/* No plugin module identifier provided */
- prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
- prototype->set_sub_type(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT);
+ prototype->set_type(MMI_NODE_TYPE_SOURCE);
+ prototype->set_sub_type(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT);
ASSERT_FALSE(prototype->is_valid());
}
+TEST_F(NodePrototypeTest, NodePrototypeContainsCorrectSubType_p) {
+ prototype->set_plugin_module_info(
+ PluginModuleInfo{mmi_plugin_module_type_e::SHARED_LIBRARY, "test.so"});
+
+ mmi_node_type_e type;
+ mmi_node_sub_type_e sub_type;
+
+ prototype->set_type(MMI_NODE_TYPE_SOURCE);
+ prototype->set_sub_type(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT);
+ type = prototype->get_type();
+ sub_type = prototype->get_sub_type();
+ ASSERT_EQ(type, MMI_NODE_TYPE_SOURCE);
+ ASSERT_EQ(std::get<mmi_node_source_type_e>(sub_type), MMI_NODE_SOURCE_TYPE_MIC_AMBIENT);
+
+ prototype->set_type(MMI_NODE_TYPE_PROCESSOR);
+ prototype->set_sub_type(MMI_NODE_PROCESSOR_TYPE_ASR);
+ type = prototype->get_type();
+ sub_type = prototype->get_sub_type();
+ ASSERT_EQ(type, MMI_NODE_TYPE_PROCESSOR);
+ ASSERT_EQ(std::get<mmi_node_processor_type_e>(sub_type), MMI_NODE_PROCESSOR_TYPE_ASR);
+
+ prototype->set_type(MMI_NODE_TYPE_LOGIC);
+ prototype->set_sub_type(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH);
+ type = prototype->get_type();
+ sub_type = prototype->get_sub_type();
+ ASSERT_EQ(type, MMI_NODE_TYPE_LOGIC);
+ ASSERT_EQ(std::get<mmi_node_logic_type_e>(sub_type), MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH);
+
+ prototype->set_type(MMI_NODE_TYPE_CUSTOM);
+ prototype->set_sub_type("com.samsung.tizen.custom-node-llm");
+ type = prototype->get_type();
+ sub_type = prototype->get_sub_type();
+ ASSERT_EQ(type, MMI_NODE_TYPE_CUSTOM);
+ ASSERT_EQ(std::get<std::string>(sub_type).compare("com.samsung.tizen.custom-node-llm"), 0);
+}
+
TEST_F(NodePrototypeTest, PortInfoProperlyAdded_p) {
ASSERT_TRUE(prototype->get_port_infos().size() == 0);
return true;
}
virtual std::shared_ptr<NodePrototype> get_node_prototype(
- mmi_standard_node_type_e type, mmi_standard_node_sub_type_e sub_type) override {
+ mmi_node_type_e type, mmi_node_sub_type_e sub_type) override {
for (auto &prototype : m_prototypes) {
if (prototype->get_type() == type && prototype->get_sub_type() == sub_type) {
return prototype;
bool ret = registry.load_node_prototypes();
ASSERT_TRUE(ret);
- auto asr_node = node_prototype_store->get_node_prototype(MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ auto asr_node = node_prototype_store->get_node_prototype(MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR);
ASSERT_NE(nullptr, asr_node);
- auto match_node = node_prototype_store->get_node_prototype(MMI_STANDARD_NODE_TYPE_LOGIC, MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH);
+ auto match_node = node_prototype_store->get_node_prototype(MMI_NODE_TYPE_LOGIC, MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH);
ASSERT_NE(nullptr, match_node);
registry.deinitialize();
bool ret = registry.load_node_prototypes();
ASSERT_TRUE(ret);
- auto node = node_prototype_store->get_node_prototype(MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_NONE);
+ auto node = node_prototype_store->get_node_prototype(MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_NONE);
ASSERT_EQ(nullptr, node);
registry.deinitialize();
return true;
}
virtual std::shared_ptr<NodePrototype> get_node_prototype(
- mmi_standard_node_type_e type, mmi_standard_node_sub_type_e sub_type) override {
+ mmi_node_type_e type, mmi_node_sub_type_e sub_type) override {
for (auto& prototype : node_prototypes) {
if (prototype->get_type() == type &&
prototype->get_sub_type() == sub_type) {
node_prototype_store = std::make_shared<NodePrototypeStoreDummy>();
auto mic_prototype = std::make_shared<NodePrototype>();
- mic_prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
- mic_prototype->set_sub_type(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT);
+ mic_prototype->set_type(MMI_NODE_TYPE_SOURCE);
+ mic_prototype->set_sub_type(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT);
PortInfo mic_audio{"AUDIO", MMI_PORT_TYPE_OUT, MMI_DATA_TYPE_AUDIO, "audio data"};
mic_prototype->add_port_info(mic_audio);
node_prototype_store->add_node_prototype(mic_prototype);
auto asr_prototype = std::make_shared<NodePrototype>();
- asr_prototype->set_type(MMI_STANDARD_NODE_TYPE_PROCESSOR);
- asr_prototype->set_sub_type(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ asr_prototype->set_type(MMI_NODE_TYPE_PROCESSOR);
+ asr_prototype->set_sub_type(MMI_NODE_PROCESSOR_TYPE_ASR);
PortInfo asr_audio{"AUDIO", MMI_PORT_TYPE_IN, MMI_DATA_TYPE_AUDIO, "audio data"};
asr_prototype->add_port_info(asr_audio);
node_prototype_store->add_node_prototype(asr_prototype);
}
virtual std::shared_ptr<NodeInstance> create_node_instance(
- mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type) override {
+ mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type) override {
create_requests.push_back(std::make_pair(node_type, node_sub_type));
auto node_instance = std::make_shared<NodeInstance>(node_type, node_sub_type);
if (node_instance) {
}
std::shared_ptr<NodePrototypeStoreDummy> node_prototype_store;
std::shared_ptr<IPluginModuleProxyProvider> plugin_module_proxy_provider;
- std::vector<std::pair<mmi_standard_node_type_e, mmi_standard_node_sub_type_e>> create_requests;
+ std::vector<std::pair<mmi_node_type_e, mmi_node_sub_type_e>> create_requests;
size_t destroy_requests{0};
size_t valid_link_requests{0};
};
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
workflow_prototype_store->add_workflow_prototype(prototype);
ClientMessageWorkflowInstanceCreate msg;
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
workflow_prototype_store->add_workflow_prototype(prototype);
ClientMessageWorkflowInstanceCreate create_msg;
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
workflow_prototype_store->add_workflow_prototype(prototype);
ClientMessageWorkflowInstanceCreate create_msg;
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
prototype->add_link_info(mmi::LinkInfo{
"MIC", "AUDIO", "ASR", "AUDIO"});
workflow_prototype_store->add_workflow_prototype(prototype);
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
workflow_prototype_store->add_workflow_prototype(prototype);
ClientMessageWorkflowInstanceCreate create_msg;
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
prototype->add_link_info(mmi::LinkInfo{
"MIC", "UNKNOWN_PORT", "ASR", "AUDIO"});
workflow_prototype_store->add_workflow_prototype(prototype);
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
prototype->add_link_info(mmi::LinkInfo{
"UNKNOWN_NODE", "AUDIO", "ASR", "AUDIO"});
workflow_prototype_store->add_workflow_prototype(prototype);
/* Add 2 nodes to the workflow prototype */
prototype->add_node_info(mmi::NodeInfo{
- "MIC", MMI_STANDARD_NODE_TYPE_SOURCE, MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT});
+ "MIC", MMI_NODE_TYPE_SOURCE, MMI_NODE_SOURCE_TYPE_MIC_AMBIENT});
prototype->add_node_info(mmi::NodeInfo{
- "ASR", MMI_STANDARD_NODE_TYPE_PROCESSOR, MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR});
+ "ASR", MMI_NODE_TYPE_PROCESSOR, MMI_NODE_PROCESSOR_TYPE_ASR});
AttributeAssignmentInfo attribute_assignment_info;
attribute_assignment_info.attribute_name = "COMMAND";
attribute_assignment_info.target_node_name = "ASR";
return true;
}
virtual std::shared_ptr<NodePrototype> get_node_prototype(
- mmi_standard_node_type_e type, mmi_standard_node_sub_type_e sub_type) override {
+ mmi_node_type_e type, mmi_node_sub_type_e sub_type) override {
for (auto& prototype : node_prototypes) {
if (prototype->get_type() == type &&
prototype->get_sub_type() == sub_type) {
}
}
void reset() {
- type = MMI_STANDARD_NODE_TYPE_NONE;
+ type = MMI_NODE_TYPE_NONE;
sub_type = std::monostate();
if (attribute) {
mmi_attribute_destroy(attribute);
}
}
void set_item(
- mmi_standard_node_type_e type,
- mmi_standard_node_sub_type_e sub_type,
+ mmi_node_type_e type,
+ mmi_node_sub_type_e sub_type,
mmi_attribute_h attribute) {
this->type = type;
this->sub_type = sub_type;
}
mmi_attribute_clone(attribute, &(this->attribute));
}
- mmi_standard_node_type_e type{MMI_STANDARD_NODE_TYPE_NONE};
- mmi_standard_node_sub_type_e sub_type{std::monostate()};
+ mmi_node_type_e type{MMI_NODE_TYPE_NONE};
+ mmi_node_sub_type_e sub_type{std::monostate()};
mmi_attribute_h attribute{nullptr};
};
class NodeInstanceTest : public NodeInstance
{
public:
- NodeInstanceTest(mmi_standard_node_type_e node_type, mmi_standard_node_sub_type_e node_sub_type) :
+ NodeInstanceTest(mmi_node_type_e node_type, mmi_node_sub_type_e node_sub_type) :
NodeInstance(node_type, node_sub_type) {
}
virtual ~NodeInstanceTest() {
node_prototype_store = std::make_shared<NodePrototypeStoreDummy>();
auto mic_prototype = std::make_shared<NodePrototype>();
- mic_prototype->set_type(MMI_STANDARD_NODE_TYPE_SOURCE);
- mic_prototype->set_sub_type(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT);
+ mic_prototype->set_type(MMI_NODE_TYPE_SOURCE);
+ mic_prototype->set_sub_type(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT);
PortInfo mic_audio{"AUDIO", MMI_PORT_TYPE_OUT, MMI_DATA_TYPE_AUDIO, "audio data"};
mic_prototype->add_port_info(mic_audio);
node_prototype_store->add_node_prototype(mic_prototype);
auto asr_prototype = std::make_shared<NodePrototype>();
- asr_prototype->set_type(MMI_STANDARD_NODE_TYPE_PROCESSOR);
- asr_prototype->set_sub_type(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ asr_prototype->set_type(MMI_NODE_TYPE_PROCESSOR);
+ asr_prototype->set_sub_type(MMI_NODE_PROCESSOR_TYPE_ASR);
PortInfo asr_audio{"AUDIO", MMI_PORT_TYPE_IN, MMI_DATA_TYPE_AUDIO, "audio data"};
asr_prototype->add_port_info(asr_audio);
node_prototype_store->add_node_prototype(asr_prototype);
}
virtual std::shared_ptr<NodeInstance> create_node_instance(
- mmi_standard_node_type_e node_type,
- mmi_standard_node_sub_type_e node_sub_type) override {
+ mmi_node_type_e node_type,
+ mmi_node_sub_type_e node_sub_type) override {
auto node_instance = std::make_shared<NodeInstanceTest>(node_type, node_sub_type);
if (node_instance) {
node_instance->set_node_prototype_store(node_prototype_store);
mmi_attribute_h attribute = nullptr;
mmi_attribute_create(value, "COMMAND", &attribute);
EXPECT_TRUE(workflow_instance->set_attribute(attribute));
- EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_STANDARD_NODE_TYPE_PROCESSOR);
- EXPECT_TRUE(std::holds_alternative<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
- EXPECT_EQ(std::get<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
- MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_NODE_TYPE_PROCESSOR);
+ EXPECT_TRUE(std::holds_alternative<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
+ EXPECT_EQ(std::get<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
+ MMI_NODE_PROCESSOR_TYPE_ASR);
EXPECT_TRUE(g_last_node_attribute_set_history.attribute != nullptr);
mmi_primitive_value_h history_item_value;
mmi_attribute_h attribute = nullptr;
mmi_attribute_create(value, "COMMAND", &attribute);
EXPECT_TRUE(workflow_instance->set_attribute(attribute));
- EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_STANDARD_NODE_TYPE_PROCESSOR);
- EXPECT_TRUE(std::holds_alternative<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
- EXPECT_EQ(std::get<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
- MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_NODE_TYPE_PROCESSOR);
+ EXPECT_TRUE(std::holds_alternative<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
+ EXPECT_EQ(std::get<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
+ MMI_NODE_PROCESSOR_TYPE_ASR);
EXPECT_TRUE(g_last_node_attribute_set_history.attribute != nullptr);
mmi_primitive_value_h history_item_value;
EXPECT_NE(workflow_instance, nullptr);
workflow_instance->initialize();
- EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_STANDARD_NODE_TYPE_PROCESSOR);
- EXPECT_TRUE(std::holds_alternative<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
- EXPECT_EQ(std::get<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
- MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_NODE_TYPE_PROCESSOR);
+ EXPECT_TRUE(std::holds_alternative<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
+ EXPECT_EQ(std::get<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
+ MMI_NODE_PROCESSOR_TYPE_ASR);
EXPECT_TRUE(g_last_node_attribute_set_history.attribute != nullptr);
mmi_primitive_value_h history_item_value;
EXPECT_NE(workflow_instance, nullptr);
workflow_instance->initialize();
- EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_STANDARD_NODE_TYPE_PROCESSOR);
- EXPECT_TRUE(std::holds_alternative<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
- EXPECT_EQ(std::get<mmi_standard_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
- MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR);
+ EXPECT_EQ(g_last_node_attribute_set_history.type, MMI_NODE_TYPE_PROCESSOR);
+ EXPECT_TRUE(std::holds_alternative<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type));
+ EXPECT_EQ(std::get<mmi_node_processor_type_e>(g_last_node_attribute_set_history.sub_type),
+ MMI_NODE_PROCESSOR_TYPE_ASR);
EXPECT_TRUE(g_last_node_attribute_set_history.attribute != nullptr);
char *name = nullptr;
#include <Ecore.h>
-static int state_changed_cb(mmi_state_e state, void *user_data) {
- return MMI_ERROR_NONE;
-}
-
class MMIMainTest : public ::testing::Test {
public:
void SetUp(void) override {
m_node_mic = nullptr;
/* FIXME: node should be 'found' instead of 'created' */
- mmi_standard_node_create_source(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT, &m_node_mic);
+ mmi_node_create_source(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT, &m_node_mic);
mmi_workflow_node_add(m_workflow, "MIC", m_node_mic);
m_node_asr = nullptr;
- mmi_standard_node_create_processor(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR, &m_node_asr);
+ mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_ASR, &m_node_asr);
mmi_workflow_node_add(m_workflow, "ASR", m_node_asr);
m_node_match = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &m_node_match);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &m_node_match);
mmi_workflow_node_add(m_workflow, "MATCH", m_node_match);
mmi_workflow_link_nodes_by_names(m_workflow, "MIC", "AUDIO", "ASR", "AUDIO");
return false;
}
- mmi_standard_node_type_e first_type;
- mmi_standard_node_type_e second_type;
+ mmi_node_type_e first_type;
+ mmi_node_type_e second_type;
mmi_node_get_type(first_workflow->node_infos[i].node, &first_type);
mmi_node_get_type(second_workflow->node_infos[i].node, &second_type);
}
switch(first_type) {
- case MMI_STANDARD_NODE_TYPE_SOURCE:
+ case MMI_NODE_TYPE_SOURCE:
{
- mmi_standard_node_source_type_e first_source_type;
- mmi_standard_node_source_type_e second_source_type;
- mmi_standard_node_get_source_type(first_workflow->node_infos[i].node, &first_source_type);
- mmi_standard_node_get_source_type(second_workflow->node_infos[i].node, &second_source_type);
+ mmi_node_source_type_e first_source_type;
+ mmi_node_source_type_e second_source_type;
+ mmi_node_get_source_type(first_workflow->node_infos[i].node, &first_source_type);
+ mmi_node_get_source_type(second_workflow->node_infos[i].node, &second_source_type);
if (first_source_type != second_source_type) {
return false;
}
}
break;
- case MMI_STANDARD_NODE_TYPE_PROCESSOR:
+ case MMI_NODE_TYPE_PROCESSOR:
{
- mmi_standard_node_processor_type_e first_processor_type;
- mmi_standard_node_processor_type_e second_processor_type;
- mmi_standard_node_get_processor_type(first_workflow->node_infos[i].node, &first_processor_type);
- mmi_standard_node_get_processor_type(second_workflow->node_infos[i].node, &second_processor_type);
+ mmi_node_processor_type_e first_processor_type;
+ mmi_node_processor_type_e second_processor_type;
+ mmi_node_get_processor_type(first_workflow->node_infos[i].node, &first_processor_type);
+ mmi_node_get_processor_type(second_workflow->node_infos[i].node, &second_processor_type);
if (first_processor_type != second_processor_type) {
return false;
}
}
break;
- case MMI_STANDARD_NODE_TYPE_LOGIC:
+ case MMI_NODE_TYPE_LOGIC:
{
- mmi_standard_node_logic_type_e first_logic_type;
- mmi_standard_node_logic_type_e second_logic_type;
- mmi_standard_node_get_logic_type(first_workflow->node_infos[i].node, &first_logic_type);
- mmi_standard_node_get_logic_type(second_workflow->node_infos[i].node, &second_logic_type);
+ mmi_node_logic_type_e first_logic_type;
+ mmi_node_logic_type_e second_logic_type;
+ mmi_node_get_logic_type(first_workflow->node_infos[i].node, &first_logic_type);
+ mmi_node_get_logic_type(second_workflow->node_infos[i].node, &second_logic_type);
if (first_logic_type != second_logic_type) {
return false;
mmi_node_h node_mic = nullptr;
/* FIXME: node should be 'found' instead of 'created' */
- mmi_standard_node_create_source(MMI_STANDARD_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
+ mmi_node_create_source(MMI_NODE_SOURCE_TYPE_MIC_AMBIENT, &node_mic);
mmi_workflow_node_add(workflow, "MIC", node_mic);
mmi_node_h node_asr = nullptr;
- mmi_standard_node_create_processor(MMI_STANDARD_NODE_PROCESSOR_TYPE_ASR, &node_asr);
+ mmi_node_create_processor(MMI_NODE_PROCESSOR_TYPE_ASR, &node_asr);
mmi_workflow_node_add(workflow, "ASR", node_asr);
mmi_node_h node_match = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_FIXED_STRING_MATCH, &node_match);
mmi_workflow_node_add(workflow, "MATCH", node_match);
mmi_workflow_link_nodes_by_names(workflow, "MIC", "AUDIO", "ASR", "AUDIO");
mmi_workflow_clone(m_workflow, &workflow);
mmi_node_h node_regex_match = nullptr;
- mmi_standard_node_create_logic(MMI_STANDARD_NODE_LOGIC_TYPE_REGEX_STRING_MATCH, &node_regex_match);
+ mmi_node_create_logic(MMI_NODE_LOGIC_TYPE_REGEX_STRING_MATCH, &node_regex_match);
mmi_workflow_node_add(workflow, "REGEX_MATCH", node_regex_match);
EXPECT_FALSE(compare_workflow_prototype(m_workflow, workflow));
TEST_F(MMIWorkflowTest, MMIWorkflowCreateFromScript_p1) {
mmi_workflow_h workflow = NULL;
- const char *script = NULL;
- int ret = MMI_ERROR_NONE;
std::string script_data = R"(
@workflow
interface mmi {
void result_cb(string source_name, bundle data) delegate;
- int workflow_instance_create(in int local_workflow_instance_id, in int workflow_type);
+ int workflow_instance_create(in int local_workflow_instance_id, in int workflow_type, in bool script_from_file, in string script_info);
int workflow_instance_destroy(in int local_workflow_instance_id);
int workflow_instance_set_attribute(in int local_workflow_instance_id, in bundle attribute);
int workflow_instance_emit_signal(in int local_workflow_instance_id, in bundle signal);
+ int workflow_instance_feed_data(in int local_workflow_instance_id, in string node_name, in string port_name, in bundle data);
int workflow_instance_activate(in int local_workflow_instance_id);
int workflow_instance_deactivate(in int local_workflow_instance_id);
int workflow_instance_register_result_callback(in int local_workflow_instance_id, result_cb callback);