SET(SRCS
src/main.cpp
- src/multi_assistant_config.cpp
- src/multi_assistant_service.cpp
- src/multi_assistant_service_plugin.cpp
- src/multi_assistant_dbus.cpp
- src/multi_assistant_dbus_server.cpp
+ src/service_config.cpp
+ src/service_main.cpp
+ src/service_plugin.cpp
+ src/service_ipc_dbus.cpp
+ src/service_ipc_dbus_dispatcher.cpp
)
ADD_EXECUTABLE(${BINNAME} ${SRCS})
+++ /dev/null
-/*
- * Copyright 2018-2019 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 _MULTI_ASSISTANT_SERVICE_H_
-#define _MULTI_ASSISTANT_SERVICE_H_
-
-#include <dlog/dlog.h>
-#include <multi_assistant.h>
-#include <multi_assistant_internal.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MAX_APPID_LEN 255
-
-typedef enum {
- CLIENT_LAUNCH_MODE_ACTIVATION,
- CLIENT_LAUNCH_MODE_PRELAUNCH,
-} CLIENT_LAUNCH_MODE;
-
-typedef enum {
- PREPROCESSING_STATE_NONE,
- PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED,
- PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED,
- PREPROCESSING_STATE_PREPROCESSING_UTTERANCE,
- PREPROCESSING_STATE_PREPROCESSING_FOLLOW_UP,
-} PREPROCESSING_STATE;
-
-typedef enum {
- PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED,
- PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED,
- PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED,
- PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED,
- PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED,
- PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED,
-} PREPROCESSING_STATE_EVENT;
-
-int mas_client_initialize(int pid);
-
-int mas_client_deinitialize(int pid);
-
-int mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type);
-
-int mas_client_get_audio_source_type(int pid, char** type);
-
-int mas_client_send_preprocessing_information(int pid);
-
-int mas_client_activate(int pid);
-
-int mas_client_deactivate(int pid);
-
-int mas_client_request_speech_data(int pid);
-
-int mas_client_send_asr_result(int pid, int event, char* asr_result);
-
-int mas_client_send_result(int pid, char* display_text, char* utterance_text, char* result_json);
-
-int mas_client_send_recognition_result(int pid, int result);
-
-int mas_client_start_streaming_audio_data(int pid, int type);
-
-int mas_client_stop_streaming_audio_data(int pid, int type);
-
-int mas_client_update_voice_feedback_state(int pid, int state);
-
-int mas_client_set_assistant_specific_command(int pid, const char *command);
-
-int mas_client_set_background_volume(int pid, double ratio);
-
-int mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid);
-
-int mas_client_send_preprocessing_result(int pid, bool result);
-
-int mas_client_set_wake_word_audio_require_flag(int pid, bool require);
-
-int mas_client_set_assistant_language(int pid, const char* language);
-
-int mas_client_send_voice_key_status_change(int pid, ma_voice_key_status_e status);
-
-int mas_client_add_wake_word(int pid, const char* wake_word, const char* language);
-
-int mas_client_remove_wake_word(int pid, const char* wake_word, const char* language);
-
-int mas_ui_client_initialize(int pid);
-
-int mas_ui_client_deinitialize(int pid);
-
-int mas_ui_client_change_assistant(const char* appid);
-
-int mas_get_current_client_pid();
-
-int mas_get_current_preprocessing_client_pid();
-
-int mas_get_client_pid_by_wakeup_word(const char *wakeup_word);
-
-int mas_get_client_pid_by_appid(const char *appid);
-
-const char* mas_get_client_appid_by_pid(int pid);
-
-bool mas_get_client_custom_ui_option_by_appid(const char *appid);
-
-const char* mas_get_client_appid_by_wakeup_word(const char *wakeup_word);
-
-int mas_set_current_client_by_wakeup_word(const char *wakeup_word);
-
-int mas_set_current_client_by_appid(const char *appid);
-
-int mas_launch_client_by_wakeup_word(const char *wakeup_word);
-
-int mas_prelaunch_default_assistant();
-
-int mas_set_current_service_state(ma_service_state_e state);
-
-int mas_bring_client_to_foreground(const char* appid);
-
-ma_service_state_e mas_get_current_service_state();
-
-int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode);
-
-int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event);
-
-int mas_update_voice_key_support_mode();
-
-bool app_create(void *data);
-
-void app_terminate(void *data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _MULTI_ASSISTANT_SERVICE_H_ */
+++ /dev/null
-/*
- * Copyright 2018-2019 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 _MULTI_WAKEUP_RECOGNIZER_H_
-#define _MULTI_WAKEUP_RECOGNIZER_H_
-
-#include <dlog/dlog.h>
-
-#include <multi_assistant_common.h>
-#include <multi_assistant_service.h>
-#include <multi_assistant_internal.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*wakeup_service_wakeup_event_cb)(mas_wakeup_event_info wakeup_info, const char* wakeup_word, void* user_data);
-
-typedef void (*wakeup_service_speech_streaming_cb)(mas_speech_streaming_event_e event, unsigned char* buffer, int len, void *user_data);
-
-typedef void (*wakeup_service_speech_status_cb)(mas_speech_status_e status, void *user_data);
-
-typedef void (*wakeup_service_setting_changed_cb)(void *user_data);
-
-typedef void (*wakeup_service_error_cb)(int error, const char* err_msg, void* user_data);
-
-typedef void (*wakeup_service_streaming_section_changed_cb)(ma_audio_streaming_data_section_e section, void* user_data);
-
-typedef void (*wakeup_service_wakeup_engine_command_cb)(mas_wakeup_engine_command_target_e target, const char* assistant_name, const char* command, void* user_data);
-
-typedef void (*wakeup_service_wakeup_service_state_changed_cb)(ma_service_state_e state, void* user_data);
-
-typedef void (*wakeup_service_voice_key_status_changed_cb)(ma_voice_key_status_e status, void* user_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _MULTI_WAKEUP_RECOGNIZER_H_ */
-#ifndef __MULTI_ASSISTANT_SERVICE_H__
-#define __MULTI_ASSISTANT_SERVICE_H__
+#ifndef __SERVICE_COMMON_H__
+#define __SERVICE_COMMON_H__
#include <app.h>
#include <glib.h>
-#include "multi_wakeup_recognizer.h"
+#include <dlog/dlog.h>
+#include <multi_assistant_common.h>
+#include <multi_assistant_service.h>
#ifdef LOG_TAG
#undef LOG_TAG
#define MAS_UI_METHOD_SEND_RECOGNITION_RESULT "mas_ui_method_send_recognition_result"
#define MAS_UI_METHOD_ENABLE_COMMON_UI "mas_ui_method_enable_common_ui"
-#endif /* __MULTI_ASSISTANT_SERVICE_H__ */
+typedef void (*wakeup_service_wakeup_event_cb)(mas_wakeup_event_info wakeup_info, void* user_data);
+
+typedef void (*wakeup_service_speech_streaming_cb)(mas_speech_streaming_event_e event, void* buffer, int len, void *user_data);
+
+typedef void (*wakeup_service_speech_status_cb)(mas_speech_status_e status, void *user_data);
+
+typedef void (*wakeup_service_setting_changed_cb)(void *user_data);
+
+typedef void (*wakeup_service_error_cb)(int error, const char* err_msg, void* user_data);
+
+typedef void (*wakeup_service_streaming_section_changed_cb)(ma_audio_streaming_data_section_e section, void* user_data);
+
+typedef void (*wakeup_service_wakeup_engine_command_cb)(mas_wakeup_engine_command_target_e target, const char* assistant_name, const char* command, void* user_data);
+
+typedef void (*wakeup_service_wakeup_service_state_changed_cb)(ma_service_state_e state, void* user_data);
+
+typedef void (*wakeup_service_voice_key_status_changed_cb)(ma_voice_key_status_e status, void* user_data);
+
+#define MAX_WAKEUP_WORDS_NUM 255
+#define MAX_WAKEUP_WORD_LEN 32
+#define MAX_SUPPORTED_LANGUAGES_NUM 255
+#define MAX_SUPPORTED_LANGUAGE_LEN 16
+
+typedef enum {
+ VOICE_KEY_SUPPORT_MODE_NONE,
+ VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK,
+ VOICE_KEY_SUPPORT_MODE_TAP_TO_TALK,
+ VOICE_KEY_SUPPORT_MODE_ALL,
+} VOICE_KEY_SUPPORT_MODE;
+
+#endif /* __SERVICE_COMMON_H__ */
*/
-#ifndef __MULTI_ASSISTANT_CONFIG_H__
-#define __MULTI_ASSISTANT_CONFIG_H__
+#ifndef __SERVICE_CONFIG_H__
+#define __SERVICE_CONFIG_H__
#include <tizen.h>
#include <tzplatform_config.h>
+#include "service_common.h"
+
#ifdef __cplusplus
extern "C"
{
#define VOICE_KEY_SUPPORT_MODE_STRING_TAP_TO_TALK "tap_to_talk"
#define VOICE_KEY_SUPPORT_MODE_STRING_ALL "all"
-#define MAX_WAKEUP_WORDS_NUM 255
-#define MAX_WAKEUP_WORD_LEN 32
-#define MAX_SUPPORTED_LANGUAGES_NUM 255
-#define MAX_SUPPORTED_LANGUAGE_LEN 16
-
-typedef enum {
- VOICE_KEY_SUPPORT_MODE_NONE,
- VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK,
- VOICE_KEY_SUPPORT_MODE_TAP_TO_TALK,
- VOICE_KEY_SUPPORT_MODE_ALL,
-} VOICE_KEY_SUPPORT_MODE;
-
typedef struct {
const char* app_id;
const char* name;
float voice_key_tap_duration;
} ma_assistant_info_s;
-typedef int (*mas_config_assistant_info_cb)(ma_assistant_info_s* info, void* user_data);
+typedef int (*service_config_assistant_info_cb)(ma_assistant_info_s* info, void* user_data);
-class CConfig {
+class CServiceConfig {
public:
- CConfig() {};
- virtual ~CConfig() {};
+ CServiceConfig() {};
+ virtual ~CServiceConfig() {};
- int mas_config_get_assistant_info(mas_config_assistant_info_cb callback, void* user_data);
+ int get_assistant_info(service_config_assistant_info_cb callback, void* user_data);
- int mas_config_add_custom_wake_word(const char* wake_word, const char* language,
+ int add_custom_wake_word(const char* wake_word, const char* language,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN]);
- int mas_config_remove_custom_wake_word(const char* wake_word, const char* language,
+ int remove_custom_wake_word(const char* wake_word, const char* language,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN]);
- int mas_config_load_custom_wake_words(const char* app_id,
+ int load_custom_wake_words(const char* app_id,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN]);
- int mas_config_save_custom_wake_words(const char* app_id,
+ int save_custom_wake_words(const char* app_id,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN]);
- int mas_config_get_custom_wake_word_num(
+ int get_custom_wake_word_num(
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN]);
- bool mas_config_has_custom_wake_word(const char* wake_word, const char* language,
+ bool has_custom_wake_word(const char* wake_word, const char* language,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN]);
private:
- int mas_config_parse_assistant_info(mas_config_assistant_info_cb callback,
+ int parse_assistant_info(service_config_assistant_info_cb callback,
const char *path, void* user_data);
};
* @}
*/
-#endif /* __MULTI_ASSISTANT_CONFIG_H__ */
+#endif /* __SERVICE_CONFIG_H__ */
--- /dev/null
+/*
+ * Copyright 2018-2019 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __SERVICE_IPC_DBUS_H__
+#define __SERVICE_IPC_DBUS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dbus/dbus.h>
+#include <Ecore.h>
+
+#include "service_ipc_dbus_dispatcher.h"
+
+class CServiceMain;
+
+class CServiceIpcDbus {
+public:
+ CServiceIpcDbus() {}
+ virtual ~CServiceIpcDbus() {}
+
+ int open_connection();
+ int close_connection();
+ int send_hello(int pid);
+ int send_error_message(int reason, const char* err_msg);
+ int send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size);
+ int active_state_change(int pid, int state);
+ int send_preprocessing_information(int pid, const char* app_id);
+ int send_streaming_section_changed(int pid, int section);
+ int send_preprocessing_result(int pid, bool result);
+ int send_wakeup_engine_command(int pid, const char* command);
+ int service_state_change(int pid, int state);
+ int voice_key_status_change(int pid, int status);
+ int masc_ui_dbus_send_hello(void);
+ int masc_ui_dbus_send_asr_result(int pid, int event, char* asr_result);
+ int masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json);
+ int masc_ui_dbus_change_assistant(const char* app_id);
+ int masc_ui_dbus_send_error_message(int reason, const char* err_msg);
+ int masc_ui_dbus_send_recognition_result(int pid, int result);
+ int masc_ui_dbus_enable_common_ui(int enable);
+
+ DBusConnection* get_connection_listener() { return g_conn_listener; }
+ CServiceIpcDbusDispatcher* get_dispatcher() { return &mDispatcher; }
+
+ void set_service_main(CServiceMain* main) {
+ mServiceMain = main;
+ mDispatcher.set_service_main(main);
+ }
+private:
+ int __dbus_check();
+ void connection_free();
+ int reconnect();
+ int mas_check_dbus_connection();
+
+private:
+ CServiceIpcDbusDispatcher mDispatcher;
+
+ DBusConnection* g_conn_sender{NULL};
+ DBusConnection* g_conn_listener{NULL};
+
+ Ecore_Fd_Handler* g_dbus_fd_handler{NULL};
+
+ int g_streaming_data_serial{0};
+
+ CServiceMain* mServiceMain{nullptr};
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_IPC_DBUS_H__ */
--- /dev/null
+/*
+ * Copyright 2018-2019 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __SERVICE_IPC_DBUS_DISPATCHER_H__
+#define __SERVICE_IPC_DBUS_DISPATCHER_H__
+
+#include <dbus/dbus.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+class CServiceMain;
+
+class CServiceIpcDbusDispatcher {
+public:
+ CServiceIpcDbusDispatcher() {}
+ virtual ~CServiceIpcDbusDispatcher() {}
+
+ int on_hello(DBusConnection* conn, DBusMessage* msg);
+ int on_initialize(DBusConnection* conn, DBusMessage* msg);
+ int on_deinitialize(DBusConnection* conn, DBusMessage* msg);
+ int on_get_audio_format(DBusConnection* conn, DBusMessage* msg);
+ int on_get_audio_source_type(DBusConnection* conn, DBusMessage* msg);
+ int on_send_asr_result(DBusConnection* conn, DBusMessage* msg);
+ int on_send_result(DBusConnection* conn, DBusMessage* msg);
+ int on_send_recognition_result(DBusConnection* conn, DBusMessage* msg);
+ int on_start_streaming_audio_data(DBusConnection* conn, DBusMessage* msg);
+ int on_stop_streaming_audio_data(DBusConnection* conn, DBusMessage* msg);
+ int on_update_voice_feedback_state(DBusConnection* conn, DBusMessage* msg);
+ int on_send_assistant_specific_command(DBusConnection* conn, DBusMessage* msg);
+ int on_set_background_volume(DBusConnection* conn, DBusMessage* msg);
+ int on_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessage* msg);
+ int on_send_preprocessing_result(DBusConnection* conn, DBusMessage* msg);
+ int on_set_wake_word_audio_require_flag(DBusConnection* conn, DBusMessage* msg);
+ int on_set_assistant_language(DBusConnection* conn, DBusMessage* msg);
+ int on_add_wake_word(DBusConnection* conn, DBusMessage* msg);
+ int on_remove_wake_word(DBusConnection* conn, DBusMessage* msg);
+ int on_ui_initialize(DBusConnection* conn, DBusMessage* msg);
+ int on_ui_deinitialize(DBusConnection* conn, DBusMessage* msg);
+ int on_ui_change_assistant(DBusConnection* conn, DBusMessage* msg);
+
+ void set_service_main(CServiceMain* main) { mServiceMain = main; }
+private:
+ CServiceMain* mServiceMain{nullptr};
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __SERVICE_IPC_DBUS_DISPATCHER_H__ */
--- /dev/null
+/*
+ * Copyright 2018-2019 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __SERVICE_MAIN_H__
+#define __SERVICE_MAIN_H__
+
+#include <string>
+
+#include <dlog/dlog.h>
+#include <multi_assistant.h>
+#include <multi_assistant_internal.h>
+#include <package_manager.h>
+
+#include "service_common.h"
+#include "service_config.h"
+#include "service_plugin.h"
+#include "service_ipc_dbus.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_APPID_LEN 255
+
+typedef enum {
+ CLIENT_LAUNCH_MODE_ACTIVATION,
+ CLIENT_LAUNCH_MODE_PRELAUNCH,
+} CLIENT_LAUNCH_MODE;
+
+typedef enum {
+ PREPROCESSING_STATE_NONE,
+ PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED,
+ PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED,
+ PREPROCESSING_STATE_PREPROCESSING_UTTERANCE,
+ PREPROCESSING_STATE_PREPROCESSING_FOLLOW_UP,
+} PREPROCESSING_STATE;
+
+typedef enum {
+ PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED,
+ PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED,
+ PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED,
+ PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED,
+ PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED,
+ PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED,
+} PREPROCESSING_STATE_EVENT;
+
+#define ENABLE_MULTI_ASSISTANT_BY_DEFAULT
+
+#define MULTI_ASSISTANT_SETTINGS_ACTIVATED "db/multi-assistant/activated"
+#define WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID "db/multi-assistant/preprocessing_assistant_appid"
+#define WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE "db/multi-assistant/prelaunch_mode"
+
+#define MAX_MACLIENT_INFO_NUM 16
+
+typedef struct {
+ int pid;
+ char appid[MAX_APPID_LEN];
+} ma_client_s;
+
+class CServiceMain {
+public:
+ CServiceMain() {}
+ virtual ~CServiceMain() {}
+
+ int mas_client_initialize(int pid);
+ int mas_client_deinitialize(int pid);
+ int mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type);
+ int mas_client_get_audio_source_type(int pid, char** type);
+ int mas_client_send_preprocessing_information(int pid);
+ int mas_client_send_voice_key_status_change(int pid, ma_voice_key_status_e status);
+ int mas_client_activate(int pid);
+ int mas_client_deactivate(int pid);
+ int mas_client_request_speech_data(int pid);
+ int mas_client_send_asr_result(int pid, int event, char* asr_result);
+ int mas_client_send_result(int pid, char* display_text, char* utterance_text, char* result_json);
+ int mas_client_send_recognition_result(int pid, int result);
+ int mas_client_start_streaming_audio_data(int pid, int type);
+ int mas_client_stop_streaming_audio_data(int pid, int type);
+ int mas_client_update_voice_feedback_state(int pid, int state);
+ int mas_client_set_assistant_specific_command(int pid, const char *command);
+ int mas_client_set_background_volume(int pid, double ratio);
+ int mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid);
+ int mas_client_send_preprocessing_result(int pid, bool result);
+ int mas_client_set_wake_word_audio_require_flag(int pid, bool require);
+ int mas_client_set_assistant_language(int pid, const char* language);
+ int mas_client_add_wake_word(int pid, const char* wake_word, const char* language);
+ int mas_client_remove_wake_word(int pid, const char* wake_word, const char* language);
+ int mas_ui_client_initialize(int pid);
+ int mas_ui_client_deinitialize(int pid);
+ int mas_ui_client_change_assistant(const char* appid);
+ int mas_get_current_client_pid();
+ int mas_get_current_preprocessing_client_pid();
+ int mas_get_client_pid_by_wakeup_word(const char *wakeup_word);
+ int mas_get_client_pid_by_appid(const char *appid);
+ const char* mas_get_client_appid_by_pid(int pid);
+ bool mas_get_client_custom_ui_option_by_appid(const char *appid);
+ const char* mas_get_client_appid_by_wakeup_word(const char *wakeup_word);
+ int mas_set_current_client_by_wakeup_word(const char *wakeup_word);
+ int mas_set_current_client_by_appid(const char *appid);
+ int mas_launch_client_by_wakeup_word(const char *wakeup_word);
+ int mas_prelaunch_default_assistant();
+ int mas_set_current_service_state(ma_service_state_e state);
+ int mas_bring_client_to_foreground(const char* appid);
+ ma_service_state_e mas_get_current_service_state();
+ int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode);
+ int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event);
+ int mas_update_voice_key_support_mode();
+
+ bool app_create(void *data);
+ void app_terminate(void *data);
+
+ int initialize_service_plugin(void);
+ int deinitialize_service_plugin(void);
+
+ bool is_valid_wakeup_engine(const char* appid);
+ int process_activated_setting();
+
+ int add_assistant_info(ma_assistant_info_s* info);
+
+ CServicePlugin* get_service_plugin() { return &mServicePlugin; }
+private:
+ int ma_client_create(ma_client_s *info);
+ int ma_client_destroy(ma_client_s *client);
+ ma_client_s* ma_client_find_by_appid(const char *appid);
+ ma_client_s* ma_client_find_by_pid(int pid);
+
+ bool check_preprocessing_assistant_exists();
+ ma_preprocessing_allow_mode_e get_preprocessing_allow_mode(const char* appid);
+ bool is_current_preprocessing_assistant(const char* appid);
+
+private:
+ std::string g_current_lang{"en_US"};
+
+ typedef struct {
+ bool used;
+ char appid[MAX_APPID_LEN];
+ char wakeup_word[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
+ char wakeup_language[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+ char wakeup_engine[MAX_APPID_LEN];
+ char supported_language[MAX_SUPPORTED_LANGUAGES_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+ bool custom_ui_option;
+ VOICE_KEY_SUPPORT_MODE voice_key_support_mode;
+ float voice_key_tap_duration;
+
+ ma_preprocessing_allow_mode_e preprocessing_allow_mode;
+ char preprocessing_allow_appid[MAX_APPID_LEN];
+ } ma_client_info;
+
+ ma_client_info g_maclient_info[MAX_MACLIENT_INFO_NUM];
+
+ int g_current_maclient_info{0};
+ int g_current_preprocessing_maclient_info{-1};
+ std::string g_wakeup_maclient_appid;
+ package_manager_h g_pkgmgr{NULL};
+
+ PREPROCESSING_STATE g_current_preprocessing_state{PREPROCESSING_STATE_NONE};
+ ma_service_state_e g_current_service_state{MA_SERVICE_STATE_INACTIVE};
+
+ /* client list */
+ GSList* g_client_list{nullptr};
+
+ CServiceConfig mServiceConfig;
+ CServicePlugin mServicePlugin;
+ CServiceIpcDbus mServiceIpc;
+
+ ma_voice_key_status_e mLastVoiceKeyStatus{MA_VOICE_KEY_STATUS_RELEASED_AFTER_PUSH};
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_MAIN_H__ */
--- /dev/null
+/*
+ * Copyright 2018-2019 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __SERVICE_PLUGIN_H__
+#define __SERVICE_PLUGIN_H__
+
+#include <tzplatform_config.h>
+
+#include "service_common.h"
+#include "service_ipc_dbus.h"
+#include "service_plugin_interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+class CServiceMain;
+
+class CServicePlugin {
+public:
+ CServicePlugin() {};
+ virtual ~CServicePlugin() {};
+
+ int initialize(void);
+ int deinitialize(void);
+ int get_settings(ma_plugin_settings **settings, size_t *struct_size);
+ int set_language(const char* language);
+ int add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language);
+ int remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language);
+ int add_assistant_language(const char* appid, const char* language);
+ int set_assistant_wakeup_engine(const char* appid, const char* engine);
+ int set_default_assistant(const char* appid);
+ int get_default_assistant(const char** appid);
+ int activate(void);
+ int deactivate(void);
+ int update_voice_feedback_state(const char* appid, int state);
+ int set_assistant_specific_command(const char *appid, const char* command);
+ int set_background_volume(const char *appid, double ratio);
+ int update_recognition_result(const char* appid, int result);
+ int set_preprocessing_allow_mode(const char* appid, int mode, const char* preprocessing_appid);
+ int process_event(int event, void* data, int len);
+ int start_streaming_utterance_data(void);
+ int stop_streaming_utterance_data(void);
+ int start_streaming_previous_utterance_data(void);
+ int stop_streaming_previous_utterance_data(void);
+ int start_streaming_follow_up_data(void);
+ int stop_streaming_follow_up_data(void);
+ int get_recording_audio_format(int* rate, int* channel, int* audio_type);
+ int get_recording_audio_source_type(char **type);
+ int set_wake_word_audio_require_flag(const char* appid, bool require);
+ int set_assistant_language(const char* appid, const char* language);
+ int set_voice_key_support_mode(int mode);
+ int set_voice_key_tap_duration(float duration);
+ int unset_voice_key_tap_duration(void);
+ int set_callbacks(void);
+ int set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data);
+ int set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data);
+ int set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data);
+ int set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data);
+ int set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data);
+ int set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data);
+ int set_error_callback(wakeup_service_error_cb callback, void* user_data);
+ int set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data);
+ int set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data);
+ int set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data);
+ int set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data);
+
+ bool is_ui_panel_enabled();
+
+ void set_service_ipc(CServiceIpcDbus* ipc) { mServiceIpc = ipc; }
+ CServiceIpcDbus* get_service_ipc() { return mServiceIpc; }
+
+ void set_service_main(CServiceMain* main) { mServiceMain = main; }
+ CServiceMain* get_service_main() { return mServiceMain; }
+private:
+#ifdef BUF_SAVE_MODE
+ char g_temp_file_name[128] = {'\0', };
+ FILE* g_pFile = NULL;
+ int g_count = 1;
+#endif
+
+ void *g_handle = NULL;
+
+ wakeup_manager_interface _wakeup_manager_interface{NULL, };
+ ma_plugin_settings* g_plugin_settings{NULL};
+
+ CServiceIpcDbus* mServiceIpc{nullptr};
+ CServiceMain* mServiceMain{nullptr};
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_PLUGIN_H__ */
*/
-#ifndef _MULTI_ASSISTANT_SERVICE_PLUGIN_H_
-#define _MULTI_ASSISTANT_SERVICE_PLUGIN_H_
+#ifndef __SERVICE_PLUGIN_INTERFACE_H__
+#define __SERVICE_PLUGIN_INTERFACE_H__
#include <tzplatform_config.h>
-#include <dlog/dlog.h>
-#include <multi_assistant_service.h>
-
-#include "multi_wakeup_recognizer.h"
-#include "multi_assistant_main.h"
#ifdef __cplusplus
extern "C" {
bool ui_panel_enabled;
} ma_plugin_settings;
-int multi_assistant_service_plugin_initialize(void);
-
-int multi_assistant_service_plugin_deinitialize(void);
-
-int multi_assistant_service_plugin_get_settings(ma_plugin_settings **settings, size_t *struct_size);
-
-int multi_assistant_service_plugin_set_language(const char* language);
-
-int multi_assistant_service_plugin_add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language);
-
-int multi_assistant_service_plugin_remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language);
-
-int multi_assistant_service_plugin_add_assistant_language(const char* appid, const char* language);
-
-int multi_assistant_service_plugin_set_assistant_wakeup_engine(const char* appid, const char* engine);
-
-int multi_assistant_service_plugin_set_default_assistant(const char* appid);
-
-int multi_assistant_service_plugin_get_default_assistant(const char** appid);
-
-int multi_assistant_service_plugin_activate(void);
-
-int multi_assistant_service_plugin_deactivate(void);
-
-int multi_assistant_service_plugin_update_voice_feedback_state(const char* appid, int state);
-
-int multi_assistant_service_plugin_set_assistant_specific_command(const char *appid, const char* command);
-
-int multi_assistant_service_plugin_set_background_volume(const char *appid, double ratio);
-
-int multi_assistant_service_plugin_update_recognition_result(const char* appid, int result);
-
-int multi_assistant_service_plugin_set_preprocessing_allow_mode(const char* appid, int mode, const char* preprocessing_appid);
-
-int multi_assistant_service_plugin_process_event(int event, void* data, int len);
-
-int multi_assistant_service_plugin_start_streaming_utterance_data(void);
-
-int multi_assistant_service_plugin_stop_streaming_utterance_data(void);
-
-int multi_assistant_service_plugin_start_streaming_previous_utterance_data(void);
-
-int multi_assistant_service_plugin_stop_streaming_previous_utterance_data(void);
-
-int multi_assistant_service_plugin_start_streaming_follow_up_data(void);
-
-int multi_assistant_service_plugin_stop_streaming_follow_up_data(void);
-
-int multi_assistant_service_plugin_get_recording_audio_format(int* rate, int* channel, int* audio_type);
-
-int multi_assistant_service_plugin_get_recording_audio_source_type(char **type);
-
-int multi_assistant_service_plugin_set_wake_word_audio_require_flag(const char* appid, bool require);
-
-int multi_assistant_service_plugin_set_assistant_language(const char* appid, const char* language);
-
-int multi_assistant_service_plugin_set_voice_key_support_mode(int mode);
-
-int multi_assistant_service_plugin_set_voice_key_tap_duration(float duration);
-
-int multi_assistant_service_plugin_unset_voice_key_tap_duration(void);
-
-int multi_assistant_service_plugin_set_callbacks(void);
-
-int multi_assistant_service_plugin_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data);
-
-int multi_assistant_service_plugin_set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data);
-
-
#define MA_WAKEUP_MANAGER_PATH tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "multiassistant/")
#define MA_DEFAULT_WAKEUP_MANAGER_FILENAME "libma-wakeup-manager.so"
-
#define MA_WAKEUP_MANAGER_FUNC_INITIALIZE "wakeup_manager_initialize"
typedef int (*wakeup_manager_initialize)(void);
#define MA_WAKEUP_MANAGER_FUNC_DEINITIALIZE "wakeup_manager_deinitialize"
}
#endif
-#endif /* _MULTI_ASSISTANT_SERVICE_PLUGIN_H_ */
+#endif /* __SERVICE_PLUGIN_INTERFACE_H__ */
#ifndef _WAKEUP_MANAGER_H_
#define _WAKEUP_MANAGER_H_
-#include "multi_assistant_config.h"
+#include "service_config.h"
#include "wakeup_manager_wrapper.h"
#include "wakeup_settings.h"
#include "wakeup_engine_manager.h"
#include <stdexcept>
-#include "multi_assistant_main.h"
+#include "service_common.h"
#include "dependency_resolver.h"
#ifdef LOG_TAG
#include <tizen.h>
#include <service_app.h>
-#include "multi_assistant_service_client.h"
+#include "service_main.h"
+
+CServiceMain g_service_main;
static bool service_app_create(void *data)
{
- return app_create(data);
+ return g_service_main.app_create(data);
}
static void service_app_terminate(void *data)
{
-
- return app_terminate(data);
+ return g_service_main.app_terminate(data);
}
static void service_app_control(app_control_h app_control, void *data)
int main(int argc, char* argv[])
{
- char ad[50] = {0,};
+ char ad[50] = {0, };
service_app_lifecycle_callback_s event_callback;
app_event_handler_h handlers[5] = {NULL, };
+++ /dev/null
-/*
- * Copyright 2018-2019 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __MULTI_ASSISTANT_DBUS_h__
-#define __MULTI_ASSISTANT_DBUS_h__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int mas_dbus_open_connection();
-
-int mas_dbus_close_connection();
-
-int masc_dbus_send_hello(int pid);
-
-int masc_dbus_send_error_message(int reason, const char* err_msg);
-
-int masc_dbus_send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size);
-
-int masc_dbus_active_state_change(int pid, int state);
-
-int masc_dbus_send_preprocessing_information(int pid, const char* app_id);
-
-int masc_dbus_send_streaming_section_changed(int pid, int section);
-
-int masc_dbus_send_preprocessing_result(int pid, bool result);
-
-int masc_dbus_send_wakeup_engine_command(int pid, const char* command);
-
-int masc_dbus_service_state_change(int pid, int state);
-
-int masc_dbus_voice_key_status_change(int pid, int status);
-
-int masc_ui_dbus_send_hello(void);
-
-int masc_ui_dbus_send_asr_result(int pid, int event, char* asr_result);
-
-int masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json);
-
-int masc_ui_dbus_change_assistant(const char* app_id);
-
-int masc_ui_dbus_send_error_message(int reason, const char* err_msg);
-
-int masc_ui_dbus_send_recognition_result(int pid, int result);
-
-int masc_ui_dbus_enable_common_ui(int enable);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MULTI_ASSISTANT_DBUS_h__ */
+++ /dev/null
-/*
- * Copyright 2018-2019 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __MULTI_ASSISTANT_DBUS_SERVER_H__
-#define __MULTI_ASSISTANT_DBUS_SERVER_H__
-
-#include <dbus/dbus.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int ma_service_dbus_hello(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_initialize(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_get_audio_format(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_get_audio_source_type(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_send_result(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_send_recognition_result(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_start_streaming_audio_data(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_stop_streaming_audio_data(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_update_voice_feedback_state(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_send_assistant_specific_command(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_set_background_volume(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_send_preprocessing_result(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_set_wake_word_audio_require_flag(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_set_assistant_language(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_add_wake_word(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_dbus_remove_wake_word(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_ui_dbus_initialize(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_ui_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg);
-
-int ma_service_ui_dbus_change_assistant(DBusConnection* conn, DBusMessage* msg);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* __MULTI_ASSISTANT_DBUS_SERVER_H__ */
#include <app_preference.h>
-#include "multi_assistant_config.h"
-#include "multi_assistant_main.h"
+#include "service_config.h"
+#include "service_common.h"
-int CConfig::mas_config_parse_assistant_info(mas_config_assistant_info_cb callback,
+int CServiceConfig::parse_assistant_info(service_config_assistant_info_cb callback,
const char *path, void* user_data)
{
xmlDocPtr doc = NULL;
return 0;
}
-int CConfig::mas_config_get_assistant_info(mas_config_assistant_info_cb callback, void* user_data)
+int CServiceConfig::get_assistant_info(service_config_assistant_info_cb callback, void* user_data)
{
const char *suffix = ".xml";
char fullpath[_POSIX_PATH_MAX];
snprintf(fullpath, _POSIX_PATH_MAX - 1, "%s/%s", MA_ASSISTANT_INFO, dir->d_name);
MAS_LOGD("Parsing file : %s\n", fullpath);
- mas_config_parse_assistant_info(callback, fullpath, user_data);
+ parse_assistant_info(callback, fullpath, user_data);
}
}
}
return 0;
}
-int CConfig::mas_config_add_custom_wake_word(const char* wake_word, const char* language,
+int CServiceConfig::add_custom_wake_word(const char* wake_word, const char* language,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
return 0;
}
-int CConfig::mas_config_remove_custom_wake_word(const char* wake_word, const char* language,
+int CServiceConfig::remove_custom_wake_word(const char* wake_word, const char* language,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
return 0;
}
-int CConfig::mas_config_load_custom_wake_words(const char* app_id,
+int CServiceConfig::load_custom_wake_words(const char* app_id,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
return 0;
}
-int CConfig::mas_config_save_custom_wake_words(const char* app_id,
+int CServiceConfig::save_custom_wake_words(const char* app_id,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
return 0;
}
-int CConfig::mas_config_get_custom_wake_word_num(
+int CServiceConfig::get_custom_wake_word_num(
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
return num;
}
-bool CConfig::mas_config_has_custom_wake_word(const char* wake_word, const char* language,
+bool CServiceConfig::has_custom_wake_word(const char* wake_word, const char* language,
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
* limitations under the License.
*/
-#include <dbus/dbus.h>
+
#include <dirent.h>
#include <dlfcn.h>
-#include <Ecore.h>
#include <message_port.h>
-#include "multi_assistant_main.h"
-#include "multi_assistant_service_client.h"
-#include "multi_assistant_dbus_server.h"
-#include "multi_assistant_dbus.h"
-
-static DBusConnection* g_conn_sender = NULL;
-static DBusConnection* g_conn_listener = NULL;
-
-static Ecore_Fd_Handler* g_dbus_fd_handler = NULL;
-
-static int g_streaming_data_serial = 0;
+#include "service_common.h"
+#include "service_main.h"
+#include "service_ipc_dbus.h"
-int mas_dbus_reconnect()
+int CServiceIpcDbus::reconnect()
{
if (!g_conn_sender || !g_conn_listener) {
- mas_dbus_close_connection();
+ close_connection();
- if (0 != mas_dbus_open_connection()) {
+ if (0 != open_connection()) {
MAS_LOGE("[ERROR] Fail to reconnect");
return -1;
}
sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected");
if (false == sender_connected || false == listener_connected) {
- mas_dbus_close_connection();
+ close_connection();
- if (0 != mas_dbus_open_connection()) {
+ if (0 != open_connection()) {
MAS_LOGE("[ERROR] Fail to reconnect");
return -1;
}
return 0;
}
-static int __dbus_check()
+int CServiceIpcDbus::__dbus_check()
{
if (NULL == g_conn_sender || NULL == g_conn_listener) {
MAS_LOGE("[ERROR] NULL connection");
- return mas_dbus_reconnect();
+ return reconnect();
}
return 0;
}
-int mas_check_dbus_connection()
+int CServiceIpcDbus::mas_check_dbus_connection()
{
if (NULL == g_conn_sender || NULL == g_conn_listener) {
MAS_LOGE("[ERROR] NULL connection sender(%p), listener(%p)", g_conn_sender, g_conn_listener);
return 0;
}
-int masc_dbus_send_hello(int pid)
+int CServiceIpcDbus::send_hello(int pid)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return result;
}
-int masc_dbus_send_error_message(int reason, const char* err_msg)
+int CServiceIpcDbus::send_error_message(int reason, const char* err_msg)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
int section;
} streaming_data_streaming_section_header;
-void masc_message_port_error(int error)
+static void masc_message_port_error(int error)
{
MAS_LOGE("message_port error found : %s",
(MESSAGE_PORT_ERROR_NONE == error) ? "MESSAGE_PORT_ERROR_NONE" :
"MESSAGE_PORT_ERROR_UNKNOWN");
}
-int masc_dbus_send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size)
+int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
static unsigned char pending_buffer[STREAMING_BUFFER_SIZE];
static unsigned int pending_buffer_size = 0;
if (b) {
bundle_add_byte(b, "content", pending_buffer, pending_buffer_size);
int ret = message_port_send_message(
- mas_get_client_appid_by_pid(pid), message_port, b);
+ mServiceMain->mas_get_client_appid_by_pid(pid), message_port, b);
if (MESSAGE_PORT_ERROR_NONE != ret)
masc_message_port_error(ret);
if (b) {
bundle_add_byte(b, "content", buffer, total_size);
int ret = message_port_send_message(
- mas_get_client_appid_by_pid(pid), message_port, b);
+ mServiceMain->mas_get_client_appid_by_pid(pid), message_port, b);
if (MESSAGE_PORT_ERROR_NONE != ret)
masc_message_port_error(ret);
return 0;
}
-int masc_dbus_active_state_change(int pid, int state)
+int CServiceIpcDbus::active_state_change(int pid, int state)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_dbus_send_preprocessing_information(int pid, const char* app_id)
+int CServiceIpcDbus::send_preprocessing_information(int pid, const char* app_id)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_dbus_send_streaming_section_changed(int pid, int section)
+int CServiceIpcDbus::send_streaming_section_changed(int pid, int section)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
bundle *b = bundle_create();
streaming_data_header header;
total_size += sizeof(streaming_section_header);
bundle_add_byte(b, "content", buffer, total_size);
- int ret = message_port_send_message(mas_get_client_appid_by_pid(pid), message_port, b);
+ int ret = message_port_send_message(mServiceMain->mas_get_client_appid_by_pid(pid), message_port, b);
if (MESSAGE_PORT_ERROR_NONE != ret)
masc_message_port_error(ret);
return 0;
}
-int masc_dbus_send_preprocessing_result(int pid, bool result)
+int CServiceIpcDbus::send_preprocessing_result(int pid, bool result)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_dbus_send_wakeup_engine_command(int pid, const char* command)
+int CServiceIpcDbus::send_wakeup_engine_command(int pid, const char* command)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_dbus_service_state_change(int pid, int state)
+int CServiceIpcDbus::service_state_change(int pid, int state)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_dbus_voice_key_status_change(int pid, int status)
+int CServiceIpcDbus::voice_key_status_change(int pid, int status)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_ui_dbus_send_hello(void)
+int CServiceIpcDbus::masc_ui_dbus_send_hello(void)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return result;
}
-int masc_ui_dbus_send_asr_result(int pid, int event, char* asr_result)
+int CServiceIpcDbus::masc_ui_dbus_send_asr_result(int pid, int event, char* asr_result)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json)
+int CServiceIpcDbus::masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json)
{
if (0 != __dbus_check()) {
return -1; //MA_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_ui_dbus_change_assistant(const char* app_id)
+int CServiceIpcDbus::masc_ui_dbus_change_assistant(const char* app_id)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_ui_dbus_send_error_message(int reason, const char* err_msg)
+int CServiceIpcDbus::masc_ui_dbus_send_error_message(int reason, const char* err_msg)
{
if (NULL == g_conn_sender) {
MAS_LOGE("[Dbus ERROR] Dbus connection is not available");
return 0;
}
-int masc_ui_dbus_send_recognition_result(int pid, int result)
+int CServiceIpcDbus::masc_ui_dbus_send_recognition_result(int pid, int result)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
return 0;
}
-int masc_ui_dbus_enable_common_ui(int enable)
+int CServiceIpcDbus::masc_ui_dbus_enable_common_ui(int enable)
{
if (0 != __dbus_check()) {
return -1; //MAS_ERROR_OPERATION_FAILED;
static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
{
- if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW;
+ CServiceIpcDbus* service_ipc = static_cast<CServiceIpcDbus*>(data);
+ if (NULL == service_ipc) {
+ MAS_LOGE("Error : service_ipc NULL");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ DBusConnection* g_conn_listener = service_ipc->get_connection_listener();
+ if (NULL == g_conn_listener) {
+ MAS_LOGE("Error : g_conn_listener NULL");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ CServiceIpcDbusDispatcher* dispatcher = service_ipc->get_dispatcher();
+ if (NULL == dispatcher) {
+ MAS_LOGE("Error : dispatcher NULL");
+ return ECORE_CALLBACK_RENEW;
+ }
dbus_connection_read_write_dispatch(g_conn_listener, 50);
/* client event */
if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_HELLO)) {
- ma_service_dbus_hello(g_conn_listener, msg);
+ dispatcher->on_hello(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_INITIALIZE)) {
- ma_service_dbus_initialize(g_conn_listener, msg);
+ dispatcher->on_initialize(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_DEINITIALIZE)) {
- ma_service_dbus_deinitialize(g_conn_listener, msg);
+ dispatcher->on_deinitialize(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_GET_RECORDING_AUDIO_FORMAT)) {
- ma_service_dbus_get_audio_format(g_conn_listener, msg);
+ dispatcher->on_get_audio_format(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_GET_RECORDING_AUDIO_SOURCE_TYPE)) {
- ma_service_dbus_get_audio_source_type(g_conn_listener, msg);
+ dispatcher->on_get_audio_source_type(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SEND_ASR_RESULT)) {
- ma_service_dbus_send_asr_result(g_conn_listener, msg);
+ dispatcher->on_send_asr_result(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SEND_RESULT)) {
- ma_service_dbus_send_result(g_conn_listener, msg);
+ dispatcher->on_send_result(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SEND_RECOGNITION_RESULT)) {
- ma_service_dbus_send_recognition_result(g_conn_listener, msg);
+ dispatcher->on_send_recognition_result(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_START_STREAMING_AUDIO_DATA)) {
- ma_service_dbus_start_streaming_audio_data(g_conn_listener, msg);
+ dispatcher->on_start_streaming_audio_data(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_STOP_STREAMING_AUDIO_DATA)) {
- ma_service_dbus_stop_streaming_audio_data(g_conn_listener, msg);
+ dispatcher->on_stop_streaming_audio_data(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_UPDATE_VOICE_FEEDBACK_STATE)) {
- ma_service_dbus_update_voice_feedback_state(g_conn_listener, msg);
+ dispatcher->on_update_voice_feedback_state(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SEND_ASSISTANT_SPECIFIC_COMMAND)) {
- ma_service_dbus_send_assistant_specific_command(g_conn_listener, msg);
+ dispatcher->on_send_assistant_specific_command(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SET_BACKGROUND_VOLUME)) {
- ma_service_dbus_set_background_volume(g_conn_listener, msg);
+ dispatcher->on_set_background_volume(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SET_PREPROCESSING_ALLOW_MODE)) {
- ma_service_dbus_set_preprocessing_allow_mode(g_conn_listener, msg);
+ dispatcher->on_set_preprocessing_allow_mode(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SEND_PREPROCESSING_RESULT)) {
- ma_service_dbus_send_preprocessing_result(g_conn_listener, msg);
+ dispatcher->on_send_preprocessing_result(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SET_WAKE_WORD_AUDIO_REQUIRE_FLAG)) {
- ma_service_dbus_set_wake_word_audio_require_flag(g_conn_listener, msg);
+ dispatcher->on_set_wake_word_audio_require_flag(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SET_ASSISTANT_LANGUAGE)) {
- ma_service_dbus_set_assistant_language(g_conn_listener, msg);
+ dispatcher->on_set_assistant_language(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_ADD_WAKE_WORD)) {
- ma_service_dbus_add_wake_word(g_conn_listener, msg);
+ dispatcher->on_add_wake_word(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_REMOVE_WAKE_WORD)) {
- ma_service_dbus_remove_wake_word(g_conn_listener, msg);
+ dispatcher->on_remove_wake_word(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_UI_METHOD_INITIALIZE)) {
- ma_service_ui_dbus_initialize(g_conn_listener, msg);
+ dispatcher->on_ui_initialize(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_UI_METHOD_DEINITIALIZE)) {
- ma_service_ui_dbus_deinitialize(g_conn_listener, msg);
+ dispatcher->on_ui_deinitialize(g_conn_listener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_UI_METHOD_CHANGE_ASSISTANT)) {
- ma_service_ui_dbus_change_assistant(g_conn_listener, msg);
+ dispatcher->on_ui_change_assistant(g_conn_listener, msg);
} else {
MAS_LOGD("Message is NOT valid");
return ECORE_CALLBACK_RENEW;
}
-static void __mas_dbus_connection_free()
+void CServiceIpcDbus::connection_free()
{
if (NULL != g_conn_listener) {
dbus_connection_close(g_conn_listener);
}
}
-int mas_dbus_open_connection()
+int CServiceIpcDbus::open_connection()
{
DBusError err;
dbus_error_init(&err);
if (NULL == g_conn_listener) {
MAS_LOGE("[Dbus ERROR] Fail to get dbus connection");
- __mas_dbus_connection_free();
+ connection_free();
return -1;
}
if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
printf("Fail to be primary owner in dbus request.");
MAS_LOGE("[Dbus ERROR] Fail to be primary owner");
- __mas_dbus_connection_free();
+ connection_free();
return -1;
}
if (dbus_error_is_set(&err)) {
MAS_LOGE("[Dbus ERROR] dbus_bus_request_name() : %s", err.message);
dbus_error_free(&err);
- __mas_dbus_connection_free();
+ connection_free();
return -1;
}
/* Flush messages which are received before fd event handler registration */
while (DBUS_DISPATCH_DATA_REMAINS == dbus_connection_get_dispatch_status(g_conn_listener)) {
- listener_event_callback(NULL, NULL);
+ listener_event_callback(this, NULL);
}
/* add a rule for getting signal */
if (dbus_error_is_set(&err)) {
MAS_LOGE("[Dbus ERROR] dbus_bus_add_match() : %s", err.message);
dbus_error_free(&err);
- __mas_dbus_connection_free();
+ connection_free();
return -1;
}
int fd = 0;
if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) {
MAS_LOGE("fail to get fd from dbus ");
- __mas_dbus_connection_free();
+ connection_free();
return -1;
} else {
MAS_LOGD("Get fd from dbus : %d", fd);
}
- g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL);
+ g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, this, NULL, NULL);
if (NULL == g_dbus_fd_handler) {
MAS_LOGE("[Dbus ERROR] Fail to get fd handler");
- __mas_dbus_connection_free();
+ connection_free();
return -1;
}
return 0;
}
-int mas_dbus_close_connection()
+int CServiceIpcDbus::close_connection()
{
DBusError err;
dbus_error_init(&err);
dbus_error_free(&err);
}
- __mas_dbus_connection_free();
+ connection_free();
return 0;
}
\ No newline at end of file
#include <stdlib.h>
-#include "multi_assistant_main.h"
-#include "multi_assistant_dbus.h"
-#include "multi_assistant_dbus_server.h"
-#include "multi_assistant_service_client.h"
+#include "service_common.h"
+#include "service_ipc_dbus_dispatcher.h"
+#include "service_main.h"
/*
* Dbus Client-Daemon Server
*/
-int ma_service_dbus_hello(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_hello(DBusConnection* conn, DBusMessage* msg)
{
MAS_LOGD("[DEBUG] MAS HELLO");
return 0;
}
-int ma_service_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGD("[IN] mas initialize : pid(%d)", pid);
- ret = mas_client_initialize(pid);
+ ret = mServiceMain->mas_client_initialize(pid);
}
DBusMessage* reply;
return ret;
}
-int ma_service_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_deinitialize(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGD("[IN] mas deinitialize : pid(%d)", pid);
- ret = mas_client_deinitialize(pid);
+ ret = mServiceMain->mas_client_deinitialize(pid);
}
DBusMessage* reply;
return 0;
}
-int ma_service_dbus_get_audio_format(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_get_audio_format(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGD("[IN] mas get audio format");
- ret = mas_client_get_audio_format(pid, &rate, &channel, &audio_type);
+ ret = mServiceMain->mas_client_get_audio_format(pid, &rate, &channel, &audio_type);
}
DBusMessage* reply;
return ret;
}
-int ma_service_dbus_get_audio_source_type(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_get_audio_source_type(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGD("[IN] mas get audio source type");
- ret = mas_client_get_audio_source_type(pid, &type);
+ ret = mServiceMain->mas_client_get_audio_source_type(pid, &type);
}
DBusMessage* reply;
return ret;
}
-int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_send_asr_result(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas send asr result : pid(%d), event(%d), asr_result(%s)", pid, event, asr_result);
- ret = mas_client_send_asr_result(pid, event, asr_result);
+ ret = mServiceMain->mas_client_send_asr_result(pid, event, asr_result);
}
DBusMessage* reply;
return ret;
}
-int ma_service_dbus_send_result(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_send_result(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas send result : pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json);
- ret = mas_client_send_result(pid, display_text, utterance_text, result_json);
+ ret = mServiceMain->mas_client_send_result(pid, display_text, utterance_text, result_json);
}
DBusMessage* reply;
return ret;
}
-int ma_service_dbus_send_recognition_result(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_send_recognition_result(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas send recognition result : pid(%d), result(%d)", pid, result);
- ret = mas_client_send_recognition_result(pid, result);
+ ret = mServiceMain->mas_client_send_recognition_result(pid, result);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_start_streaming_audio_data(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_start_streaming_audio_data(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas send start streaming : pid(%d), type(%d)", pid, type);
- ret = mas_client_start_streaming_audio_data(pid, type);
+ ret = mServiceMain->mas_client_start_streaming_audio_data(pid, type);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_stop_streaming_audio_data(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_stop_streaming_audio_data(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas stop streaming : pid(%d), type(%d)", pid, type);
- ret = mas_client_stop_streaming_audio_data(pid, type);
+ ret = mServiceMain->mas_client_stop_streaming_audio_data(pid, type);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_update_voice_feedback_state(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_update_voice_feedback_state(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas update voice feedback : pid(%d), state(%d)", pid, state);
- ret = mas_client_update_voice_feedback_state(pid, state);
+ ret = mServiceMain->mas_client_update_voice_feedback_state(pid, state);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_send_assistant_specific_command(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_send_assistant_specific_command(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas send assistant specific command : pid(%d), command(%s)", pid, command);
- ret = mas_client_set_assistant_specific_command(pid, command);
+ ret = mServiceMain->mas_client_set_assistant_specific_command(pid, command);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_set_background_volume(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_set_background_volume(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas set background volume : pid(%d), ratio(%f)", pid, ratio);
- ret = mas_client_set_background_volume(pid, ratio);
+ ret = mServiceMain->mas_client_set_background_volume(pid, ratio);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
temp_app_id = strdup(app_id);
}
MAS_LOGI("[IN] mas set preprocessing allow mode : pid(%d), mode(%d), app_id(%s)", pid, mode, temp_app_id);
- ret = mas_client_set_preprocessing_allow_mode(pid,
+ ret = mServiceMain->mas_client_set_preprocessing_allow_mode(pid,
static_cast<ma_preprocessing_allow_mode_e>(mode), temp_app_id);
if (NULL != temp_app_id)
free(temp_app_id);
return ret;
}
-int ma_service_dbus_send_preprocessing_result(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_send_preprocessing_result(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas send preprocessing result : pid(%d), result(%d)", pid, result);
- ret = mas_client_send_preprocessing_result(pid, (bool)result);
+ ret = mServiceMain->mas_client_send_preprocessing_result(pid, (bool)result);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_set_wake_word_audio_require_flag(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_set_wake_word_audio_require_flag(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas set wake word audio require flag : pid(%d), require(%d)", pid, require);
- ret = mas_client_set_wake_word_audio_require_flag(pid, (bool)require);
+ ret = mServiceMain->mas_client_set_wake_word_audio_require_flag(pid, (bool)require);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_set_assistant_language(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_set_assistant_language(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas set assistant language : pid(%d), language(%s)", pid, language);
- ret = mas_client_set_assistant_language(pid, language);
+ ret = mServiceMain->mas_client_set_assistant_language(pid, language);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_add_wake_word(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_add_wake_word(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas add wake word : pid(%d), wake_word(%s) language(%s)", pid, wake_word, language);
- ret = mas_client_add_wake_word(pid, wake_word, language);
+ ret = mServiceMain->mas_client_add_wake_word(pid, wake_word, language);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_dbus_remove_wake_word(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_remove_wake_word(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGI("[IN] mas remove wake word : pid(%d), wake_word(%s) language(%s)", pid, wake_word, language);
- ret = mas_client_remove_wake_word(pid, wake_word, language);
+ ret = mServiceMain->mas_client_remove_wake_word(pid, wake_word, language);
}
MAS_LOGD("<<<<<");
return ret;
}
-int ma_service_ui_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_ui_initialize(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGD("[IN] mas ui initialize : pid(%d)", pid);
- ret = mas_ui_client_initialize(pid);
+ ret = mServiceMain->mas_ui_client_initialize(pid);
}
DBusMessage* reply;
return ret;
}
-int ma_service_ui_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_ui_deinitialize(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGD("[IN] mas ui deinitialize : pid(%d)", pid);
- ret = mas_ui_client_deinitialize(pid);
+ ret = mServiceMain->mas_ui_client_deinitialize(pid);
}
DBusMessage* reply;
return ret;
}
-int ma_service_ui_dbus_change_assistant(DBusConnection* conn, DBusMessage* msg)
+int CServiceIpcDbusDispatcher::on_ui_change_assistant(DBusConnection* conn, DBusMessage* msg)
{
+ if (nullptr == mServiceMain) {
+ MAS_LOGE("mServiceMain variable is NULL");
+ return -1;
+ }
+
DBusError err;
dbus_error_init(&err);
ret = -1; //MAS_ERROR_OPERATION_FAILED;
} else {
MAS_LOGD("[IN] mas ui change assisant : app_id(%s)", app_id);
- ret = mas_ui_client_change_assistant(app_id);
+ ret = mServiceMain->mas_ui_client_change_assistant(app_id);
}
DBusMessage* reply;
#include <malloc.h>
#include <Ecore.h>
#include <vconf.h>
-#include <package_manager.h>
#include <pkgmgr-info.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
-#include "multi_assistant_main.h"
-#include "multi_assistant_service_client.h"
-#include "multi_assistant_service_plugin.h"
-#include "multi_assistant_dbus.h"
-#include "multi_assistant_config.h"
-
-static const char *g_current_lang = "en_US";
-
-#define ENABLE_MULTI_ASSISTANT_BY_DEFAULT
-
-#define MULTI_ASSISTANT_SETTINGS_ACTIVATED "db/multi-assistant/activated"
-#define WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID "db/multi-assistant/preprocessing_assistant_appid"
-#define WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE "db/multi-assistant/prelaunch_mode"
-
-#define MAX_MACLIENT_INFO_NUM 16
-typedef struct {
- bool used;
- char appid[MAX_APPID_LEN];
- char wakeup_word[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
- char wakeup_language[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
- char wakeup_engine[MAX_APPID_LEN];
- char supported_language[MAX_SUPPORTED_LANGUAGES_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
- bool custom_ui_option;
- VOICE_KEY_SUPPORT_MODE voice_key_support_mode;
- float voice_key_tap_duration;
-
- ma_preprocessing_allow_mode_e preprocessing_allow_mode;
- char preprocessing_allow_appid[MAX_APPID_LEN];
-} ma_client_info;
-
-static ma_client_info g_maclient_info[MAX_MACLIENT_INFO_NUM];
-
-typedef struct {
- int pid;
- char appid[MAX_APPID_LEN];
-} ma_client_s;
-
-static int g_current_maclient_info = 0;
-static int g_current_preprocessing_maclient_info = -1;
-static const char *g_wakeup_maclient_appid = NULL;
-static package_manager_h g_pkgmgr = NULL;
-
-static PREPROCESSING_STATE g_current_preprocessing_state = PREPROCESSING_STATE_NONE;
-static ma_service_state_e g_current_service_state = MA_SERVICE_STATE_INACTIVE;
-static ma_voice_key_status_e g_last_voice_key_status = MA_VOICE_KEY_STATUS_RELEASED_AFTER_PUSH;
-
-/* client list */
-static GSList* g_client_list = NULL;
-static CConfig g_config;
-
-int ma_client_create(ma_client_s *info)
+#include "service_common.h"
+#include "service_main.h"
+#include "service_plugin.h"
+#include "service_ipc_dbus.h"
+#include "service_config.h"
+
+static CServiceMain* g_service_main = nullptr;
+
+int CServiceMain::ma_client_create(ma_client_s *info)
{
if (NULL == info) {
MAS_LOGE("Input parameter is NULL"); //LCOV_EXCL_LINE
return 0;
}
-int ma_client_destroy(ma_client_s *client)
+int CServiceMain::ma_client_destroy(ma_client_s *client)
{
if (NULL == client) {
MAS_LOGE("Input parameter is NULL"); //LCOV_EXCL_LINE
return 0;
}
-ma_client_s* ma_client_find_by_appid(const char *appid)
+ma_client_s* CServiceMain::ma_client_find_by_appid(const char *appid)
{
if (NULL == appid) {
MAS_LOGE("Input parameter is NULL"); //LCOV_EXCL_LINE
return NULL;
}
-ma_client_s* ma_client_find_by_pid(int pid)
+ma_client_s* CServiceMain::ma_client_find_by_pid(int pid)
{
ma_client_s *data = NULL;
return NULL;
}
-bool check_preprocessing_assistant_exists()
+bool CServiceMain::check_preprocessing_assistant_exists()
{
bool ret = false;
return ret;
}
-bool is_current_preprocessing_assistant(const char* appid)
+bool CServiceMain::is_current_preprocessing_assistant(const char* appid)
{
if (NULL == appid) return false;
return ret;
}
-int mas_client_initialize(int pid)
+int CServiceMain::mas_client_initialize(int pid)
{
MAS_LOGD("[Enter] pid(%d)", pid);
- char appid[MAX_APPID_LEN] = {'\0',};
+ char appid[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
appid[MAX_APPID_LEN - 1] = '\0';
}
mas_client_send_preprocessing_information(pid);
- if (MA_VOICE_KEY_STATUS_PRESSED == g_last_voice_key_status) {
- mas_client_send_voice_key_status_change(pid, g_last_voice_key_status);
+ if (MA_VOICE_KEY_STATUS_PRESSED == mLastVoiceKeyStatus) {
+ mas_client_send_voice_key_status_change(pid, mLastVoiceKeyStatus);
}
if (current_maclient_appid && 0 == strncmp(current_maclient_appid, appid, MAX_APPID_LEN)) {
MAS_LOGD("MA client with current maclient appid connected!");
- if (g_wakeup_maclient_appid && strncmp(g_wakeup_maclient_appid, appid, MAX_APPID_LEN) == 0) {
- g_wakeup_maclient_appid = NULL;
+ if (0 == g_wakeup_maclient_appid.compare(appid)) {
+ g_wakeup_maclient_appid.clear();
mas_client_activate(pid);
mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
} else {
MAS_LOGE("[ERROR] g_wakeup_maclient_appid and appid differ : %s %s",
- (g_wakeup_maclient_appid ? g_wakeup_maclient_appid : "NULL"), appid);
+ g_wakeup_maclient_appid.c_str(), appid);
}
} else {
MAS_LOGD("MA client connected, but its appid does not match with current maclient");
}
- masc_dbus_service_state_change(pid, mas_get_current_service_state());
+ mServiceIpc.service_state_change(pid, mas_get_current_service_state());
} else {
MAS_LOGE("[ERROR] Fail to retrieve appid");
}
return 0;
}
-int mas_client_deinitialize(int pid)
+int CServiceMain::mas_client_deinitialize(int pid)
{
MAS_LOGD("[Enter] pid(%d)", pid);
ma_client_s *client = ma_client_find_by_pid(pid);
return 0;
}
-int mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type)
+int CServiceMain::mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type)
{
MAS_LOGD("[Enter] pid(%d)", pid);
- int ret = multi_assistant_service_plugin_get_recording_audio_format(rate, channel, audio_type);
+ int ret = mServicePlugin.get_recording_audio_format(rate, channel, audio_type);
if (0 != ret){
MAS_LOGE("[ERROR] Fail to get recording audio format, ret(%d)", ret);
}
}
#define MAX_LOCAL_VARIABLE_STRING_LEN 256
-int mas_client_get_audio_source_type(int pid, char** type)
+int CServiceMain::mas_client_get_audio_source_type(int pid, char** type)
{
MAS_LOGD("[Enter] pid(%d)", pid);
if (NULL == type) return -1;
static char cached[MAX_LOCAL_VARIABLE_STRING_LEN] = {'\0'};
- int ret = multi_assistant_service_plugin_get_recording_audio_source_type(type);
+ int ret = mServicePlugin.get_recording_audio_source_type(type);
if (0 != ret){
MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
*type = cached;
return ret;
}
-int mas_client_send_preprocessing_information(int pid)
+int CServiceMain::mas_client_send_preprocessing_information(int pid)
{
int ret = -1;
MAS_LOGD("[Enter] pid(%d)", pid);
char* vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID);
MAS_LOGD("preprocessing_assistant_appid : %s", vconf_str);
if (vconf_str) {
- ret = masc_dbus_send_preprocessing_information(pid, vconf_str);
+ ret = mServiceIpc.send_preprocessing_information(pid, vconf_str);
free(vconf_str);
vconf_str = NULL;
}
return ret;
}
-int mas_client_send_voice_key_status_change(int pid, ma_voice_key_status_e status)
+int CServiceMain::mas_client_send_voice_key_status_change(int pid, ma_voice_key_status_e status)
{
- g_last_voice_key_status = status;
- int ret = masc_dbus_voice_key_status_change(pid, status);
+ int ret = -1;
+ MAS_LOGD("[Enter] pid(%d)", pid);
+
+ ret = mServiceIpc.voice_key_status_change(pid, status);
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
}
+ mLastVoiceKeyStatus = status;
+
return ret;
}
-int mas_client_activate(int pid)
+int CServiceMain::mas_client_activate(int pid)
{
int ret = -1;
MAS_LOGD("[Enter] pid(%d)", pid);
- ret = masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
+ ret = mServiceIpc.active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
return ret;
}
-int mas_client_deactivate(int pid)
+int CServiceMain::mas_client_deactivate(int pid)
{
int ret = -1;
MAS_LOGD("[Enter] pid(%d)", pid);
- ret = masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_INACTIVE);
+ ret = mServiceIpc.active_state_change(pid, MA_ACTIVE_STATE_INACTIVE);
return ret;
}
-int mas_client_send_asr_result(int pid, int event, char* asr_result)
+int CServiceMain::mas_client_send_asr_result(int pid, int event, char* asr_result)
{
MAS_LOGD("[Enter] pid(%d), event(%d), asr_result(%s)", pid, event, asr_result);
- int ret = masc_ui_dbus_send_asr_result(pid, event, asr_result);
+ int ret = mServiceIpc.masc_ui_dbus_send_asr_result(pid, event, asr_result);
if (0 != ret){
MAS_LOGE("[ERROR] Fail to send asr result, ret(%d)", ret);
}
return ret;
}
-int mas_client_send_result(int pid, char* display_text, char* utterance_text, char* result_json)
+int CServiceMain::mas_client_send_result(int pid, char* display_text, char* utterance_text, char* result_json)
{
MAS_LOGD("[Enter] pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json);
- int ret = masc_ui_dbus_send_result(pid, display_text, utterance_text, result_json);
+ int ret = mServiceIpc.masc_ui_dbus_send_result(pid, display_text, utterance_text, result_json);
if (0 != ret){
MAS_LOGE("[ERROR] Fail to send result, ret(%d)", ret);
}
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
}
- multi_assistant_service_plugin_update_recognition_result(pid_appid, MA_RECOGNITION_RESULT_EVENT_SUCCESS);
+ mServicePlugin.update_recognition_result(pid_appid, MA_RECOGNITION_RESULT_EVENT_SUCCESS);
return ret;
}
-int mas_client_send_recognition_result(int pid, int result)
+int CServiceMain::mas_client_send_recognition_result(int pid, int result)
{
MAS_LOGD("[Enter] pid(%d), result(%d)", pid, result);
- int ret = masc_ui_dbus_send_recognition_result(pid, result);
+ int ret = mServiceIpc.masc_ui_dbus_send_recognition_result(pid, result);
if (0 != ret){
MAS_LOGE("[ERROR] Fail to send recognition result, ret(%d)", ret);
}
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
}
- multi_assistant_service_plugin_update_recognition_result(pid_appid, result);
+ mServicePlugin.update_recognition_result(pid_appid, result);
return ret;
}
-int mas_client_start_streaming_audio_data(int pid, int type)
+int CServiceMain::mas_client_start_streaming_audio_data(int pid, int type)
{
int ret = -1;
switch(type) {
case MA_AUDIO_STREAMING_DATA_TYPE_CURRENT_UTTERANCE:
- ret = multi_assistant_service_plugin_start_streaming_utterance_data();
+ ret = mServicePlugin.start_streaming_utterance_data();
mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED);
break;
case MA_AUDIO_STREAMING_DATA_TYPE_PREVIOUS_UTTERANCE:
- ret = multi_assistant_service_plugin_start_streaming_previous_utterance_data();
+ ret = mServicePlugin.start_streaming_previous_utterance_data();
/* Preprocessing is not required for previous utterance streaming */
break;
case MA_AUDIO_STREAMING_DATA_TYPE_FOLLOW_UP_SPEECH:
- ret = multi_assistant_service_plugin_start_streaming_follow_up_data();
+ ret = mServicePlugin.start_streaming_follow_up_data();
mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED);
break;
}
return ret;
}
-int mas_client_stop_streaming_audio_data(int pid, int type)
+int CServiceMain::mas_client_stop_streaming_audio_data(int pid, int type)
{
int ret = -1;
switch(type) {
case MA_AUDIO_STREAMING_DATA_TYPE_CURRENT_UTTERANCE:
- ret = multi_assistant_service_plugin_stop_streaming_utterance_data();
+ ret = mServicePlugin.stop_streaming_utterance_data();
break;
case MA_AUDIO_STREAMING_DATA_TYPE_PREVIOUS_UTTERANCE:
- ret = multi_assistant_service_plugin_stop_streaming_previous_utterance_data();
+ ret = mServicePlugin.stop_streaming_previous_utterance_data();
break;
case MA_AUDIO_STREAMING_DATA_TYPE_FOLLOW_UP_SPEECH:
- ret = multi_assistant_service_plugin_stop_streaming_follow_up_data();
+ ret = mServicePlugin.stop_streaming_follow_up_data();
break;
}
return ret;
}
-int mas_client_update_voice_feedback_state(int pid, int state)
+int CServiceMain::mas_client_update_voice_feedback_state(int pid, int state)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
}
- multi_assistant_service_plugin_update_voice_feedback_state(pid_appid, state);
+ mServicePlugin.update_voice_feedback_state(pid_appid, state);
return 0;
}
-int mas_client_set_assistant_specific_command(int pid, const char *command)
+int CServiceMain::mas_client_set_assistant_specific_command(int pid, const char *command)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
}
- multi_assistant_service_plugin_set_assistant_specific_command(pid_appid, command);
+ mServicePlugin.set_assistant_specific_command(pid_appid, command);
return 0;
}
-int mas_client_set_background_volume(int pid, double ratio)
+int CServiceMain::mas_client_set_background_volume(int pid, double ratio)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
}
- multi_assistant_service_plugin_set_background_volume(pid_appid, ratio);
+ mServicePlugin.set_background_volume(pid_appid, ratio);
return 0;
}
-int mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid)
+int CServiceMain::mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
return 0;
}
-int mas_client_send_preprocessing_result(int pid, bool result)
+int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
ma_client_s* client = ma_client_find_by_appid(current_maclient_appid);
if (client) {
- masc_dbus_send_preprocessing_result(client->pid, result);
+ mServiceIpc.send_preprocessing_result(client->pid, result);
}
return 0;
}
-int mas_client_set_wake_word_audio_require_flag(int pid, bool require)
+int CServiceMain::mas_client_set_wake_word_audio_require_flag(int pid, bool require)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
}
- multi_assistant_service_plugin_set_wake_word_audio_require_flag(pid_appid, require);
+ mServicePlugin.set_wake_word_audio_require_flag(pid_appid, require);
return 0;
}
-int mas_client_set_assistant_language(int pid, const char* language)
+int CServiceMain::mas_client_set_assistant_language(int pid, const char* language)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
int ret = aul_app_get_appid_bypid(pid, buf, sizeof(buf));
if (AUL_R_OK == ret) {
buf[MAX_APPID_LEN - 1] = '\0';
pid_appid = buf;
}
- multi_assistant_service_plugin_set_assistant_language(pid_appid, language);
+ mServicePlugin.set_assistant_language(pid_appid, language);
return 0;
}
-int mas_client_add_wake_word(int pid, const char* wake_word, const char* language)
+int CServiceMain::mas_client_add_wake_word(int pid, const char* wake_word, const char* language)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
int ret = aul_app_get_appid_bypid(pid, buf, sizeof(buf));
if (AUL_R_OK == ret) {
buf[MAX_APPID_LEN - 1] = '\0';
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
if (g_maclient_info[loop].used &&
0 == strncmp(buf, g_maclient_info[loop].appid, MAX_APPID_LEN)) {
- ret = g_config.mas_config_add_custom_wake_word(wake_word, language,
+ ret = mServiceConfig.add_custom_wake_word(wake_word, language,
g_maclient_info[loop].wakeup_word,
g_maclient_info[loop].wakeup_language);
if (0 == ret) {
- g_config.mas_config_save_custom_wake_words(pid_appid,
+ mServiceConfig.save_custom_wake_words(pid_appid,
g_maclient_info[loop].wakeup_word,
g_maclient_info[loop].wakeup_language);
} else {
}
}
- multi_assistant_service_plugin_add_assistant_wakeup_word(pid_appid, wake_word, language);
+ mServicePlugin.add_assistant_wakeup_word(pid_appid, wake_word, language);
return 0;
}
-int mas_client_remove_wake_word(int pid, const char* wake_word, const char* language)
+int CServiceMain::mas_client_remove_wake_word(int pid, const char* wake_word, const char* language)
{
const char* pid_appid = NULL;
- char buf[MAX_APPID_LEN] = {'\0',};
+ char buf[MAX_APPID_LEN] = {'\0', };
int ret = aul_app_get_appid_bypid(pid, buf, sizeof(buf));
if (AUL_R_OK == ret) {
buf[MAX_APPID_LEN - 1] = '\0';
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
if (g_maclient_info[loop].used &&
0 == strncmp(buf, g_maclient_info[loop].appid, MAX_APPID_LEN)) {
- ret = g_config.mas_config_remove_custom_wake_word(wake_word, language,
+ ret = mServiceConfig.remove_custom_wake_word(wake_word, language,
g_maclient_info[loop].wakeup_word,
g_maclient_info[loop].wakeup_language);
if (0 == ret) {
- g_config.mas_config_save_custom_wake_words(pid_appid,
+ mServiceConfig.save_custom_wake_words(pid_appid,
g_maclient_info[loop].wakeup_word,
g_maclient_info[loop].wakeup_language);
}
}
}
- multi_assistant_service_plugin_remove_assistant_wakeup_word(pid_appid, wake_word, language);
+ mServicePlugin.remove_assistant_wakeup_word(pid_appid, wake_word, language);
return 0;
}
-int mas_ui_client_initialize(int pid)
+int CServiceMain::mas_ui_client_initialize(int pid)
{
MAS_LOGD("[Enter] pid(%d)", pid);
return 0;
}
-int mas_ui_client_deinitialize(int pid)
+int CServiceMain::mas_ui_client_deinitialize(int pid)
{
MAS_LOGD("[Enter] pid(%d)", pid);
return 0;
}
-int mas_ui_client_change_assistant(const char* appid)
+int CServiceMain::mas_ui_client_change_assistant(const char* appid)
{
MAS_LOGD("[Enter]");
}
bool use_custom_ui = mas_get_client_custom_ui_option_by_appid(appid);
- masc_ui_dbus_enable_common_ui(!use_custom_ui);
+ mServiceIpc.masc_ui_dbus_enable_common_ui(!use_custom_ui);
mas_set_current_client_by_appid(appid);
int pid = mas_get_client_pid_by_appid(appid);
if (pid != -1) {
mas_bring_client_to_foreground(appid);
mas_client_send_preprocessing_information(pid);
- if (MA_VOICE_KEY_STATUS_PRESSED == g_last_voice_key_status) {
- mas_client_send_voice_key_status_change(pid, g_last_voice_key_status);
+ if (MA_VOICE_KEY_STATUS_PRESSED == mLastVoiceKeyStatus) {
+ mas_client_send_voice_key_status_change(pid, mLastVoiceKeyStatus);
}
mas_client_activate(pid);
MAS_LOGD("MA Client with appid %s exists, requesting speech data", (appid ? appid : "NULL"));
/*
- int ret = multi_assistant_service_plugin_start_streaming_utterance_data();
+ int ret = mServicePlugin.start_streaming_utterance_data();
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to start streaming utterance data(%d)", ret);
}
return 0;
}
-int __mas_assistant_info_cb(ma_assistant_info_s* info, void* user_data) {
+static int mas_assistant_info_cb(ma_assistant_info_s* info, void* user_data) {
+ int ret = -1;
+ CServiceMain* service_main = static_cast<CServiceMain*>(user_data);
+ if (service_main) {
+ ret = service_main->add_assistant_info(info);
+ }
+ return ret;
+}
+
+int CServiceMain::add_assistant_info(ma_assistant_info_s* info) {
MAS_LOGD("__mas_assistant_info_cb called");
if (NULL == info) {
return 0;
}
-static void mas_active_state_changed_cb(keynode_t* key, void* data)
+static void active_state_changed_cb(keynode_t* key, void* data)
{
int vconf_value = 0;
if (vconf_get_bool(MULTI_ASSISTANT_SETTINGS_ACTIVATED, &vconf_value) == 0) {
MAS_LOGD("multi-assistant active state : %d\n", vconf_value);
- if (vconf_value) {
- multi_assistant_service_plugin_activate();
+ CServicePlugin *plugin = nullptr;
+ if (g_service_main) {
+ plugin = g_service_main->get_service_plugin();
+ }
+ if (plugin) {
+ if (vconf_value) {
+ plugin->activate();
+ } else {
+ plugin->deactivate();
+ }
} else {
- multi_assistant_service_plugin_deactivate();
+ MAS_LOGE("Could not change plugin state : %p %p", g_service_main, plugin);
}
}
}
-static int init_plugin(void)
+int CServiceMain::initialize_service_plugin(void)
{
- if (0 != multi_assistant_service_plugin_initialize()) {
+ if (0 != mServicePlugin.initialize()) {
MAS_LOGE("Fail to ws intialize");
return -1;
}
- if (0 != multi_assistant_service_plugin_set_language(g_current_lang)) {
+ if (0 != mServicePlugin.set_language(g_current_lang.c_str())) {
MAS_LOGE("Fail to ws set language");
return -1;
}
- if (0 == g_config.mas_config_get_assistant_info(__mas_assistant_info_cb, NULL)) {
+ if (0 == mServiceConfig.get_assistant_info(mas_assistant_info_cb, this)) {
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
int inner_loop;
if (g_maclient_info[loop].used &&
0 < strlen(g_maclient_info[loop].appid)) {
- g_config.mas_config_load_custom_wake_words(g_maclient_info[loop].appid,
+ mServiceConfig.load_custom_wake_words(g_maclient_info[loop].appid,
g_maclient_info[loop].wakeup_word, g_maclient_info[loop].wakeup_language);
if (0 < strlen(g_maclient_info[loop].wakeup_engine)) {
- multi_assistant_service_plugin_set_assistant_wakeup_engine(
+ mServicePlugin.set_assistant_wakeup_engine(
g_maclient_info[loop].appid,
g_maclient_info[loop].wakeup_engine);
}
if (0 < strlen(g_maclient_info[loop].wakeup_word[inner_loop])) {
MAS_LOGD("Registering wakeup word %s for app %s",
g_maclient_info[loop].wakeup_word[inner_loop], g_maclient_info[loop].appid);
- if (0 != multi_assistant_service_plugin_add_assistant_wakeup_word(
+ if (0 != mServicePlugin.add_assistant_wakeup_word(
g_maclient_info[loop].appid,
g_maclient_info[loop].wakeup_word[inner_loop],
g_maclient_info[loop].wakeup_language[inner_loop])) {
if (0 < strlen(g_maclient_info[loop].supported_language[inner_loop])) {
MAS_LOGD("Adding language %s for app %s",
g_maclient_info[loop].supported_language[inner_loop], g_maclient_info[loop].appid);
- if (0 != multi_assistant_service_plugin_add_assistant_language(
+ if (0 != mServicePlugin.add_assistant_language(
g_maclient_info[loop].appid,
g_maclient_info[loop].supported_language[inner_loop])) {
MAS_LOGE("Fail to add assistant's language");
MAS_LOGE("Fail to load assistant info");
}
- if (0 != multi_assistant_service_plugin_set_callbacks()) {
+ if (0 != mServicePlugin.set_callbacks()) {
MAS_LOGE("Fail to set callbacks");
return -1;
}
return 0;
}
-static int deinit_plugin(void)
+int CServiceMain::deinitialize_service_plugin(void)
{
MAS_LOGI("[ENTER]");
- if (0 != multi_assistant_service_plugin_deactivate()) {
+ if (0 != mServicePlugin.deactivate()) {
MAS_LOGE("Fail to deactivate");
}
- if (0 != multi_assistant_service_plugin_deinitialize()) {
+ if (0 != mServicePlugin.deinitialize()) {
MAS_LOGE("Fail to deinitialize");
}
MAS_LOGI("[END]");
return 0;
}
-static int process_activated_setting()
+int CServiceMain::process_activated_setting()
{
- if (0 == vconf_notify_key_changed(MULTI_ASSISTANT_SETTINGS_ACTIVATED, mas_active_state_changed_cb, NULL)) {
+ if (0 == vconf_notify_key_changed(MULTI_ASSISTANT_SETTINGS_ACTIVATED, active_state_changed_cb, NULL)) {
/* Activate / deactivate according to the vconf key setting */
- mas_active_state_changed_cb(NULL, NULL);
+ active_state_changed_cb(NULL, NULL);
} else {
#ifdef ENABLE_MULTI_ASSISTANT_BY_DEFAULT
/* Multi-assistant needs to be enabled by default, unless disabled explicitly */
- multi_assistant_service_plugin_activate();
+ mServicePlugin.activate();
const char *default_assistant = NULL;
- if (0 == multi_assistant_service_plugin_get_default_assistant(&default_assistant)) {
+ if (0 == mServicePlugin.get_default_assistant(&default_assistant)) {
if (NULL == default_assistant) {
if (g_maclient_info[0].used) {
default_assistant = g_maclient_info[0].appid;
MAS_LOGW("No default assistant, setting %s as default", default_assistant);
- multi_assistant_service_plugin_set_default_assistant(default_assistant);
+ mServicePlugin.set_default_assistant(default_assistant);
} else {
MAS_LOGE("No default assistant, and no assistant installed");
}
return 0;
}
-static int init_wakeup(void)
-{
- MAS_LOGD("[Enter] init_wakeup");
-
- int ret = mas_dbus_open_connection();
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to open connection");
- }
-
- init_plugin();
-
- process_activated_setting();
-
- mas_prelaunch_default_assistant();
- mas_update_voice_key_support_mode();
-
- /* For the case of preprocessing assistant, it always have to be launched beforehand */
- char *vconf_str;
- vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID);
- if (vconf_str) {
- MAS_LOGD("prelaunching preprocessing_assistant_appid : %s", vconf_str);
- mas_launch_client_by_appid(vconf_str, CLIENT_LAUNCH_MODE_PRELAUNCH);
- free(vconf_str);
- vconf_str = NULL;
- }
-
- return 0;
-}
-
-static void deinit_wakeup(void)
-{
- MAS_LOGI("[Enter] deinit_wakeup");
-
-/* if (NULL != g_current_lang) {
- free(g_current_lang);
- g_current_lang = NULL;
- }
-*/
- deinit_plugin();
-
- vconf_ignore_key_changed(MULTI_ASSISTANT_SETTINGS_ACTIVATED, mas_active_state_changed_cb);
-
- int ret = mas_dbus_close_connection();
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to close connection");
- }
- MAS_LOGI("[END]");
-}
-
-int mas_get_current_client_pid()
+int CServiceMain::mas_get_current_client_pid()
{
int ret = -1;
if (g_current_maclient_info >= 0 && g_current_maclient_info < MAX_MACLIENT_INFO_NUM) {
return ret;
}
-int mas_get_current_preprocessing_client_pid()
+int CServiceMain::mas_get_current_preprocessing_client_pid()
{
int ret = -1;
if (g_current_preprocessing_maclient_info >= 0 && g_current_preprocessing_maclient_info < MAX_MACLIENT_INFO_NUM) {
return ret;
}
-int mas_get_client_pid_by_appid(const char *appid)
+int CServiceMain::mas_get_client_pid_by_appid(const char *appid)
{
int ret = -1;
return ret;
}
-const char* mas_get_client_appid_by_pid(int pid)
+const char* CServiceMain::mas_get_client_appid_by_pid(int pid)
{
const char* ret = NULL;
return ret;
}
-bool mas_get_client_custom_ui_option_by_appid(const char *appid)
+bool CServiceMain::mas_get_client_custom_ui_option_by_appid(const char *appid)
{
bool ret = false;
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
return ret;
}
-int mas_get_client_pid_by_wakeup_word(const char *wakeup_word)
+int CServiceMain::mas_get_client_pid_by_wakeup_word(const char *wakeup_word)
{
const char *appid = mas_get_client_appid_by_wakeup_word(wakeup_word);
return mas_get_client_pid_by_appid(appid);
}
-const char* mas_get_client_appid_by_wakeup_word(const char *wakeup_word)
+const char* CServiceMain::mas_get_client_appid_by_wakeup_word(const char *wakeup_word)
{
int loop;
const char *appid = NULL;
return appid;
}
-int mas_set_current_client_by_wakeup_word(const char *wakeup_word)
+int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word)
{
int loop;
int ret = -1;
return ret;
}
-int mas_set_current_client_by_appid(const char *appid)
+int CServiceMain::mas_set_current_client_by_appid(const char *appid)
{
int ret = -1;
int prev_selection = g_current_maclient_info;
return ret;
}
-int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode)
+int CServiceMain::mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode)
{
if (NULL == appid || 0 == strlen(appid)) {
MAS_LOGE("appid invalid, failed launching MA Client");
}
}
}
- MAS_LOGD("g_wakeup_maclient_appid : %s, %d", g_wakeup_maclient_appid, found);
+ MAS_LOGD("g_wakeup_maclient_appid : %s, %d", g_wakeup_maclient_appid.c_str(), found);
}
if (b) bundle_free(b);
return result;
}
-int mas_bring_client_to_foreground(const char* appid)
+int CServiceMain::mas_bring_client_to_foreground(const char* appid)
{
/* Bring MA client to foreground - is there a better way other than launching? */
if (NULL == appid || 0 == strlen(appid)) {
return result;
}
-int mas_launch_client_by_wakeup_word(const char *wakeup_word)
+int CServiceMain::mas_launch_client_by_wakeup_word(const char *wakeup_word)
{
const char *appid = mas_get_client_appid_by_wakeup_word(wakeup_word);
return mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
}
-int mas_prelaunch_default_assistant()
+int CServiceMain::mas_prelaunch_default_assistant()
{
/* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */
int prelaunch_mode;
int res = vconf_get_bool(WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE, &prelaunch_mode);
if (0 == res && 0 != prelaunch_mode) {
const char *default_assistant = NULL;
- if (0 == multi_assistant_service_plugin_get_default_assistant(&default_assistant)) {
+ if (0 == mServicePlugin.get_default_assistant(&default_assistant)) {
if (0 == aul_app_is_running(default_assistant)) {
MAS_LOGD("prelaunching default_assistant_appid : %s", default_assistant);
mas_launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH);
return 0;
}
-int mas_update_voice_key_support_mode()
+int CServiceMain::mas_update_voice_key_support_mode()
{
/* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */
bool successful = false;
const char *default_assistant = NULL;
- if (0 == multi_assistant_service_plugin_get_default_assistant(&default_assistant)) {
+ if (0 == mServicePlugin.get_default_assistant(&default_assistant)) {
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
if (g_maclient_info[loop].used) {
if (default_assistant &&
strncmp(default_assistant, g_maclient_info[loop].appid, MAX_APPID_LEN) == 0) {
float duration = g_maclient_info[loop].voice_key_tap_duration;
if (0.0f < duration) {
- multi_assistant_service_plugin_set_voice_key_tap_duration(duration);
+ mServicePlugin.set_voice_key_tap_duration(duration);
} else {
- multi_assistant_service_plugin_unset_voice_key_tap_duration();
+ mServicePlugin.unset_voice_key_tap_duration();
}
- multi_assistant_service_plugin_set_voice_key_support_mode(
+ mServicePlugin.set_voice_key_support_mode(
g_maclient_info[loop].voice_key_support_mode);
successful = true;
}
}
if (!successful) {
- multi_assistant_service_plugin_unset_voice_key_tap_duration();
- multi_assistant_service_plugin_set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE_NONE);
+ mServicePlugin.unset_voice_key_tap_duration();
+ mServicePlugin.set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE_NONE);
}
return 0;
}
-ma_preprocessing_allow_mode_e get_preprocessing_allow_mode(const char* appid)
+ma_preprocessing_allow_mode_e CServiceMain::get_preprocessing_allow_mode(const char* appid)
{
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
if (appid && g_maclient_info[loop].used) {
/* This might need to be read from settings in the future, but using macro for now */
//#define BRING_PREPROCESSING_ASSISTANT_TO_FRONT
-int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event)
+int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event)
{
const char* current_maclient_appid = NULL;
const char* preprocessing_allow_appid = NULL;
return 0;
}
-int mas_set_current_service_state(ma_service_state_e state)
+int CServiceMain::mas_set_current_service_state(ma_service_state_e state)
{
g_current_service_state = state;
data = static_cast<ma_client_s*>(g_slist_nth_data(g_client_list, i));
if (NULL != data && -1 != data->pid) {
- int ret = masc_dbus_service_state_change(data->pid, state);
+ int ret = mServiceIpc.service_state_change(data->pid, state);
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to send wakeup service state change to %d, ret(%d)",
data->pid, ret);
return 0;
}
-ma_service_state_e mas_get_current_service_state()
+ma_service_state_e CServiceMain::mas_get_current_service_state()
{
return g_current_service_state;
}
-static int pkg_app_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+bool CServiceMain::is_valid_wakeup_engine(const char* appid)
{
+ for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) {
+ if (g_maclient_info[loop].used) {
+ LOGD("comparing appid : %s %s", g_maclient_info[loop].wakeup_engine, appid);
+ if (0 == strncmp(g_maclient_info[loop].wakeup_engine, appid, MAX_APPID_LEN)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+int pkg_app_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ if (nullptr == g_service_main) return -1;
+
char *appid = NULL;
- int ret = pkgmgrinfo_appinfo_get_appid (handle, &appid);
+ int ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
if (PMINFO_R_OK == ret && NULL != appid) {
int *result = (int*)user_data;
if (result) {
- for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) {
- if (g_maclient_info[loop].used) {
- LOGD("comparing appid : %s %s", g_maclient_info[loop].wakeup_engine, appid);
- if (0 == strncmp(g_maclient_info[loop].wakeup_engine, appid, MAX_APPID_LEN)) {
- *result = 1;
- }
- }
+ bool exists = g_service_main->is_valid_wakeup_engine(appid);
+ if (exists) {
+ *result = 1;
}
}
} else {
LOGE("pkgmgrinfo_appinfo_get_appid failed! error code=%d", ret);
- return 0;
}
return 0;
*/
static void _package_manager_event_cb(const char *type, const char *package, package_manager_event_type_e event_type, package_manager_event_state_e event_state, int progress, package_manager_error_e error, void *user_data)
{
+ CServiceMain* service_main = static_cast<CServiceMain*>(user_data);
+
int ret = 0;
- uid_t uid = getuid ();
+ uid_t uid = getuid();
pkgmgrinfo_pkginfo_h handle = NULL;
static bool in_progress = false;
bool should_exit = false;
return;
bool user = false;
- LOGD("type=%s package=%s event_type=%d event_state=%d progress=%d error=%d",
+ MAS_LOGD("type=%s package=%s event_type=%d event_state=%d progress=%d error=%d",
type, package, event_type, event_state, progress, error);
ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle);
if (ret != PMINFO_R_OK || NULL == handle) {
- LOGW("Failed to call pkgmgrinfo_pkginfo_get_pkginfo & get_usr_pkginfo(\"%s\",~) returned %d, uid : %d", package, ret, getuid ());
+ MAS_LOGW("Failed to call pkgmgrinfo_pkginfo_get_pkginfo & get_usr_pkginfo(\"%s\",~) returned %d, uid : %d", package, ret, getuid());
/* Try to get in user packages */
user = true;
- ret = pkgmgrinfo_pkginfo_get_usr_pkginfo (package, uid, &handle);
+ ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(package, uid, &handle);
if (ret != PMINFO_R_OK || NULL == handle) {
- LOGW("Failed to call pkgmgrinfo_pkginfo_get_pkginfo & get_usr_pkginfo(\"%s\",~) returned %d, uid : %d", package, ret, getuid ());
+ MAS_LOGW("Failed to call pkgmgrinfo_pkginfo_get_pkginfo & get_usr_pkginfo(\"%s\",~) returned %d, uid : %d", package, ret, getuid());
return;
}
}
}
if (1 == ret) {
if (PACKAGE_MANAGER_EVENT_STATE_STARTED == event_state) {
- LOGI("processing PACKAGE_MANAGER_EVENT_STATE_STARTED event : %d", event_type);
+ MAS_LOGI("processing PACKAGE_MANAGER_EVENT_STATE_STARTED event : %d", event_type);
if (false == in_progress) {
in_progress = true;
- deinit_plugin();
+ if (service_main) {
+ service_main->deinitialize_service_plugin();
+ } else {
+ MAS_LOGE("service_main is NULL");
+ }
}
} else if (PACKAGE_MANAGER_EVENT_STATE_COMPLETED == event_state) {
- LOGI("processing PACKAGE_MANAGER_EVENT_STATE_COMPLETED event : %d", event_type);
+ MAS_LOGI("processing PACKAGE_MANAGER_EVENT_STATE_COMPLETED event : %d", event_type);
if (false == in_progress) {
- deinit_plugin();
+ if (service_main) {
+ service_main->deinitialize_service_plugin();
+ } else {
+ MAS_LOGE("service_main is NULL");
+ }
+ }
+ /*
+ if (service_main) {
+ service_main->initialize_service_plugin();
+ service_main->process_activated_setting();
+ } else {
+ MAS_LOGE("service_main is NULL");
}
+ */
should_exit = true;
in_progress = false;
}
return;
}
-bool app_create(void *data)
+bool CServiceMain::app_create(void *data)
{
// Todo: add your code here.
-
MAS_LOGD("[Enter] Service app create");
- if (0 != init_wakeup()) {
- MAS_LOGE("Fail to init wakeup service");
- return false;
+ g_service_main = this;
+
+ mServiceIpc.set_service_main(this);
+
+ mServicePlugin.set_service_ipc(&mServiceIpc);
+ mServicePlugin.set_service_main(this);
+
+ int ret = mServiceIpc.open_connection();
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to open connection");
+ }
+
+ initialize_service_plugin();
+
+ process_activated_setting();
+
+ mas_prelaunch_default_assistant();
+ mas_update_voice_key_support_mode();
+
+ /* For the case of preprocessing assistant, it always have to be launched beforehand */
+ char *vconf_str;
+ vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID);
+ if (vconf_str) {
+ MAS_LOGD("prelaunching preprocessing_assistant_appid : %s", vconf_str);
+ mas_launch_client_by_appid(vconf_str, CLIENT_LAUNCH_MODE_PRELAUNCH);
+ free(vconf_str);
+ vconf_str = NULL;
}
if (!g_pkgmgr) {
int ret = package_manager_create(&g_pkgmgr);
if (ret == PACKAGE_MANAGER_ERROR_NONE) {
- ret = package_manager_set_event_cb(g_pkgmgr, _package_manager_event_cb, NULL);
+ ret = package_manager_set_event_cb(g_pkgmgr, _package_manager_event_cb, this);
if (ret == PACKAGE_MANAGER_ERROR_NONE) {
LOGD("package_manager_set_event_cb succeeded.");
- }
- else {
+ } else {
LOGE("package_manager_set_event_cb failed(%d)", ret);
}
- }
- else {
+ } else {
LOGE("package_manager_create failed(%d)", ret);
}
}
return true;
}
-void app_terminate(void *data)
+void CServiceMain::app_terminate(void *data)
{
MAS_LOGI("[ENTER]");
if (g_pkgmgr) {
g_pkgmgr = NULL;
}
- // Todo: add your code here.
- deinit_wakeup();
+ deinitialize_service_plugin();
+
+ vconf_ignore_key_changed(MULTI_ASSISTANT_SETTINGS_ACTIVATED, active_state_changed_cb);
+
+ int ret = mServiceIpc.close_connection();
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to close connection");
+ }
+
+ g_service_main = nullptr;
+
MAS_LOGI("[END]");
return;
}
#include <string.h>
#include <glib.h>
#include <dlfcn.h>
+#include <new>
-#include "multi_wakeup_recognizer.h"
-#include "multi_assistant_main.h"
-#include "multi_assistant_service_client.h"
-#include "multi_assistant_service_plugin.h"
-#include "multi_assistant_dbus.h"
+#include "service_main.h"
+#include "service_plugin.h"
+#include "service_ipc_dbus.h"
/* Sound buf save for test */
#if 0
#define BUF_SAVE_MODE
#endif
-#ifdef BUF_SAVE_MODE
-static char g_temp_file_name[128] = {'\0',};
-
-static FILE* g_pFile = NULL;
-
-static int g_count = 1;
-#endif
+typedef struct {
+ void* data;
+ CServicePlugin* plugin;
+} AsyncParam;
-static void *g_handle = NULL;
-
-static wakeup_manager_interface _wakeup_manager_interface = { NULL, };
-static ma_plugin_settings* g_plugin_settings = NULL;
-
-static bool is_ui_panel_enabled()
+bool CServicePlugin::is_ui_panel_enabled()
{
/* By default we assume the ui panel is always enabled unless explicitly turned off */
bool ret = true;
}
#endif /* -TEST_CODE */
-Eina_Bool process_wakeup_event_by_appid_timer(void* data)
+static Eina_Bool process_wakeup_event_by_appid_timer(void* data)
{
- char* appid = static_cast<char*>(data);
+ if (NULL == data) return ECORE_CALLBACK_CANCEL;
+ AsyncParam* param = static_cast<AsyncParam*>(data);
+
+ char* appid = static_cast<char*>(param->data);
MAS_LOGD("[ENTER] appid(%s)", appid);
int pid = -1;
if (!appid) return ECORE_CALLBACK_CANCEL;
- bool use_custom_ui = mas_get_client_custom_ui_option_by_appid(appid);
- bool ui_panel_enabled = is_ui_panel_enabled();
- if (ui_panel_enabled) masc_ui_dbus_enable_common_ui(!use_custom_ui);
+ CServicePlugin* plugin = param->plugin;
+ CServiceIpcDbus* service_ipc = nullptr;
+ CServiceMain* service_main = nullptr;
+ if (plugin) {
+ service_ipc = plugin->get_service_ipc();
+ service_main = plugin->get_service_main();
+ }
+ if (service_ipc && service_main) {
+ bool use_custom_ui = service_main->mas_get_client_custom_ui_option_by_appid(appid);
+ bool ui_panel_enabled = false;
+ if (param->plugin) ui_panel_enabled = param->plugin->is_ui_panel_enabled();
+ if (ui_panel_enabled) {
+ service_ipc->masc_ui_dbus_enable_common_ui(!use_custom_ui);
+ service_ipc->masc_ui_dbus_change_assistant(appid);
+ }
- mas_set_current_client_by_appid(appid);
- if (ui_panel_enabled) masc_ui_dbus_change_assistant(appid);
- if ((pid = mas_get_client_pid_by_appid(appid)) != -1) {
- mas_client_send_preprocessing_information(pid);
- mas_client_activate(pid);
- mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
- } else {
- // Appropriate MA Client not available, trying to launch new one
- MAS_LOGD("MA Client with appid %s does not exist, launching client", appid);
- mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
+ service_main->mas_set_current_client_by_appid(appid);
+ if ((pid = service_main->mas_get_client_pid_by_appid(appid)) != -1) {
+ service_main->mas_client_send_preprocessing_information(pid);
+ service_main->mas_client_activate(pid);
+ service_main->mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
+ } else {
+ // Appropriate MA Client not available, trying to launch new one
+ MAS_LOGD("MA Client with appid %s does not exist, launching client", appid);
+ service_main->mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
+ }
}
if (appid) free(appid);
+ delete param;
MAS_LOGD("END");
return ECORE_CALLBACK_CANCEL;
}
-Eina_Bool process_wakeup_event_by_word_timer(void* data)
+static Eina_Bool process_wakeup_event_by_word_timer(void* data)
{
- char* wakeup_word = static_cast<char*>(data);
MAS_LOGD("[ENTER]");
- if (!wakeup_word) return EINA_FALSE;
+ if (NULL == data) return ECORE_CALLBACK_CANCEL;
+ AsyncParam* param = static_cast<AsyncParam*>(data);
+
+ char* wakeup_word = static_cast<char*>(param->data);
+ CServicePlugin* plugin = param->plugin;
+ CServiceMain* service_main = nullptr;
+
+ if (plugin) {
+ service_main = plugin->get_service_main();
+ }
+
+ delete param;
+ param = nullptr;
- const char* appid = mas_get_client_appid_by_wakeup_word(wakeup_word);
- process_wakeup_event_by_appid_timer(static_cast<void*>(strdup(appid)));
+ if (service_main) {
+ const char* appid = service_main->mas_get_client_appid_by_wakeup_word(wakeup_word);
+ if (appid) {
+ param = new(std::nothrow) AsyncParam;
+ if (param) {
+ param->data = static_cast<void*>(strdup(appid));
+ param->plugin = plugin;
+ process_wakeup_event_by_appid_timer(static_cast<void*>(param));
+ }
+ }
+ }
if (wakeup_word) free(wakeup_word);
return ECORE_CALLBACK_CANCEL;
}
-static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, const char* wakeup_word, void* user_data)
+static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data)
{
+ MAS_LOGD("dalton debug : %p", user_data);
MAS_LOGD("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
int ret = -1;
- if (is_ui_panel_enabled()) {
- int retry_cnt = 0;
- while (0 != ret) {
- ret = masc_ui_dbus_send_hello();
- retry_cnt++;
- if (5 < retry_cnt) {
- MAS_LOGE("[ERROR] Fail to receive reply for hello, ret(%d)", ret);
- break;
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
+ if (plugin->is_ui_panel_enabled() && service_ipc) {
+ int retry_cnt = 0;
+ while (0 != ret) {
+ ret = service_ipc->masc_ui_dbus_send_hello();
+ retry_cnt++;
+ if (5 < retry_cnt) {
+ MAS_LOGE("[ERROR] Fail to receive reply for hello, ret(%d)", ret);
+ break;
+ }
}
}
}
}
#endif /* - TEST_CODE */
if (wakeup_info.wakeup_appid) {
- ecore_thread_main_loop_begin();
- ecore_timer_add(0.0f, process_wakeup_event_by_appid_timer,
- static_cast<void*>(strdup(wakeup_info.wakeup_appid)));
- ecore_thread_main_loop_end();
+ AsyncParam* param = new(std::nothrow) AsyncParam;
+ if (param) {
+ param->data = static_cast<void*>(strdup(wakeup_info.wakeup_appid));
+ param->plugin = static_cast<CServicePlugin*>(user_data);
+ ecore_thread_main_loop_begin();
+ ecore_timer_add(0.0f, process_wakeup_event_by_appid_timer,
+ static_cast<void*>(param));
+ ecore_thread_main_loop_end();
+ }
} else if (wakeup_info.wakeup_word) {
- ecore_thread_main_loop_begin();
- ecore_timer_add(0.0f, process_wakeup_event_by_word_timer,
- static_cast<void*>(strdup(wakeup_info.wakeup_word)));
- ecore_thread_main_loop_end();
+ AsyncParam* param = new(std::nothrow) AsyncParam;
+ if (param) {
+ param->data = static_cast<void*>(strdup(wakeup_info.wakeup_word));
+ param->plugin = static_cast<CServicePlugin*>(user_data);
+ ecore_thread_main_loop_begin();
+ ecore_timer_add(0.0f, process_wakeup_event_by_word_timer,
+ static_cast<void*>(param));
+ ecore_thread_main_loop_end();
+ }
}
-
}
static bool __validate_streaming_event_order(int pid, mas_speech_streaming_event_e *event)
if (NULL == event) return false;
- mas_speech_streaming_event_e expected_sequence [][2] = {
+ mas_speech_streaming_event_e expected_sequence[][2] = {
{MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
{MAS_SPEECH_STREAMING_EVENT_START, MAS_SPEECH_STREAMING_EVENT_FINISH},
{MAS_SPEECH_STREAMING_EVENT_CONTINUE, MAS_SPEECH_STREAMING_EVENT_CONTINUE},
return ret;
}
-static void handle_speech_streaming_event_failure(void *data)
+void handle_speech_streaming_event_failure(void* data)
{
- mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
+ AsyncParam* param = static_cast<AsyncParam*>(data);
+ if (NULL == param) return;
+
+ CServicePlugin* plugin = param->plugin;
+ CServiceMain* service_main = nullptr;
+ if (plugin) service_main = plugin->get_service_main();
+
+ if (service_main) {
+ service_main->mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
+ }
+
+ delete param;
}
-static void __audio_streaming_cb(mas_speech_streaming_event_e event, unsigned char* buffer, int len, void *user_data)
+static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffer, int len, void *user_data)
{
if (event == MAS_SPEECH_STREAMING_EVENT_FAIL) {
ecore_main_loop_thread_safe_call_async(handle_speech_streaming_event_failure, NULL);
}
static int count = 0;
if (event != MAS_SPEECH_STREAMING_EVENT_CONTINUE || count % 100 == 0) {
- MAS_LOGD( "[SUCCESS] __audio_streaming_cb is called, event(%d), buffer(%p), len(%d)", event, buffer, len);
+ MAS_LOGD("[SUCCESS] __audio_streaming_cb is called, event(%d), buffer(%p), len(%d)",
+ event, buffer, len);
}
++count;
- int pid = mas_get_current_client_pid();
- int preprocessing_pid = mas_get_current_preprocessing_client_pid();
- if (pid == -1) {
- MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
- } else {
- if (__validate_streaming_event_order(pid, &event)) {
- int ret = masc_dbus_send_streaming_audio_data(pid, event, buffer, len);
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
- }
- if (pid != preprocessing_pid && -1 != preprocessing_pid) {
- int ret = masc_dbus_send_streaming_audio_data(preprocessing_pid, event, buffer, len);
+ CServicePlugin* plugin = static_cast<CServicePlugin*>(user_data);
+ CServiceIpcDbus* service_ipc = nullptr;
+ CServiceMain* service_main = nullptr;
+ if (plugin) {
+ service_ipc = plugin->get_service_ipc();
+ service_main = plugin->get_service_main();
+ }
+
+ if (service_ipc && service_main) {
+ int pid = service_main->mas_get_current_client_pid();
+ int preprocessing_pid = service_main->mas_get_current_preprocessing_client_pid();
+ if (pid == -1) {
+ MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
+ } else {
+ if (__validate_streaming_event_order(pid, &event)) {
+ int ret = service_ipc->send_streaming_audio_data(pid,
+ event, buffer, len);
if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to send speech data to preprocessing client, ret(%d)", ret);
+ MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
+ }
+ if (pid != preprocessing_pid && -1 != preprocessing_pid) {
+ int ret = service_ipc->send_streaming_audio_data(preprocessing_pid,
+ event, buffer, len);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to send speech data to preprocessing client, ret(%d)", ret);
+ }
}
}
}
}
-
#ifdef BUF_SAVE_MODE
/* write pcm buffer */
if (g_pFile)
static void __speech_status_cb(mas_speech_status_e status, void *user_data)
{
- MAS_LOGD( "[SUCCESS] __speech_status_cb is called, status(%d)", status);
+ MAS_LOGD("[SUCCESS] __speech_status_cb is called, status(%d)", status);
}
static void __error_cb(int error, const char* err_msg, void* user_data)
{
- MAS_LOGD( "[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
+ MAS_LOGD("[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
- if (is_ui_panel_enabled()) {
- int ret = masc_ui_dbus_send_error_message(error, err_msg);
+ CServiceIpcDbus* service_ipc = nullptr;
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ service_ipc = plugin->get_service_ipc();
+ }
+ if (plugin->is_ui_panel_enabled() && service_ipc) {
+ int ret = service_ipc->masc_ui_dbus_send_error_message(error, err_msg);
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to send error message, ret(%d)", ret);
}
static void __setting_changed_cb(void *user_data)
{
- mas_prelaunch_default_assistant();
- mas_update_voice_key_support_mode();
- MAS_LOGD( "[SUCCESS] __setting_changed_cb is called");
+ CServiceMain* service_main = nullptr;
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ service_main = plugin->get_service_main();
+ }
+ if (service_main) {
+ service_main->mas_prelaunch_default_assistant();
+ service_main->mas_update_voice_key_support_mode();
+ }
+ MAS_LOGD("[SUCCESS] __setting_changed_cb is called");
}
static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e section, void* user_data)
{
- MAS_LOGD( "[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
-
- int pid = mas_get_current_client_pid();
- int ret = masc_dbus_send_streaming_section_changed(pid, (int)section);
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret);
+ MAS_LOGD("[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
+
+ CServiceIpcDbus *service_ipc = nullptr;
+ CServiceMain* service_main = nullptr;
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ service_ipc = plugin->get_service_ipc();
+ service_main = plugin->get_service_main();
+ }
+ if (service_ipc && service_main) {
+ int pid = service_main->mas_get_current_client_pid();
+ int ret = service_ipc->send_streaming_section_changed(pid, (int)section);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret);
+ }
}
}
static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target, const char* assistant_name, const char* command, void* user_data)
{
- MAS_LOGD( "[SUCCESS] __wakeup_engine_command_cb is called, command(%s)", command);
-
- int pid = mas_get_client_pid_by_appid(assistant_name);
- if (-1 != pid) {
- int ret = masc_dbus_send_wakeup_engine_command(pid, command);
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to send wakeup engine command, ret(%d)", ret);
+ MAS_LOGD("[SUCCESS] __wakeup_engine_command_cb is called, command(%s)", command);
+
+ CServiceIpcDbus *service_ipc = nullptr;
+ CServiceMain* service_main = nullptr;
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ service_ipc = plugin->get_service_ipc();
+ service_main = plugin->get_service_main();
+ }
+ if (service_ipc && service_main) {
+ int pid = service_main->mas_get_client_pid_by_appid(assistant_name);
+ if (-1 != pid) {
+ int ret = service_ipc->send_wakeup_engine_command(pid, command);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to send wakeup engine command, ret(%d)", ret);
+ }
}
}
}
static void __wakeup_service_state_changed_cb(ma_service_state_e state, void* user_data)
{
- MAS_LOGD( "[SUCCESS] __wakeup_service_state_changed_cb is called, state(%d)", state);
+ MAS_LOGD("[SUCCESS] __wakeup_service_state_changed_cb is called, state(%d)", state);
- mas_set_current_service_state(state);
+ CServiceMain* service_main = nullptr;
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ service_main = plugin->get_service_main();
+ }
+ if (service_main) {
+ service_main->mas_set_current_service_state(state);
+ }
}
static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e status, void* user_data)
{
- MAS_LOGD( "[SUCCESS] __wakeup_service_voice_key_status_changed_cb is called, state(%d)", status);
-
- int pid = mas_get_current_client_pid();
- int ret = mas_client_send_voice_key_status_change(pid, status);
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
+ MAS_LOGD("[SUCCESS] __wakeup_service_voice_key_status_changed_cb is called, state(%d)", status);
+
+ CServiceIpcDbus *service_ipc = nullptr;
+ CServiceMain* service_main = nullptr;
+ CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
+ if (plugin) {
+ service_ipc = plugin->get_service_ipc();
+ service_main = plugin->get_service_main();
+ }
+ if (service_ipc && service_main) {
+ int pid = service_main->mas_get_current_client_pid();
+ int ret = service_ipc->voice_key_status_change(pid, status);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
+ }
}
}
-int multi_assistant_service_plugin_initialize(void)
+int CServicePlugin::initialize(void)
{
- MAS_LOGD( "[Enter]");
+ MAS_LOGD("[Enter]");
- char filepath[512] = {'\0',};
+ char filepath[512] = {'\0', };
const char *default_engine_path = MA_WAKEUP_MANAGER_PATH;
snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME);
return ret;
}
-int multi_assistant_service_plugin_deinitialize(void)
+int CServicePlugin::deinitialize(void)
{
#ifdef BUF_SAVE_MODE
if (g_pFile) {
return ret;
}
-int multi_assistant_service_plugin_get_settings(ma_plugin_settings **settings, size_t *struct_size)
+int CServicePlugin::get_settings(ma_plugin_settings **settings, size_t *struct_size)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_language(const char* language)
+int CServicePlugin::set_language(const char* language)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
+int CServicePlugin::add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
+int CServicePlugin::remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_add_assistant_language(const char* appid, const char* language)
+int CServicePlugin::add_assistant_language(const char* appid, const char* language)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_assistant_wakeup_engine(const char* appid, const char* engine)
+int CServicePlugin::set_assistant_wakeup_engine(const char* appid, const char* engine)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_default_assistant(const char* appid)
+int CServicePlugin::set_default_assistant(const char* appid)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_get_default_assistant(const char** appid)
+int CServicePlugin::get_default_assistant(const char** appid)
{
int ret = -1;
if (NULL == appid) {
return ret;
}
-int multi_assistant_service_plugin_activate(void)
+int CServicePlugin::activate(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_deactivate(void)
+int CServicePlugin::deactivate(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_update_voice_feedback_state(const char* appid, int state)
+int CServicePlugin::update_voice_feedback_state(const char* appid, int state)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_assistant_specific_command(const char* appid, const char* command)
+int CServicePlugin::set_assistant_specific_command(const char* appid, const char* command)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_background_volume(const char* appid, double ratio)
+int CServicePlugin::set_background_volume(const char* appid, double ratio)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_update_recognition_result(const char* appid, int state)
+int CServicePlugin::update_recognition_result(const char* appid, int state)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_process_event(int event, void *data, int len)
+int CServicePlugin::process_event(int event, void *data, int len)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_start_streaming_utterance_data(void)
+int CServicePlugin::start_streaming_utterance_data(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_stop_streaming_utterance_data(void)
+int CServicePlugin::stop_streaming_utterance_data(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_start_streaming_previous_utterance_data(void)
+int CServicePlugin::start_streaming_previous_utterance_data(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_stop_streaming_previous_utterance_data(void)
+int CServicePlugin::stop_streaming_previous_utterance_data(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_start_streaming_follow_up_data(void)
+int CServicePlugin::start_streaming_follow_up_data(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_stop_streaming_follow_up_data(void)
+int CServicePlugin::stop_streaming_follow_up_data(void)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_get_recording_audio_format(int *rate, int *channel, int *audio_type)
+int CServicePlugin::get_recording_audio_format(int *rate, int *channel, int *audio_type)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_get_recording_audio_source_type(char** type)
+int CServicePlugin::get_recording_audio_source_type(char** type)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_voice_key_tap_duration(float duration)
+int CServicePlugin::set_voice_key_tap_duration(float duration)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_unset_voice_key_tap_duration()
+int CServicePlugin::unset_voice_key_tap_duration()
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_voice_key_support_mode(int mode)
+int CServicePlugin::set_voice_key_support_mode(int mode)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_wake_word_audio_require_flag(const char* appid, bool require)
+int CServicePlugin::set_wake_word_audio_require_flag(const char* appid, bool require)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_assistant_language(const char* appid, const char* language)
+int CServicePlugin::set_assistant_language(const char* appid, const char* language)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_callbacks(void)
+int CServicePlugin::set_callbacks(void)
{
- int ret = multi_assistant_service_plugin_set_wakeup_event_callback(__wakeup_event_cb, NULL);
+ int ret = set_wakeup_event_callback(__wakeup_event_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set wakeup event cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_utterance_streaming_callback(__audio_streaming_cb, NULL);
+ ret = set_utterance_streaming_callback(__audio_streaming_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set utterance streaming cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_previous_utterance_streaming_callback(__audio_streaming_cb, NULL);
+ ret = set_previous_utterance_streaming_callback(__audio_streaming_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set previous utterance streaming cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_follow_up_streaming_callback(__audio_streaming_cb, NULL);
+ ret = set_follow_up_streaming_callback(__audio_streaming_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set follow-up streaming cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_speech_status_callback(__speech_status_cb, NULL);
+ ret = set_speech_status_callback(__speech_status_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set speech status changed cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_setting_changed_callback(__setting_changed_cb, NULL);
+ ret = set_setting_changed_callback(__setting_changed_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set setting changed cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_error_callback(__error_cb, NULL);
+ ret = set_error_callback(__error_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set error cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_streaming_section_changed_callback(__streaming_section_changed_cb, NULL);
+ ret = set_streaming_section_changed_callback(__streaming_section_changed_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set streaming section changed cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_wakeup_engine_command_callback(__wakeup_engine_command_cb, NULL);
+ ret = set_wakeup_engine_command_callback(__wakeup_engine_command_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set wakeup engine command cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_wakeup_service_state_changed_callback(__wakeup_service_state_changed_cb, NULL);
+ ret = set_wakeup_service_state_changed_callback(__wakeup_service_state_changed_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set wakeup engine command cb");
return ret;
}
- ret = multi_assistant_service_plugin_set_voice_key_status_changed_callback(__wakeup_service_voice_key_status_changed_cb, NULL);
+ ret = set_voice_key_status_changed_callback(__wakeup_service_voice_key_status_changed_cb, this);
if (0 != ret) {
MAS_LOGE("Fail to set wakeup engine command cb");
return ret;
return 0;
}
-int multi_assistant_service_plugin_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
+int CServicePlugin::set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
} else {
ret = func(callback, user_data);
+ MAS_LOGD("dalton debug : %p", user_data);
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to set wakeup event callback, ret(%d)", ret);
}
return ret;
}
-int multi_assistant_service_plugin_set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
+int CServicePlugin::set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
+int CServicePlugin::set_previous_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
+int CServicePlugin::set_follow_up_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
+int CServicePlugin::set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data)
+int CServicePlugin::set_setting_changed_callback(wakeup_service_setting_changed_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb callback, void* user_data)
+int CServicePlugin::set_error_callback(wakeup_service_error_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
+int CServicePlugin::set_streaming_section_changed_callback(wakeup_service_streaming_section_changed_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data)
+int CServicePlugin::set_wakeup_engine_command_callback(wakeup_service_wakeup_engine_command_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data)
+int CServicePlugin::set_wakeup_service_state_changed_callback(wakeup_service_wakeup_service_state_changed_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
return ret;
}
-int multi_assistant_service_plugin_set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data)
+int CServicePlugin::set_voice_key_status_changed_callback(wakeup_service_voice_key_status_changed_cb callback, void* user_data)
{
int ret = -1;
if (NULL != g_handle) {
SET(TEST_SOURCES
test_config.cpp
- ${CMAKE_SOURCE_DIR}/src/multi_assistant_config.cpp
+ ${CMAKE_SOURCE_DIR}/src/service_config.cpp
)
# Find Packages
#include <gtest/gtest.h>
-#include "multi_assistant_config.h"
+#include "service_config.h"
#include <string>
}
void TearDown() override {
}
- CConfig config;
+ CServiceConfig config;
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
};
memset(wakeup_word_storage, 0x0, sizeof(wakeup_word_storage));
memset(wakeup_language_storage, 0x0, sizeof(wakeup_language_storage));
- config.mas_config_add_custom_wake_word(
+ config.add_custom_wake_word(
preloaded_wake_word.c_str(), preloaded_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
}
const std::string preloaded_wake_word{"Hi Preloaded"};
const std::string preloaded_language{"pr_LD"};
- CConfig config;
+ CServiceConfig config;
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
};
const std::string arbitrary_wake_word{"Hi Tizen"};
const std::string arbitrary_language{"ar_LA"};
- config.mas_config_add_custom_wake_word(
+ config.add_custom_wake_word(
arbitrary_wake_word.c_str(), arbitrary_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- int wake_word_num = config.mas_config_get_custom_wake_word_num(
+ int wake_word_num = config.get_custom_wake_word_num(
wakeup_word_storage, wakeup_language_storage);
ASSERT_EQ(wake_word_num, 1);
}
const std::string arbitrary_wake_word{"Hi Tizen"};
const std::string arbitrary_language1{"ar_LA1"};
const std::string arbitrary_language2{"ar_LA2"};
- config.mas_config_add_custom_wake_word(
+ config.add_custom_wake_word(
arbitrary_wake_word.c_str(), arbitrary_language1.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- config.mas_config_add_custom_wake_word(
+ config.add_custom_wake_word(
arbitrary_wake_word.c_str(), arbitrary_language2.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- int wake_word_num = config.mas_config_get_custom_wake_word_num(
+ int wake_word_num = config.get_custom_wake_word_num(
wakeup_word_storage, wakeup_language_storage);
ASSERT_EQ(wake_word_num, 2);
}
const std::string arbitrary_wake_word{"Hi Tizen"};
const std::string arbitrary_language{"ar_LA"};
- int ret = config.mas_config_remove_custom_wake_word(
+ int ret = config.remove_custom_wake_word(
arbitrary_wake_word.c_str(), arbitrary_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
}
TEST_F(StorageWithAnArbitraryWakeWord, StillHasOneWakeWordAfterDuplicatedAdd) {
- config.mas_config_add_custom_wake_word(
+ config.add_custom_wake_word(
preloaded_wake_word.c_str(), preloaded_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- int wake_word_num = config.mas_config_get_custom_wake_word_num(
+ int wake_word_num = config.get_custom_wake_word_num(
wakeup_word_storage, wakeup_language_storage);
ASSERT_EQ(wake_word_num, 1);
}
TEST_F(StorageWithAnArbitraryWakeWord, HasZeroWakeWordAfterRemoval) {
- config.mas_config_remove_custom_wake_word(
+ config.remove_custom_wake_word(
preloaded_wake_word.c_str(), preloaded_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- int wake_word_num = config.mas_config_get_custom_wake_word_num(
+ int wake_word_num = config.get_custom_wake_word_num(
wakeup_word_storage, wakeup_language_storage);
ASSERT_EQ(wake_word_num, 0);
}
TEST_F(StorageWithAnArbitraryWakeWord, RemovesItemRequestedForRemoval) {
const std::string arbitrary_wake_word{"Hi Tizen"};
const std::string arbitrary_language{"ar_LA"};
- config.mas_config_add_custom_wake_word(
+ config.add_custom_wake_word(
arbitrary_wake_word.c_str(), arbitrary_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- config.mas_config_remove_custom_wake_word(
+ config.remove_custom_wake_word(
preloaded_wake_word.c_str(), preloaded_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- bool exists = config.mas_config_has_custom_wake_word(
+ bool exists = config.has_custom_wake_word(
preloaded_wake_word.c_str(), preloaded_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
TEST_F(StorageWithAnArbitraryWakeWord, PreservesItemNotRequestedForRemoval) {
const std::string arbitrary_wake_word{"Hi Tizen"};
const std::string arbitrary_language{"ar_LA"};
- config.mas_config_add_custom_wake_word(
+ config.add_custom_wake_word(
arbitrary_wake_word.c_str(), arbitrary_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- config.mas_config_remove_custom_wake_word(
+ config.remove_custom_wake_word(
preloaded_wake_word.c_str(), preloaded_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);
- bool exists = config.mas_config_has_custom_wake_word(
+ bool exists = config.has_custom_wake_word(
arbitrary_wake_word.c_str(), arbitrary_language.c_str(),
wakeup_word_storage,
wakeup_language_storage);