Encapsulate functions and data into classes 49/226049/5
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 19 Feb 2020 11:30:48 +0000 (20:30 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 6 Apr 2020 04:03:32 +0000 (13:03 +0900)
Change-Id: I03489e7713649cb20f54eac0f968bdf96c5ad786

22 files changed:
CMakeLists.txt
inc/multi_assistant_service_client.h [deleted file]
inc/multi_wakeup_recognizer.h [deleted file]
inc/service_common.h [moved from inc/multi_assistant_main.h with 77% similarity]
inc/service_config.h [moved from inc/multi_assistant_config.h with 75% similarity]
inc/service_ipc_dbus.h [new file with mode: 0644]
inc/service_ipc_dbus_dispatcher.h [new file with mode: 0644]
inc/service_main.h [new file with mode: 0644]
inc/service_plugin.h [new file with mode: 0644]
inc/service_plugin_interface.h [moved from inc/multi_assistant_service_plugin.h with 72% similarity]
plugins/wakeup-manager/inc/wakeup_manager.h
plugins/wakeup-manager/src/dependency_resolver.cpp
src/main.cpp
src/multi_assistant_dbus.h [deleted file]
src/multi_assistant_dbus_server.h [deleted file]
src/service_config.cpp [moved from src/multi_assistant_config.cpp with 94% similarity]
src/service_ipc_dbus.cpp [moved from src/multi_assistant_dbus.cpp with 87% similarity]
src/service_ipc_dbus_dispatcher.cpp [moved from src/multi_assistant_dbus_server.cpp with 77% similarity]
src/service_main.cpp [moved from src/multi_assistant_service.cpp with 76% similarity]
src/service_plugin.cpp [moved from src/multi_assistant_service_plugin.cpp with 74% similarity]
tests/utc/config/CMakeLists.txt
tests/utc/config/test_config.cpp

index f92c5fb..aca1239 100644 (file)
@@ -63,11 +63,11 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
 
 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})
 
diff --git a/inc/multi_assistant_service_client.h b/inc/multi_assistant_service_client.h
deleted file mode 100644 (file)
index 9127e3a..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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_ */
diff --git a/inc/multi_wakeup_recognizer.h b/inc/multi_wakeup_recognizer.h
deleted file mode 100644 (file)
index d5f8fb0..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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_ */
similarity index 77%
rename from inc/multi_assistant_main.h
rename to inc/service_common.h
index 643d75b..ca86cc8 100644 (file)
@@ -1,9 +1,11 @@
-#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__ */
similarity index 75%
rename from inc/multi_assistant_config.h
rename to inc/service_config.h
index a84c54d..18fccbc 100644 (file)
  */
 
 
-#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"
 {
@@ -57,18 +59,6 @@ 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;
@@ -84,35 +74,35 @@ typedef struct {
        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);
 };
 
@@ -124,4 +114,4 @@ private:
  * @}
  */
 
-#endif /* __MULTI_ASSISTANT_CONFIG_H__ */
+#endif /* __SERVICE_CONFIG_H__ */
diff --git a/inc/service_ipc_dbus.h b/inc/service_ipc_dbus.h
new file mode 100644 (file)
index 0000000..7242f12
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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__ */
diff --git a/inc/service_ipc_dbus_dispatcher.h b/inc/service_ipc_dbus_dispatcher.h
new file mode 100644 (file)
index 0000000..45d06fe
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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__ */
diff --git a/inc/service_main.h b/inc/service_main.h
new file mode 100644 (file)
index 0000000..61e4853
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * 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__ */
diff --git a/inc/service_plugin.h b/inc/service_plugin.h
new file mode 100644 (file)
index 0000000..b4d9da8
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * 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__ */
similarity index 72%
rename from inc/multi_assistant_service_plugin.h
rename to inc/service_plugin_interface.h
index a8efc61..5d622d4 100644 (file)
  */
 
 
