%license COPYING
%{_bindir}/mmi-manager
%{_libdir}/libmmi*.so*
+%{_datadir}/iu/*
%{_datadir}/mmi-provider/*
%{_libdir}/provider/libmmi*.so
%{_datadir}/packages/%{name}.xml
--- /dev/null
+/*
+ * Copyright (c) 2022 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 <json-glib/json-glib.h>
+
+#include "mmi_iu_log.h"
+#include "mmi_iu_error.h"
+
+#include "PreDefinedCommands.h"
+
+
+using namespace std;
+
+
+static const char *__COMMAND_RESULT = "Result";
+static const char *__COMMAND_CANDIDATES = "Candidates";
+
+
+PreDefinedCommands::PreDefinedCommands()
+{
+ __parser = nullptr;
+ __language.clear();
+ __commands.clear();
+}
+
+PreDefinedCommands::~PreDefinedCommands()
+{
+ __commands.clear();
+ __language.clear();
+ if (__parser) {
+ g_object_unref(__parser);
+ __parser = nullptr;
+ }
+}
+
+void PreDefinedCommands::setCommandFilePath(std::string filePath)
+{
+ JsonParser *parser = json_parser_new();
+ if (parser == nullptr) {
+ _E("Fail to create json parser handle");
+ return;
+ }
+
+ GError *error = nullptr;
+ json_parser_load_from_file(parser, filePath.c_str(), &error);
+ if (error != nullptr) {
+ _E("Fail to parse the file (%s). error(%s)", filePath.c_str(), error->message);
+ g_error_free(error);
+ g_object_unref(parser);
+ return;
+ }
+
+ __parser = parser;
+}
+
+void PreDefinedCommands::setLanguage(std::string language)
+{
+ if (__parser == nullptr) {
+ _E("Parser is still not set.");
+ return;
+ }
+
+ if (__language == language) {
+ _I("Language is not changed. language(%s)", language.c_str());
+ return;
+ }
+
+ JsonNode *root = json_parser_get_root(__parser);
+ if (root == nullptr) {
+ _E("Fail to get root node");
+ return;
+ }
+
+ JsonObject *object = json_node_get_object(root);
+ JsonArray *commands = json_object_get_array_member(object, language.c_str());
+ if (commands == nullptr) {
+ _E("Fail to get command set. language(%s)", language.c_str());
+ return;
+ }
+ __language = language;
+
+ json_array_foreach_element(commands, iterateCommandsCallback, static_cast<gpointer>(this));
+}
+
+void PreDefinedCommands::iterateCommandsCallback(JsonArray *array, guint index, JsonNode *element, gpointer userData)
+{
+ PreDefinedCommands *instance = static_cast<PreDefinedCommands *>(userData);
+ if (instance == nullptr) {
+ _E("User data is null");
+ return;
+ }
+
+ JsonObject *object = json_node_get_object(element);
+ if (object == nullptr) {
+ _E("Fail to get object from element");
+ return;
+ }
+
+ const gchar *result = json_object_get_string_member(object, __COMMAND_RESULT);
+ if (result == nullptr) {
+ _E("Fail to get result string");
+ return;
+ }
+
+ JsonArray *candidates = json_object_get_array_member(object, __COMMAND_CANDIDATES);
+ if (candidates == nullptr) {
+ _E("Fail to get candidates array");
+ return;
+ }
+
+ unsigned int size = json_array_get_length(candidates);
+ for (unsigned int i = 0; i < size; i++) {
+ const gchar *candidate = json_array_get_string_element(candidates, i);
+ _D("Set candidates. candidate(%s), result(%s)", candidate, result);
+
+ instance->__commands.insert(pair<string, string>(candidate, result));
+ }
+}
+
+std::string PreDefinedCommands::findCommand(std::string result)
+{
+ auto element = __commands.find(result);
+
+ if (element == __commands.end()) {
+ _E("There no matched command");
+ return "";
+ }
+
+ _I("Result : command(%s), result(%s)", result.c_str(), element->second.c_str());
+ return element->second;
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 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_IU_PRE_DEFINED_COMMANDS_H__
+#define __TIZEN_UIX_MMI_IU_PRE_DEFINED_COMMANDS_H__
+
+#include <map>
+#include <string>
+#include <memory>
+#include <json-glib/json-glib.h>
+
+
+class PreDefinedCommands {
+ public:
+ PreDefinedCommands();
+ ~PreDefinedCommands();
+
+ void setCommandFilePath(std::string filePath);
+ void setLanguage(std::string language);
+ std::string findCommand(std::string result);
+
+ private:
+ static void iterateCommandsCallback(JsonArray *array, guint index, JsonNode *element, gpointer userData);
+
+ private:
+ JsonParser *__parser;
+ std::string __language;
+ std::map<std::string, std::string> __commands;
+};
+
+#endif /* __TIZEN_UIX_MMI_IU_PRE_DEFINED_COMMANDS_H__ */
\ No newline at end of file
'iu/VoiceTouchEngine.h',
'iu/json_provider.cpp',
'iu/json_provider.h',
+ 'iu/PreDefinedCommands.cpp',
+ 'iu/PreDefinedCommands.h',
'output_modality/mmi_output_modality.cpp',
'output_modality/mmi_output_modality.h',
'output_modality/TouchModule.cpp',
'mmi-provider-iface.h',
)
+install_data('res/voice_touch_commands.json', install_dir : '/usr/share/iu/')
+
glib_dep = dependency('glib-2.0', method : 'pkg-config')
gio_dep = dependency('gio-2.0', method : 'pkg-config')
bundle_dep = dependency('bundle', method : 'pkg-config')
--- /dev/null
+{
+ "ko_KR" : [
+ {
+ "Result" : "SHOW_NUMBER",
+ "Candidates" : [
+ "힌트 보여줘",
+ "숫자 힌트 보여줘",
+ "숫자 보여줘",
+ "숫자"
+ ]
+ },
+ {
+ "Result" : "SHOW_LABEL",
+ "Candidates" : [
+ "힌트 메세지 보여줘",
+ "텍스트 보여줘",
+ "텍스트",
+ "텍스트 힌트 보여줘"
+ ]
+ },
+ {
+ "Result" : "SHOW_GRID",
+ "Candidates" : [
+ "그리드",
+ "그리드 모드",
+ "그리드로 보여줘",
+ "그리드 보여줘"
+ ]
+ },
+ {
+ "Result" : "REFRESH_WINDOW_INFO",
+ "Candidates" : [
+ "화면 갱신해줘",
+ "화면 업데이트",
+ "리프레시",
+ "새로고침",
+ "새로 고침"
+ ]
+ },
+ {
+ "Result" : "REQUEST_TURNING_OFF",
+ "Candidates" : [
+ "동작 그만",
+ "이제 그만"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_BACK",
+ "Candidates" : [
+ "뒤로"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_UP",
+ "Candidates" : [
+ "위",
+ "위로"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_DOWN",
+ "Candidates" : [
+ "아래",
+ "아래로"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_LEFT",
+ "Candidates" : [
+ "왼쪽",
+ "왼쪽으로"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_RIGHT",
+ "Candidates" : [
+ "오른쪽",
+ "오른쪽으로"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_RETURN",
+ "Candidates" : [
+ "선택",
+ "선택해줘",
+ "클릭"
+ ]
+ },
+ {
+ "Result" : "OPERATION_TRAY_ON",
+ "Candidates" : [
+ "트레이 열어",
+ "트레이 올려"
+ ]
+ },
+ {
+ "Result" : "OPERATION_TRAY_OFF",
+ "Candidates" : [
+ "트레이 닫아",
+ "트레이 내려"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PANEL_ON",
+ "Candidates" : [
+ "패널 열어",
+ "패널 내려"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PANEL_OFF",
+ "Candidates" : [
+ "패널 닫아",
+ "패널 올려"
+ ]
+ }
+ ],
+ "en_US" : [
+ {
+ "Result" : "SHOW_NUMBER",
+ "Candidates" : [
+ "show number",
+ "show numbers",
+ "please show me numbers"
+ ]
+ },
+ {
+ "Result" : "SHOW_LABEL",
+ "Candidates" : [
+ "show label",
+ "show labels",
+ "please show me labels"
+ ]
+ },
+ {
+ "Result" : "SHOW_GRID",
+ "Candidates" : [
+ "show grid",
+ "show grids",
+ "please show me grids"
+ ]
+ },
+ {
+ "Result" : "REFRESH_WINDOW_INFO",
+ "Candidates" : [
+ "refresh the screen",
+ "update the screen",
+ "refresh now",
+ "update now",
+ "refresh",
+ "update",
+ "please update the screen",
+ "please refresh the screen"
+ ]
+ },
+ {
+ "Result" : "REQUEST_TURNING_OFF",
+ "Candidates" : [
+ "stop recognition",
+ "stop",
+ "turn off",
+ "turn off recognition",
+ "stop voice touch",
+ "turn off voice touch"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_BACK",
+ "Candidates" : [
+ "back",
+ "press back"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_UP",
+ "Candidates" : [
+ "up",
+ "press up"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_DOWN",
+ "Candidates" : [
+ "down",
+ "press down"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_LEFT",
+ "Candidates" : [
+ "left",
+ "press left"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_RIGHT",
+ "Candidates" : [
+ "right",
+ "press right"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PRESS_RETURN",
+ "Candidates" : [
+ "click",
+ "click this",
+ "press return"
+ ]
+ },
+ {
+ "Result" : "OPERATION_TRAY_ON",
+ "Candidates" : [
+ "tray on",
+ "tray up"
+ ]
+ },
+ {
+ "Result" : "OPERATION_TRAY_OFF",
+ "Candidates" : [
+ "tray off",
+ "tray down"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PANEL_ON",
+ "Candidates" : [
+ "panel on",
+ "panel down"
+ ]
+ },
+ {
+ "Result" : "OPERATION_PANEL_OFF",
+ "Candidates" : [
+ "panel off",
+ "panel up"
+ ]
+ }
+ ]
+}
\ No newline at end of file