-#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" {
@@ -34,98 +29,10 @@ typedef struct {
        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"
@@ -257,4 +164,4 @@ typedef struct {
 }
 #endif
 
-#endif /* _MULTI_ASSISTANT_SERVICE_PLUGIN_H_ */
+#endif /* __SERVICE_PLUGIN_INTERFACE_H__ */
index 8b52f89..3b6a00b 100644 (file)
@@ -18,7 +18,7 @@
 #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"
index 3b2ef19..7ebd3d6 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <stdexcept>
 
-#include "multi_assistant_main.h"
+#include "service_common.h"
 #include "dependency_resolver.h"
 
 #ifdef LOG_TAG
index 6422575..951d933 100644 (file)
 #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)
@@ -59,7 +60,7 @@ static void service_app_low_memory(app_event_info_h event_info, void *user_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, };
 
diff --git a/src/multi_assistant_dbus.h b/src/multi_assistant_dbus.h
deleted file mode 100644 (file)
index 6d20348..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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__ */
diff --git a/src/multi_assistant_dbus_server.h b/src/multi_assistant_dbus_server.h
deleted file mode 100644 (file)
index 24d1759..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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__ */
similarity index 94%
rename from src/multi_assistant_config.cpp
rename to src/service_config.cpp
index f636d01..44c4eaa 100644 (file)
 
 #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;
@@ -217,7 +217,7 @@ int CConfig::mas_config_parse_assistant_info(mas_config_assistant_info_cb callba
        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";
 
@@ -232,7 +232,7 @@ int CConfig::mas_config_get_assistant_info(mas_config_assistant_info_cb callback
                                        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);
                                }
                        }
                }
@@ -242,7 +242,7 @@ int CConfig::mas_config_get_assistant_info(mas_config_assistant_info_cb callback
        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])
 {
@@ -270,7 +270,7 @@ int CConfig::mas_config_add_custom_wake_word(const char* wake_word, const char*
        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])
 {
@@ -301,7 +301,7 @@ int CConfig::mas_config_remove_custom_wake_word(const char* wake_word, const cha
        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])
 {
@@ -356,7 +356,7 @@ int CConfig::mas_config_load_custom_wake_words(const char* app_id,
        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])
 {
@@ -384,7 +384,7 @@ int CConfig::mas_config_save_custom_wake_words(const char* app_id,
        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])
 {
@@ -397,7 +397,7 @@ int CConfig::mas_config_get_custom_wake_word_num(
        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])
 {
similarity index 87%
rename from src/multi_assistant_dbus.cpp
rename to src/service_ipc_dbus.cpp
index 4f04de3..1a7558b 100644 (file)
  * 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;
                }
@@ -52,9 +43,9 @@ int mas_dbus_reconnect()
                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;
                }
@@ -65,16 +56,16 @@ int mas_dbus_reconnect()
        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);
@@ -83,7 +74,7 @@ int mas_check_dbus_connection()
        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;
@@ -125,7 +116,7 @@ int masc_dbus_send_hello(int pid)
        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;
@@ -201,7 +192,7 @@ typedef struct {
        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" :
@@ -215,8 +206,13 @@ void masc_message_port_error(int error)
                "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;
 
@@ -249,7 +245,7 @@ int masc_dbus_send_streaming_audio_data(int pid, int event, void* data, unsigned
                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);
 
@@ -270,7 +266,7 @@ int masc_dbus_send_streaming_audio_data(int pid, int event, void* data, unsigned
                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);
 
@@ -285,7 +281,7 @@ int masc_dbus_send_streaming_audio_data(int pid, int event, void* data, unsigned
        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;
@@ -335,7 +331,7 @@ int masc_dbus_active_state_change(int pid, int state)
        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;
@@ -399,8 +395,13 @@ int masc_dbus_send_preprocessing_information(int pid, const char* app_id)
        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;
@@ -419,7 +420,7 @@ int masc_dbus_send_streaming_section_changed(int pid, int section)
        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);
 
@@ -428,7 +429,7 @@ int masc_dbus_send_streaming_section_changed(int pid, int section)
        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;
@@ -481,7 +482,7 @@ int masc_dbus_send_preprocessing_result(int pid, bool result)
        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;
@@ -545,7 +546,7 @@ int masc_dbus_send_wakeup_engine_command(int pid, const char* command)
        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;
@@ -595,7 +596,7 @@ int masc_dbus_service_state_change(int pid, int state)
        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;
@@ -645,7 +646,7 @@ int masc_dbus_voice_key_status_change(int pid, int status)
        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;
@@ -689,7 +690,7 @@ int masc_ui_dbus_send_hello(void)
        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;
@@ -743,7 +744,7 @@ int masc_ui_dbus_send_asr_result(int pid, int event, char* asr_result)
        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;
@@ -835,7 +836,7 @@ int masc_ui_dbus_send_result(int pid, const char* display_text, const char* utte
        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;
@@ -875,7 +876,7 @@ int masc_ui_dbus_change_assistant(const char* app_id)
        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");
@@ -923,7 +924,7 @@ int masc_ui_dbus_send_error_message(int reason, const char* err_msg)
        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;
@@ -964,7 +965,7 @@ int masc_ui_dbus_send_recognition_result(int pid, int result)
        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;
@@ -1006,7 +1007,23 @@ int masc_ui_dbus_enable_common_ui(int enable)
 
 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);
 
@@ -1026,70 +1043,70 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
 
                /* 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");
@@ -1102,7 +1119,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
        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);
@@ -1116,7 +1133,7 @@ static void __mas_dbus_connection_free()
        }
 }
 
-int mas_dbus_open_connection()
+int CServiceIpcDbus::open_connection()
 {
        DBusError err;
        dbus_error_init(&err);
@@ -1148,7 +1165,7 @@ int mas_dbus_open_connection()
 
        if (NULL == g_conn_listener) {
                MAS_LOGE("[Dbus ERROR] Fail to get dbus connection");
-               __mas_dbus_connection_free();
+               connection_free();
                return -1;
        }
 
@@ -1160,20 +1177,20 @@ int mas_dbus_open_connection()
        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 */
@@ -1186,31 +1203,31 @@ int mas_dbus_open_connection()
        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);
@@ -1227,7 +1244,7 @@ int mas_dbus_close_connection()
                dbus_error_free(&err);
        }
 
-       __mas_dbus_connection_free();
+       connection_free();
 
        return 0;
 }
\ No newline at end of file
similarity index 77%
rename from src/multi_assistant_dbus_server.cpp
rename to src/service_ipc_dbus_dispatcher.cpp
index ae97bd2..76d40b0 100644 (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");
 
@@ -45,8 +44,13 @@ int ma_service_dbus_hello(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -65,7 +69,7 @@ int ma_service_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
                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;
@@ -96,8 +100,13 @@ int ma_service_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -116,7 +125,7 @@ int ma_service_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
                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;
@@ -147,8 +156,13 @@ int ma_service_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -168,7 +182,7 @@ int ma_service_dbus_get_audio_format(DBusConnection* conn, DBusMessage* msg)
                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;
@@ -201,8 +215,13 @@ int ma_service_dbus_get_audio_format(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -222,7 +241,7 @@ int ma_service_dbus_get_audio_source_type(DBusConnection* conn, DBusMessage* msg
                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;
@@ -263,8 +282,13 @@ int ma_service_dbus_get_audio_source_type(DBusConnection* conn, DBusMessage* msg
        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);
 
@@ -286,7 +310,7 @@ int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg)
                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;
@@ -319,8 +343,13 @@ int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -345,7 +374,7 @@ int ma_service_dbus_send_result(DBusConnection* conn, DBusMessage* msg)
                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;
@@ -378,8 +407,13 @@ int ma_service_dbus_send_result(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -400,7 +434,7 @@ int ma_service_dbus_send_recognition_result(DBusConnection* conn, DBusMessage* m
                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("<<<<<");
@@ -409,8 +443,13 @@ int ma_service_dbus_send_recognition_result(DBusConnection* conn, DBusMessage* m
        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);
 
@@ -431,7 +470,7 @@ int ma_service_dbus_start_streaming_audio_data(DBusConnection* conn, DBusMessage
                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("<<<<<");
@@ -440,8 +479,13 @@ int ma_service_dbus_start_streaming_audio_data(DBusConnection* conn, DBusMessage
        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);
 
@@ -462,7 +506,7 @@ int ma_service_dbus_stop_streaming_audio_data(DBusConnection* conn, DBusMessage*
                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("<<<<<");
@@ -471,8 +515,13 @@ int ma_service_dbus_stop_streaming_audio_data(DBusConnection* conn, DBusMessage*
        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);
 
@@ -493,7 +542,7 @@ int ma_service_dbus_update_voice_feedback_state(DBusConnection* conn, DBusMessag
                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("<<<<<");
@@ -502,8 +551,13 @@ int ma_service_dbus_update_voice_feedback_state(DBusConnection* conn, DBusMessag
        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);
 
@@ -524,7 +578,7 @@ int ma_service_dbus_send_assistant_specific_command(DBusConnection* conn, DBusMe
                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("<<<<<");
@@ -533,8 +587,13 @@ int ma_service_dbus_send_assistant_specific_command(DBusConnection* conn, DBusMe
        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);
 
@@ -555,7 +614,7 @@ int ma_service_dbus_set_background_volume(DBusConnection* conn, DBusMessage* msg
                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("<<<<<");
@@ -564,8 +623,13 @@ int ma_service_dbus_set_background_volume(DBusConnection* conn, DBusMessage* msg
        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);
 
@@ -592,7 +656,7 @@ int ma_service_dbus_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessa
                        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);
@@ -604,8 +668,13 @@ int ma_service_dbus_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessa
        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);
 
@@ -626,7 +695,7 @@ int ma_service_dbus_send_preprocessing_result(DBusConnection* conn, DBusMessage*
                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("<<<<<");
@@ -635,8 +704,13 @@ int ma_service_dbus_send_preprocessing_result(DBusConnection* conn, DBusMessage*
        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);
 
@@ -657,7 +731,7 @@ int ma_service_dbus_set_wake_word_audio_require_flag(DBusConnection* conn, DBusM
                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("<<<<<");
@@ -666,8 +740,13 @@ int ma_service_dbus_set_wake_word_audio_require_flag(DBusConnection* conn, DBusM
        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);
 
@@ -688,7 +767,7 @@ int ma_service_dbus_set_assistant_language(DBusConnection* conn, DBusMessage* ms
                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("<<<<<");
@@ -697,8 +776,13 @@ int ma_service_dbus_set_assistant_language(DBusConnection* conn, DBusMessage* ms
        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);
 
@@ -721,7 +805,7 @@ int ma_service_dbus_add_wake_word(DBusConnection* conn, DBusMessage* msg)
                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("<<<<<");
@@ -730,8 +814,12 @@ int ma_service_dbus_add_wake_word(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -754,7 +842,7 @@ int ma_service_dbus_remove_wake_word(DBusConnection* conn, DBusMessage* msg)
                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("<<<<<");
@@ -763,8 +851,13 @@ int ma_service_dbus_remove_wake_word(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -783,7 +876,7 @@ int ma_service_ui_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
                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;
@@ -814,8 +907,13 @@ int ma_service_ui_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -834,7 +932,7 @@ int ma_service_ui_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
                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;
@@ -865,8 +963,13 @@ int ma_service_ui_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
        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);
 
@@ -885,7 +988,7 @@ int ma_service_ui_dbus_change_assistant(DBusConnection* conn, DBusMessage* msg)
                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;
similarity index 76%
rename from src/multi_assistant_service.cpp
rename to src/service_main.cpp
index 56f5ed3..54c2368 100644 (file)
@@ -23,7 +23,6 @@
 #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
@@ -102,7 +59,7 @@ int ma_client_create(ma_client_s *info)
        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
@@ -117,7 +74,7 @@ int ma_client_destroy(ma_client_s *client)
        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
@@ -144,7 +101,7 @@ ma_client_s* ma_client_find_by_appid(const char *appid)
        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;
 
@@ -166,7 +123,7 @@ ma_client_s* ma_client_find_by_pid(int pid)
        return NULL;
 }
 
-bool check_preprocessing_assistant_exists()
+bool CServiceMain::check_preprocessing_assistant_exists()
 {
        bool ret = false;
 
@@ -191,7 +148,7 @@ bool check_preprocessing_assistant_exists()
        return ret;
 }
 
-bool is_current_preprocessing_assistant(const char* appid)
+bool CServiceMain::is_current_preprocessing_assistant(const char* appid)
 {
        if (NULL == appid) return false;
 
@@ -209,11 +166,11 @@ bool is_current_preprocessing_assistant(const char* appid)
        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';
 
@@ -246,25 +203,25 @@ int mas_client_initialize(int pid)
                }
 
                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");
        }
@@ -272,7 +229,7 @@ int mas_client_initialize(int pid)
        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);
@@ -283,11 +240,11 @@ int mas_client_deinitialize(int 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);
        }
@@ -296,14 +253,14 @@ int mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_typ
 }
 
 #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;
@@ -315,7 +272,7 @@ int mas_client_get_audio_source_type(int pid, char** type)
        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);
@@ -323,7 +280,7 @@ int mas_client_send_preprocessing_information(int 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;
        }
@@ -331,40 +288,44 @@ int mas_client_send_preprocessing_information(int pid)
        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);
        }
@@ -374,121 +335,121 @@ int mas_client_send_asr_result(int pid, int event, char* asr_result)
        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;
@@ -513,10 +474,10 @@ int mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode
        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;
@@ -538,43 +499,43 @@ int mas_client_send_preprocessing_result(int pid, bool result)
 
        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';
@@ -584,11 +545,11 @@ int mas_client_add_wake_word(int pid, const char* wake_word, const char* languag
        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 {
@@ -598,14 +559,14 @@ int mas_client_add_wake_word(int pid, const char* wake_word, const char* languag
                }
        }
 
-       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';
@@ -615,36 +576,36 @@ int mas_client_remove_wake_word(int pid, const char* wake_word, const char* lang
        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]");
 
@@ -654,21 +615,21 @@ int mas_ui_client_change_assistant(const char* appid)
        }
 
        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);
                }
@@ -692,7 +653,16 @@ int mas_ui_client_change_assistant(const char* appid)
        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) {
@@ -773,41 +743,49 @@ int __mas_assistant_info_cb(ma_assistant_info_s* info, void* user_data) {
        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);
                                }
@@ -815,7 +793,7 @@ static int init_plugin(void)
                                        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])) {
@@ -827,7 +805,7 @@ static int init_plugin(void)
                                        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");
@@ -840,7 +818,7 @@ static int init_plugin(void)
                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;
        }
@@ -848,35 +826,35 @@ static int init_plugin(void)
        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");
                                }
@@ -887,56 +865,7 @@ static int process_activated_setting()
        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) {
@@ -949,7 +878,7 @@ int mas_get_current_client_pid()
        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) {
@@ -962,7 +891,7 @@ int mas_get_current_preprocessing_client_pid()
        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;
 
@@ -985,7 +914,7 @@ int mas_get_client_pid_by_appid(const char *appid)
        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;
 
@@ -1006,7 +935,7 @@ const char* mas_get_client_appid_by_pid(int pid)
        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++) {
@@ -1021,13 +950,13 @@ bool mas_get_client_custom_ui_option_by_appid(const char *appid)
        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;
@@ -1073,7 +1002,7 @@ const char* mas_get_client_appid_by_wakeup_word(const char *wakeup_word)
        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;
@@ -1125,7 +1054,7 @@ int mas_set_current_client_by_wakeup_word(const char *wakeup_word)
        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;
@@ -1150,7 +1079,7 @@ int mas_set_current_client_by_appid(const char *appid)
        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");
@@ -1195,7 +1124,7 @@ int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode
                                }
                        }
                }
-               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);
@@ -1204,7 +1133,7 @@ int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode
        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)) {
@@ -1231,20 +1160,20 @@ int mas_bring_client_to_foreground(const char* 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);
@@ -1254,23 +1183,23 @@ int mas_prelaunch_default_assistant()
        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;
                                }
@@ -1279,13 +1208,13 @@ int mas_update_voice_key_support_mode()
        }
 
        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) {
@@ -1300,7 +1229,7 @@ ma_preprocessing_allow_mode_e get_preprocessing_allow_mode(const char* appid)
 /* 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;
@@ -1408,7 +1337,7 @@ int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event)
        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;
 
@@ -1421,7 +1350,7 @@ int mas_set_current_service_state(ma_service_state_e 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);
@@ -1431,31 +1360,41 @@ int mas_set_current_service_state(ma_service_state_e state)
        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;
@@ -1482,8 +1421,10 @@ Update package (change the source codes and Run As again), there are four scenar
 */
 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;
@@ -1501,16 +1442,16 @@ static void _package_manager_event_cb(const char *type, const char *package, pac
                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;
                }
        }
@@ -1524,16 +1465,32 @@ static void _package_manager_event_cb(const char *type, const char *package, pac
        }
        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;
                }
@@ -1549,29 +1506,50 @@ static void _package_manager_event_cb(const char *type, const char *package, pac
        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);
                }
        }
@@ -1579,7 +1557,7 @@ bool app_create(void *data)
        return true;
 }
 
-void app_terminate(void *data)
+void CServiceMain::app_terminate(void *data)
 {
        MAS_LOGI("[ENTER]");
        if (g_pkgmgr) {
@@ -1588,8 +1566,17 @@ void app_terminate(void *data)
                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;
 }
similarity index 74%
rename from src/multi_assistant_service_plugin.cpp
rename to src/service_plugin.cpp
index a9f41bd..7f1b4ef 100644 (file)
 #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;
@@ -93,45 +84,81 @@ Eina_Bool __send_result(void *data)
 }
 #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);
 
@@ -139,19 +166,24 @@ Eina_Bool process_wakeup_event_by_word_timer(void* data)
        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;
+                               }
                        }
                }
        }
@@ -208,17 +240,26 @@ static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, const char* wak
        }
 #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)
@@ -230,7 +271,7 @@ static bool __validate_streaming_event_order(int pid, mas_speech_streaming_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},
@@ -273,12 +314,23 @@ static bool __validate_streaming_event_order(int pid, mas_speech_streaming_event
        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);
@@ -286,29 +338,41 @@ static void __audio_streaming_cb(mas_speech_streaming_event_e event, unsigned ch
        }
        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)
@@ -328,15 +392,20 @@ static void __audio_streaming_cb(mas_speech_streaming_event_e event, unsigned ch
 
 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);
                }
@@ -345,58 +414,99 @@ static void __error_cb(int error, const char* err_msg, void* user_data)
 
 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);
 
@@ -563,7 +673,7 @@ int multi_assistant_service_plugin_initialize(void)
        return ret;
 }
 
-int multi_assistant_service_plugin_deinitialize(void)
+int CServicePlugin::deinitialize(void)
 {
 #ifdef BUF_SAVE_MODE
        if (g_pFile) {
@@ -595,7 +705,7 @@ int multi_assistant_service_plugin_deinitialize(void)
        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) {
@@ -614,7 +724,7 @@ int multi_assistant_service_plugin_get_settings(ma_plugin_settings **settings, s
        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) {
@@ -633,7 +743,7 @@ int multi_assistant_service_plugin_set_language(const char* language)
        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) {
@@ -652,7 +762,7 @@ int multi_assistant_service_plugin_add_assistant_wakeup_word(const char* appid,
        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) {
@@ -671,7 +781,7 @@ int multi_assistant_service_plugin_remove_assistant_wakeup_word(const char* appi
        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) {
@@ -690,7 +800,7 @@ int multi_assistant_service_plugin_add_assistant_language(const char* appid, con
        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) {
@@ -709,7 +819,7 @@ int multi_assistant_service_plugin_set_assistant_wakeup_engine(const char* appid
        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) {
@@ -728,7 +838,7 @@ int multi_assistant_service_plugin_set_default_assistant(const char* appid)
        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) {
@@ -751,7 +861,7 @@ int multi_assistant_service_plugin_get_default_assistant(const char** appid)
        return ret;
 }
 
-int multi_assistant_service_plugin_activate(void)
+int CServicePlugin::activate(void)
 {
        int ret = -1;
        if (NULL != g_handle) {
@@ -770,7 +880,7 @@ int multi_assistant_service_plugin_activate(void)
        return ret;
 }
 
-int multi_assistant_service_plugin_deactivate(void)
+int CServicePlugin::deactivate(void)
 {
        int ret = -1;
        if (NULL != g_handle) {
@@ -789,7 +899,7 @@ int multi_assistant_service_plugin_deactivate(void)
        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) {
@@ -808,7 +918,7 @@ int multi_assistant_service_plugin_update_voice_feedback_state(const char* appid
        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) {
@@ -827,7 +937,7 @@ int multi_assistant_service_plugin_set_assistant_specific_command(const char* ap
        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) {
@@ -846,7 +956,7 @@ int multi_assistant_service_plugin_set_background_volume(const char* appid, doub
        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) {
@@ -865,7 +975,7 @@ int multi_assistant_service_plugin_update_recognition_result(const char* appid,
        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) {
@@ -884,7 +994,7 @@ int multi_assistant_service_plugin_process_event(int event, void *data, int len)
        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) {
@@ -903,7 +1013,7 @@ int multi_assistant_service_plugin_start_streaming_utterance_data(void)
        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) {
@@ -922,7 +1032,7 @@ int multi_assistant_service_plugin_stop_streaming_utterance_data(void)
        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) {
@@ -941,7 +1051,7 @@ int multi_assistant_service_plugin_start_streaming_previous_utterance_data(void)
        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) {
@@ -960,7 +1070,7 @@ int multi_assistant_service_plugin_stop_streaming_previous_utterance_data(void)
        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) {
@@ -979,7 +1089,7 @@ int multi_assistant_service_plugin_start_streaming_follow_up_data(void)
        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) {
@@ -998,7 +1108,7 @@ int multi_assistant_service_plugin_stop_streaming_follow_up_data(void)
        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) {
@@ -1017,7 +1127,7 @@ int multi_assistant_service_plugin_get_recording_audio_format(int *rate, int *ch
        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) {
@@ -1036,7 +1146,7 @@ int multi_assistant_service_plugin_get_recording_audio_source_type(char** type)
        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) {
@@ -1055,7 +1165,7 @@ int multi_assistant_service_plugin_set_voice_key_tap_duration(float duration)
        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) {
@@ -1074,7 +1184,7 @@ int multi_assistant_service_plugin_unset_voice_key_tap_duration()
        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) {
@@ -1093,7 +1203,7 @@ int multi_assistant_service_plugin_set_voice_key_support_mode(int mode)
        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) {
@@ -1112,7 +1222,7 @@ int multi_assistant_service_plugin_set_wake_word_audio_require_flag(const char*
        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) {
@@ -1131,69 +1241,69 @@ int multi_assistant_service_plugin_set_assistant_language(const char* appid, con
        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;
@@ -1202,7 +1312,7 @@ int multi_assistant_service_plugin_set_callbacks(void)
        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) {
@@ -1211,6 +1321,7 @@ int multi_assistant_service_plugin_set_wakeup_event_callback(wakeup_service_wake
                        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);
                        }
@@ -1221,7 +1332,7 @@ int multi_assistant_service_plugin_set_wakeup_event_callback(wakeup_service_wake
        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) {
@@ -1240,7 +1351,7 @@ int multi_assistant_service_plugin_set_utterance_streaming_callback(wakeup_servi
        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) {
@@ -1259,7 +1370,7 @@ int multi_assistant_service_plugin_set_previous_utterance_streaming_callback(wak
        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) {
@@ -1278,7 +1389,7 @@ int multi_assistant_service_plugin_set_follow_up_streaming_callback(wakeup_servi
        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) {
@@ -1295,7 +1406,7 @@ int multi_assistant_service_plugin_set_speech_status_callback(wakeup_service_spe
        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) {
@@ -1312,7 +1423,7 @@ int multi_assistant_service_plugin_set_setting_changed_callback(wakeup_service_s
        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) {
@@ -1329,7 +1440,7 @@ int multi_assistant_service_plugin_set_error_callback(wakeup_service_error_cb ca
        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) {
@@ -1346,7 +1457,7 @@ int multi_assistant_service_plugin_set_streaming_section_changed_callback(wakeup
        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) {
@@ -1363,7 +1474,7 @@ int multi_assistant_service_plugin_set_wakeup_engine_command_callback(wakeup_ser
        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) {
@@ -1380,7 +1491,7 @@ int multi_assistant_service_plugin_set_wakeup_service_state_changed_callback(wak
        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) {
index ad3d302..f874261 100644 (file)
@@ -13,7 +13,7 @@ ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"")
 
 SET(TEST_SOURCES
        test_config.cpp
-       ${CMAKE_SOURCE_DIR}/src/multi_assistant_config.cpp
+       ${CMAKE_SOURCE_DIR}/src/service_config.cpp
 )
 
 # Find Packages
index 6a92495..d9b6299 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <gtest/gtest.h>
 
-#include "multi_assistant_config.h"
+#include "service_config.h"
 
 #include <string>
 
@@ -32,7 +32,7 @@ public:
        }
        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];
 };
@@ -47,7 +47,7 @@ public:
                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);
@@ -56,7 +56,7 @@ public:
        }
        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];
 };
@@ -65,12 +65,12 @@ TEST_F(StorageWithEmptyWakeWord, HasOneWakeWordAfterAdd) {
        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);
 }
@@ -79,17 +79,17 @@ TEST_F(StorageWithEmptyWakeWord, HasTwoWakeWordsWhenDifferentLanguageAdded) {
        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);
 }
@@ -98,7 +98,7 @@ TEST_F(StorageWithEmptyWakeWord, RemovalFailsWhenNoMatchingEntryExists) {
        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);
@@ -107,23 +107,23 @@ TEST_F(StorageWithEmptyWakeWord, RemovalFailsWhenNoMatchingEntryExists) {
 }
 
 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);
 }
@@ -131,16 +131,16 @@ TEST_F(StorageWithAnArbitraryWakeWord, HasZeroWakeWordAfterRemoval) {
 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);
@@ -150,16 +150,16 @@ TEST_F(StorageWithAnArbitraryWakeWord, RemovesItemRequestedForRemoval) {
 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);