Merge changes I94bee8d4,I9dc8f8fb,Id361946a,I1b8aef64 into tizen
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 16 Apr 2020 01:31:21 +0000 (01:31 +0000)
committerGerrit Code Review <gerrit@review>
Thu, 16 Apr 2020 01:31:21 +0000 (01:31 +0000)
* changes:
  Remove unnecessary mas_ prefix in CServiceMain
  Replace int with pid_t for representing a process ID
  Send audio data to the dedicated audio processing app if exists
  Add override keyword for inherited virtual functions

14 files changed:
inc/application_manager.h
inc/application_manager_aul.h
inc/client_manager.h
inc/service_ipc_dbus.h
inc/service_ipc_dbus_dispatcher.h
inc/service_main.h
src/application_manager_aul.cpp
src/client_manager.cpp
src/service_ipc_dbus.cpp
src/service_ipc_dbus_dispatcher.cpp
src/service_main.cpp
src/service_plugin.cpp
tests/utc/client-manager/test_client_manager.cpp
tests/utc/service-main/test_service_main.cpp

index 1effd84..05bdcca 100644 (file)
@@ -32,6 +32,7 @@ public:
        virtual bool bring_app_to_foreground(const std::string& appid) = 0;
        virtual bool launch_app_async(const std::string& appid, bool background) = 0;
        virtual boost::optional<std::string> get_appid_by_pid(pid_t pid) = 0;
+       virtual boost::optional<pid_t> get_pid_by_appid(const std::string& appid) = 0;
 };
 
 #ifdef __cplusplus
index 4b46f59..9e3bedb 100644 (file)
@@ -34,6 +34,7 @@ public:
        virtual bool bring_app_to_foreground(const std::string& appid) override;
        virtual bool launch_app_async(const std::string& appid, bool background) override;
        virtual boost::optional<std::string> get_appid_by_pid(pid_t pid) override;
+       boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override;
 };
 
 #ifdef __cplusplus
index b174b14..0ecad4e 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 #endif
 
 typedef struct {
-       int pid;
+       pid_t pid;
        std::string appid;
 } ma_client_s;
 
@@ -38,20 +38,20 @@ public:
        virtual ~CClientManager() {}
 
        int set_application_manager(IApplicationManager* manager);
-       int create_client(int pid, std::string appid);
-       int destroy_client_by_pid(int pid);
+       int create_client(pid_t pid, std::string appid);
+       int destroy_client_by_pid(pid_t pid);
        int destroy_client_by_appid(std::string appid);
 
        int get_client_num();
-       int find_client_pid_by_index(unsigned int index);
+       pid_t find_client_pid_by_index(unsigned int index);
 
-       int find_client_pid_by_appid(std::string appid);
-       std::string find_client_appid_by_pid(int pid);
+       pid_t find_client_pid_by_appid(std::string appid);
+       std::string find_client_appid_by_pid(pid_t pid);
 
        bool check_client_validity_by_appid(std::string appid);
 private:
        ma_client_s* find_client_by_appid(std::string appid);
-       ma_client_s* find_client_by_pid(int pid);
+       ma_client_s* find_client_by_pid(pid_t pid);
        ma_client_s* get_client_by_index(unsigned int index);
        int destroy_client(ma_client_s* client);
 
index 9c5e40b..abe1990 100644 (file)
@@ -35,22 +35,22 @@ public:
 
        int open_connection();
        int close_connection();
-       int send_hello(int pid);
+       int send_hello(pid_t 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 change_active_state(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 change_service_state(int pid, int state);
-       int change_voice_key_status(int pid, int status);
+       int send_streaming_audio_data(pid_t pid, int event, void* data, unsigned int data_size);
+       int change_active_state(pid_t pid, int state);
+       int send_preprocessing_information(pid_t pid, const char* app_id);
+       int send_streaming_section_changed(pid_t pid, int section);
+       int send_preprocessing_result(pid_t pid, bool result);
+       int send_wakeup_engine_command(pid_t pid, const char* command);
+       int change_service_state(pid_t pid, int state);
+       int change_voice_key_status(pid_t pid, int status);
        int masc_ui_dbus_send_hello(void);
-       int masc_ui_dbus_send_asr_result(int pid, int event, const 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_send_asr_result(pid_t pid, int event, const char* asr_result);
+       int masc_ui_dbus_send_result(pid_t 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_send_recognition_result(pid_t pid, int result);
        int masc_ui_dbus_enable_common_ui(int enable);
 
        DBusConnection* get_connection_listener() { return mConnectionListener; }
@@ -59,6 +59,9 @@ public:
        void set_client_manager(CClientManager* manager) {
                mClientManager = manager;
        }
+       void set_application_manager(IApplicationManager* manager) {
+               mApplicationManager = manager;
+       }
        void set_service_ipc_observer(IServiceIpcObserver* observer) {
                mDispatcher.set_ipc_observer(observer);
        }
@@ -79,6 +82,7 @@ private:
        int mStreamingDataSerial{0};
 
        CClientManager* mClientManager{nullptr};
+       IApplicationManager* mApplicationManager{nullptr};
 };
 
 #ifdef __cplusplus
index ae36c70..9a88a99 100644 (file)
@@ -29,28 +29,28 @@ class CServiceMain;
 
 class IServiceIpcObserver {
 public:
-       virtual int on_initialize(int pid) = 0;
-       virtual int on_deinitialize(int pid) = 0;
-       virtual int on_get_audio_format(int pid, int& rate, int& channel, int& audio_type) = 0;
-       virtual int on_get_audio_source_type(int pid, std::string& type) = 0;
-       virtual int on_send_asr_result(int pid, int event, std::string asr_result) = 0;
-       virtual int on_send_result(int pid,
+       virtual int on_initialize(pid_t pid) = 0;
+       virtual int on_deinitialize(pid_t pid) = 0;
+       virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) = 0;
+       virtual int on_get_audio_source_type(pid_t pid, std::string& type) = 0;
+       virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result) = 0;
+       virtual int on_send_result(pid_t pid,
                std::string display_text, std::string utterance_text, std::string result_json) = 0;
-       virtual int on_send_recognition_result(int pid, int result) = 0;
-       virtual int on_start_streaming_audio_data(int pid, int type) = 0;
-       virtual int on_stop_streaming_audio_data(int pid, int type) = 0;
-       virtual int on_update_voice_feedback_state(int pid, int state) = 0;
-       virtual int on_send_assistant_specific_command(int pid, std::string command) = 0;
-       virtual int on_set_background_volume(int pid, double ratio) = 0;
-       virtual int on_set_preprocessing_allow_mode(int pid, int mode, std::string app_id) = 0;
-       virtual int on_send_preprocessing_result(int pid, int result) = 0;
-       virtual int on_set_wake_word_audio_require_flag(int pid, int require) = 0;
-       virtual int on_set_assistant_language(int pid, std::string language) = 0;
-       virtual int on_add_wake_word(int pid, std::string wake_word, std::string language) = 0;
-       virtual int on_remove_wake_word(int pid, std::string wake_word, std::string language) = 0;
+       virtual int on_send_recognition_result(pid_t pid, int result) = 0;
+       virtual int on_start_streaming_audio_data(pid_t pid, int type) = 0;
+       virtual int on_stop_streaming_audio_data(pid_t pid, int type) = 0;
+       virtual int on_update_voice_feedback_state(pid_t pid, int state) = 0;
+       virtual int on_send_assistant_specific_command(pid_t pid, std::string command) = 0;
+       virtual int on_set_background_volume(pid_t pid, double ratio) = 0;
+       virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) = 0;
+       virtual int on_send_preprocessing_result(pid_t pid, int result) = 0;
+       virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require) = 0;
+       virtual int on_set_assistant_language(pid_t pid, std::string language) = 0;
+       virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) = 0;
+       virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) = 0;
 
-       virtual int on_ui_initialize(int pid) = 0;
-       virtual int on_ui_deinitialize(int pid) = 0;
+       virtual int on_ui_initialize(pid_t pid) = 0;
+       virtual int on_ui_deinitialize(pid_t pid) = 0;
        virtual int on_ui_change_assistant(std::string app_id) = 0;
 };
 
index 94ee073..741ee7e 100644 (file)
@@ -76,69 +76,70 @@ public:
                {}
        virtual ~CServiceMain() {}
 
-       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_request_speech_data(int pid);
-       int mas_client_send_asr_result(int pid, int event, const char* asr_result);
-       int mas_client_send_result(int pid, const char* display_text,
+       int client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type);
+       int client_get_audio_source_type(pid_t pid, char** type);
+       int client_send_preprocessing_information(pid_t pid);
+       int client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status);
+       int client_request_speech_data(pid_t pid);
+       int client_send_asr_result(pid_t pid, int event, const char* asr_result);
+       int client_send_result(pid_t pid, const char* display_text,
                const char* utterance_text, const 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);
-       std::string 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();
-
-       virtual int on_initialize(int pid) override;
-       virtual int on_deinitialize(int pid) override;
-       virtual int on_get_audio_format(int pid, int& rate, int& channel, int& audio_type) override;
-       virtual int on_get_audio_source_type(int pid, std::string& type) override;
-       virtual int on_send_asr_result(int pid, int event, std::string asr_result) override;
-       virtual int on_send_result(int pid, std::string display_text,
+       int client_send_recognition_result(pid_t pid, int result);
+       int client_start_streaming_audio_data(pid_t pid, int type);
+       int client_stop_streaming_audio_data(pid_t pid, int type);
+       int client_update_voice_feedback_state(pid_t pid, int state);
+       int client_set_assistant_specific_command(pid_t pid, const char *command);
+       int client_set_background_volume(pid_t pid, double ratio);
+       int client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid);
+       int client_send_preprocessing_result(pid_t pid, bool result);
+       int client_set_wake_word_audio_require_flag(pid_t pid, bool require);
+       int client_set_assistant_language(pid_t pid, const char* language);
+       int client_add_wake_word(pid_t pid, const char* wake_word, const char* language);
+       int client_remove_wake_word(pid_t pid, const char* wake_word, const char* language);
+       int ui_client_initialize(pid_t pid);
+       int ui_client_deinitialize(pid_t pid);
+       int ui_client_change_assistant(const char* appid);
+       pid_t get_current_client_pid();
+       pid_t get_current_preprocessing_client_pid();
+       pid_t get_current_audio_processing_pid();
+       int get_client_pid_by_wakeup_word(const char *wakeup_word);
+       int get_client_pid_by_appid(const char *appid);
+       std::string get_client_appid_by_pid(pid_t pid);
+       bool get_client_custom_ui_option_by_appid(const char *appid);
+       const char* get_client_appid_by_wakeup_word(const char *wakeup_word);
+       int set_current_client_by_wakeup_word(const char *wakeup_word);
+       int set_current_client_by_appid(const char *appid);
+       int launch_client_by_wakeup_word(const char *wakeup_word);
+       int prelaunch_default_assistant();
+       int set_current_service_state(ma_service_state_e state);
+       int bring_client_to_foreground(const char* appid);
+       ma_service_state_e get_current_service_state();
+       int launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode);
+       int process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event);
+       int update_voice_key_support_mode();
+
+       virtual int on_initialize(pid_t pid) override;
+       virtual int on_deinitialize(pid_t pid) override;
+       virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) override;
+       virtual int on_get_audio_source_type(pid_t pid, std::string& type) override;
+       virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result) override;
+       virtual int on_send_result(pid_t pid, std::string display_text,
                std::string utterance_text, std::string result_json) override;
-       virtual int on_send_recognition_result(int pid, int result) override;
-       virtual int on_start_streaming_audio_data(int pid, int type) override;
-       virtual int on_stop_streaming_audio_data(int pid, int type) override;
-       virtual int on_update_voice_feedback_state(int pid, int state) override;
-       virtual int on_send_assistant_specific_command(int pid, std::string command) override;
-       virtual int on_set_background_volume(int pid, double ratio) override;
-       virtual int on_set_preprocessing_allow_mode(int pid, int mode, std::string app_id) override;
-       virtual int on_send_preprocessing_result(int pid, int result) override;
-       virtual int on_set_wake_word_audio_require_flag(int pid, int require) override;
-       virtual int on_set_assistant_language(int pid, std::string language) override;
-       virtual int on_add_wake_word(int pid, std::string wake_word, std::string language) override;
-       virtual int on_remove_wake_word(int pid, std::string wake_word, std::string language) override;
-
-       virtual int on_ui_initialize(int pid) override;
-       virtual int on_ui_deinitialize(int pid) override;
+       virtual int on_send_recognition_result(pid_t pid, int result) override;
+       virtual int on_start_streaming_audio_data(pid_t pid, int type) override;
+       virtual int on_stop_streaming_audio_data(pid_t pid, int type) override;
+       virtual int on_update_voice_feedback_state(pid_t pid, int state) override;
+       virtual int on_send_assistant_specific_command(pid_t pid, std::string command) override;
+       virtual int on_set_background_volume(pid_t pid, double ratio) override;
+       virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) override;
+       virtual int on_send_preprocessing_result(pid_t pid, int result) override;
+       virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require) override;
+       virtual int on_set_assistant_language(pid_t pid, std::string language) override;
+       virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) override;
+       virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) override;
+
+       virtual int on_ui_initialize(pid_t pid) override;
+       virtual int on_ui_deinitialize(pid_t pid) override;
        virtual int on_ui_change_assistant(std::string app_id) override;
 
        bool app_create(void *data);
@@ -177,6 +178,8 @@ private:
 
                ma_preprocessing_allow_mode_e preprocessing_allow_mode{MA_PREPROCESSING_ALLOW_NONE};
                char preprocessing_allow_appid[MAX_APPID_LEN];
+
+               boost::optional<std::string> audio_processing_appid;
        } ma_client_info;
 
        ma_client_info mClientInfo[MAX_MACLIENT_INFO_NUM];
index 41ae5f2..00b6ecb 100644 (file)
@@ -110,3 +110,15 @@ boost::optional<std::string> CApplicationManagerAul::get_appid_by_pid(pid_t pid)
 
        return ret;
 }
+
+boost::optional<pid_t> CApplicationManagerAul::get_pid_by_appid(const std::string& appid)
+{
+       boost::optional<pid_t> ret;
+
+       pid_t pid = aul_app_get_pid(appid.c_str());
+       if (pid >= 0) {
+               ret = pid;
+       }
+
+       return ret;
+}
\ No newline at end of file
index f9cf2f9..01cd9d5 100644 (file)
@@ -23,7 +23,7 @@ int CClientManager::set_application_manager(IApplicationManager* manager)
        return 0;
 }
 
-int CClientManager::create_client(int pid, std::string appid)
+int CClientManager::create_client(pid_t pid, std::string appid)
 {
        ma_client_s* data = NULL;
 
@@ -60,7 +60,7 @@ int CClientManager::destroy_client(ma_client_s* client)
        return 0;
 }
 
-int CClientManager::destroy_client_by_pid(int pid)
+int CClientManager::destroy_client_by_pid(pid_t pid)
 {
        ma_client_s* client = find_client_by_pid(pid);
        return destroy_client(client);
@@ -94,7 +94,7 @@ ma_client_s* CClientManager::find_client_by_appid(std::string appid)
        return NULL;
 }
 
-ma_client_s* CClientManager::find_client_by_pid(int pid)
+ma_client_s* CClientManager::find_client_by_pid(pid_t pid)
 {
        ma_client_s *data = NULL;
 
@@ -126,9 +126,9 @@ ma_client_s* CClientManager::get_client_by_index(unsigned int index)
        return static_cast<ma_client_s*>(g_slist_nth_data(mClientList, index));
 }
 
-int CClientManager::find_client_pid_by_index(unsigned int index)
+pid_t CClientManager::find_client_pid_by_index(unsigned int index)
 {
-       int pid = -1;
+       pid_t pid = -1;
        ma_client_s* client = get_client_by_index(index);
        if (client) {
                pid = client->pid;
@@ -136,9 +136,9 @@ int CClientManager::find_client_pid_by_index(unsigned int index)
        return pid;
 }
 
-int CClientManager::find_client_pid_by_appid(std::string appid)
+pid_t CClientManager::find_client_pid_by_appid(std::string appid)
 {
-       int pid = -1;
+       pid_t pid = -1;
 
        if (nullptr == mApplicationManager) {
                MAS_LOGE("ApplicationManager is NULL, can't check if app is running or not");
@@ -158,7 +158,7 @@ int CClientManager::find_client_pid_by_appid(std::string appid)
        return pid;
 }
 
-std::string CClientManager::find_client_appid_by_pid(int pid)
+std::string CClientManager::find_client_appid_by_pid(pid_t pid)
 {
        std::string appid;
 
@@ -182,7 +182,7 @@ std::string CClientManager::find_client_appid_by_pid(int pid)
 
 bool CClientManager::check_client_validity_by_appid(std::string appid)
 {
-       int pid = find_client_pid_by_appid(appid);
+       pid_t pid = find_client_pid_by_appid(appid);
        if (0 < pid) return true;
        return false;
 }
index f6fba74..bb1c3fa 100644 (file)
@@ -74,7 +74,7 @@ int CServiceIpcDbus::mas_check_dbus_connection()
        return 0;
 }
 
-int CServiceIpcDbus::send_hello(int pid)
+int CServiceIpcDbus::send_hello(pid_t pid)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -206,7 +206,7 @@ static void masc_message_port_error(int error)
                "MESSAGE_PORT_ERROR_UNKNOWN");
 }
 
-int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size)
+int CServiceIpcDbus::send_streaming_audio_data(pid_t pid, int event, void* data, unsigned int data_size)
 {
        if (nullptr == mClientManager) {
                MAS_LOGE("mClientManager variable is NULL");
@@ -244,10 +244,14 @@ int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, u
                bundle *b = bundle_create();
                if (b) {
                        bundle_add_byte(b, "content", pending_buffer, pending_buffer_size);
-                       int ret = message_port_send_message(
-                               mClientManager->find_client_appid_by_pid(pid).c_str(), message_port, b);
-                       if (MESSAGE_PORT_ERROR_NONE != ret)
-                               masc_message_port_error(ret);
+                       boost::optional<std::string> appid = mApplicationManager->get_appid_by_pid(pid);
+                       if (appid) {
+                               int ret = message_port_send_message((*appid).c_str(), message_port, b);
+                               if (MESSAGE_PORT_ERROR_NONE != ret)
+                                       masc_message_port_error(ret);
+                       } else {
+                               MAS_LOGE("AppID for PID %d not found!!!", pid);
+                       }
 
                        pending_buffer_size = 0;
                        bundle_free(b);
@@ -265,10 +269,14 @@ int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, u
                bundle *b = bundle_create();
                if (b) {
                        bundle_add_byte(b, "content", buffer, total_size);
-                       int ret = message_port_send_message(
-                               mClientManager->find_client_appid_by_pid(pid).c_str(), message_port, b);
-                       if (MESSAGE_PORT_ERROR_NONE != ret)
-                               masc_message_port_error(ret);
+                       boost::optional<std::string> appid = mApplicationManager->get_appid_by_pid(pid);
+                       if (appid) {
+                               int ret = message_port_send_message((*appid).c_str(), message_port, b);
+                               if (MESSAGE_PORT_ERROR_NONE != ret)
+                                       masc_message_port_error(ret);
+                       } else {
+                               MAS_LOGE("AppID for PID %d not found!!!", pid);
+                       }
 
                        bundle_free(b);
                } else {
@@ -281,7 +289,7 @@ int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, u
        return 0;
 }
 
-int CServiceIpcDbus::change_active_state(int pid, int state)
+int CServiceIpcDbus::change_active_state(pid_t pid, int state)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -331,7 +339,7 @@ int CServiceIpcDbus::change_active_state(int pid, int state)
        return 0;
 }
 
-int CServiceIpcDbus::send_preprocessing_information(int pid, const char* app_id)
+int CServiceIpcDbus::send_preprocessing_information(pid_t pid, const char* app_id)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -395,7 +403,7 @@ int CServiceIpcDbus::send_preprocessing_information(int pid, const char* app_id)
        return 0;
 }
 
-int CServiceIpcDbus::send_streaming_section_changed(int pid, int section)
+int CServiceIpcDbus::send_streaming_section_changed(pid_t pid, int section)
 {
        if (nullptr == mClientManager) {
                MAS_LOGE("mClientManager variable is NULL");
@@ -430,7 +438,7 @@ int CServiceIpcDbus::send_streaming_section_changed(int pid, int section)
        return 0;
 }
 
-int CServiceIpcDbus::send_preprocessing_result(int pid, bool result)
+int CServiceIpcDbus::send_preprocessing_result(pid_t pid, bool result)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -483,7 +491,7 @@ int CServiceIpcDbus::send_preprocessing_result(int pid, bool result)
        return 0;
 }
 
-int CServiceIpcDbus::send_wakeup_engine_command(int pid, const char* command)
+int CServiceIpcDbus::send_wakeup_engine_command(pid_t pid, const char* command)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -547,7 +555,7 @@ int CServiceIpcDbus::send_wakeup_engine_command(int pid, const char* command)
        return 0;
 }
 
-int CServiceIpcDbus::change_service_state(int pid, int state)
+int CServiceIpcDbus::change_service_state(pid_t pid, int state)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -597,7 +605,7 @@ int CServiceIpcDbus::change_service_state(int pid, int state)
        return 0;
 }
 
-int CServiceIpcDbus::change_voice_key_status(int pid, int status)
+int CServiceIpcDbus::change_voice_key_status(pid_t pid, int status)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -691,7 +699,7 @@ int CServiceIpcDbus::masc_ui_dbus_send_hello(void)
        return result;
 }
 
-int CServiceIpcDbus::masc_ui_dbus_send_asr_result(int pid, int event, const char* asr_result)
+int CServiceIpcDbus::masc_ui_dbus_send_asr_result(pid_t pid, int event, const char* asr_result)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
@@ -745,7 +753,7 @@ int CServiceIpcDbus::masc_ui_dbus_send_asr_result(int pid, int event, const char
        return 0;
 }
 
-int CServiceIpcDbus::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(pid_t pid, const char* display_text, const char* utterance_text, const char* result_json)
 {
        if (0 != __dbus_check()) {
                return -1; //MA_ERROR_OPERATION_FAILED;
@@ -925,7 +933,7 @@ int CServiceIpcDbus::masc_ui_dbus_send_error_message(int reason, const char* err
        return 0;
 }
 
-int CServiceIpcDbus::masc_ui_dbus_send_recognition_result(int pid, int result)
+int CServiceIpcDbus::masc_ui_dbus_send_recognition_result(pid_t pid, int result)
 {
        if (0 != __dbus_check()) {
                return -1; //MAS_ERROR_OPERATION_FAILED;
index 183140b..674c9e1 100644 (file)
@@ -54,7 +54,7 @@ int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage*
        DBusError err;
        dbus_error_init(&err);
 
-       int pid = -1;
+       pid_t pid = -1;
        int ret = 0;
 
        if (FALSE == dbus_message_get_args(msg, &err,
@@ -112,7 +112,7 @@ int CServiceIpcDbusDispatcher::on_deinitialize(DBusConnection* conn, DBusMessage
        DBusError err;
        dbus_error_init(&err);
 
-       int pid = -1;
+       pid_t pid = -1;
        int ret = 0;
 
        if (FALSE == dbus_message_get_args(msg, &err,
@@ -170,7 +170,7 @@ int CServiceIpcDbusDispatcher::on_get_audio_format(DBusConnection* conn, DBusMes
        DBusError err;
        dbus_error_init(&err);
 
-       int pid = -1;
+       pid_t pid = -1;
        int rate, channel, audio_type;
        int ret;
 
@@ -231,7 +231,7 @@ int CServiceIpcDbusDispatcher::on_get_audio_source_type(DBusConnection* conn, DB
        DBusError err;
        dbus_error_init(&err);
 
-       int pid = -1;
+       pid_t pid = -1;
        std::string type;
        int ret;
 
@@ -300,7 +300,7 @@ int CServiceIpcDbusDispatcher::on_send_asr_result(DBusConnection* conn, DBusMess
        DBusError err;
        dbus_error_init(&err);
 
-       int pid, event;
+       pid_t pid, event;
        char *asr_result;
        int ret = 0;
 
@@ -364,7 +364,7 @@ int CServiceIpcDbusDispatcher::on_send_result(DBusConnection* conn, DBusMessage*
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        char* display_text;
        char* utterance_text;
        char* result_json;
@@ -433,7 +433,7 @@ int CServiceIpcDbusDispatcher::on_send_recognition_result(DBusConnection* conn,
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int result;
        int ret = 0;
 
@@ -471,7 +471,7 @@ int CServiceIpcDbusDispatcher::on_start_streaming_audio_data(DBusConnection* con
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int type;
        int ret = 0;
 
@@ -509,7 +509,7 @@ int CServiceIpcDbusDispatcher::on_stop_streaming_audio_data(DBusConnection* conn
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int type;
        int ret = 0;
 
@@ -547,7 +547,7 @@ int CServiceIpcDbusDispatcher::on_update_voice_feedback_state(DBusConnection* co
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int state;
        int ret = 0;
 
@@ -585,7 +585,7 @@ int CServiceIpcDbusDispatcher::on_send_assistant_specific_command(DBusConnection
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        char* command;
 
@@ -624,7 +624,7 @@ int CServiceIpcDbusDispatcher::on_set_background_volume(DBusConnection* conn, DB
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        double ratio;
 
@@ -662,7 +662,7 @@ int CServiceIpcDbusDispatcher::on_set_preprocessing_allow_mode(DBusConnection* c
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        int mode;
        char* app_id;
@@ -704,7 +704,7 @@ int CServiceIpcDbusDispatcher::on_send_preprocessing_result(DBusConnection* conn
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        int result;
 
@@ -742,7 +742,7 @@ int CServiceIpcDbusDispatcher::on_set_wake_word_audio_require_flag(DBusConnectio
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        int require;
 
@@ -780,7 +780,7 @@ int CServiceIpcDbusDispatcher::on_set_assistant_language(DBusConnection* conn, D
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        char* language;
 
@@ -819,7 +819,7 @@ int CServiceIpcDbusDispatcher::on_add_wake_word(DBusConnection* conn, DBusMessag
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        char* wake_word;
        char* language;
@@ -861,7 +861,7 @@ int CServiceIpcDbusDispatcher::on_remove_wake_word(DBusConnection* conn, DBusMes
        DBusError err;
        dbus_error_init(&err);
 
-       int pid;
+       pid_t pid;
        int ret = 0;
        char* wake_word;
        char* language;
@@ -903,7 +903,7 @@ int CServiceIpcDbusDispatcher::on_ui_initialize(DBusConnection* conn, DBusMessag
        DBusError err;
        dbus_error_init(&err);
 
-       int pid = -1;
+       pid_t pid = -1;
        int ret = 0;
 
        if (FALSE == dbus_message_get_args(msg, &err,
@@ -961,7 +961,7 @@ int CServiceIpcDbusDispatcher::on_ui_deinitialize(DBusConnection* conn, DBusMess
        DBusError err;
        dbus_error_init(&err);
 
-       int pid = -1;
+       pid_t pid = -1;
        int ret = 0;
 
        if (FALSE == dbus_message_get_args(msg, &err,
index 85cee29..699e0db 100644 (file)
@@ -74,7 +74,7 @@ bool CServiceMain::is_current_preprocessing_assistant(const char* appid)
        return ret;
 }
 
-int CServiceMain::mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type)
+int CServiceMain::client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type)
 {
        MAS_LOGD("[Enter] pid(%d)", pid);
 
@@ -87,7 +87,7 @@ int CServiceMain::mas_client_get_audio_format(int pid, int* rate, int* channel,
 }
 
 #define MAX_LOCAL_VARIABLE_STRING_LEN 256
-int CServiceMain::mas_client_get_audio_source_type(int pid, char** type)
+int CServiceMain::client_get_audio_source_type(pid_t pid, char** type)
 {
        MAS_LOGD("[Enter] pid(%d)", pid);
 
@@ -106,7 +106,7 @@ int CServiceMain::mas_client_get_audio_source_type(int pid, char** type)
        return ret;
 }
 
-int CServiceMain::mas_client_send_preprocessing_information(int pid)
+int CServiceMain::client_send_preprocessing_information(pid_t pid)
 {
        int ret = -1;
        MAS_LOGD("[Enter] pid(%d)", pid);
@@ -121,7 +121,7 @@ int CServiceMain::mas_client_send_preprocessing_information(int pid)
        return ret;
 }
 
-int CServiceMain::mas_client_send_voice_key_status_change(int pid, ma_voice_key_status_e status)
+int CServiceMain::client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status)
 {
        int ret = -1;
        MAS_LOGD("[Enter] pid(%d)", pid);
@@ -135,7 +135,7 @@ int CServiceMain::mas_client_send_voice_key_status_change(int pid, ma_voice_key_
        return ret;
 }
 
-int CServiceMain::mas_client_send_asr_result(int pid, int event, const char* asr_result)
+int CServiceMain::client_send_asr_result(pid_t pid, int event, const char* asr_result)
 {
        MAS_LOGD("[Enter] pid(%d), event(%d), asr_result(%s)", pid, event, asr_result);
        int ret = mServiceIpc.masc_ui_dbus_send_asr_result(pid, event, asr_result);
@@ -148,7 +148,7 @@ int CServiceMain::mas_client_send_asr_result(int pid, int event, const char* asr
        return ret;
 }
 
-int CServiceMain::mas_client_send_result(int pid, const char* display_text,
+int CServiceMain::client_send_result(pid_t pid, const char* display_text,
        const char* utterance_text, const char* result_json)
 {
        MAS_LOGD("[Enter] pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json);
@@ -167,7 +167,7 @@ int CServiceMain::mas_client_send_result(int pid, const char* display_text,
        return ret;
 }
 
-int CServiceMain::mas_client_send_recognition_result(int pid, int result)
+int CServiceMain::client_send_recognition_result(pid_t pid, int result)
 {
        MAS_LOGD("[Enter] pid(%d), result(%d)", pid, result);
        int ret = mServiceIpc.masc_ui_dbus_send_recognition_result(pid, result);
@@ -185,13 +185,13 @@ int CServiceMain::mas_client_send_recognition_result(int pid, int result)
        return ret;
 }
 
-int CServiceMain::mas_client_start_streaming_audio_data(int pid, int type)
+int CServiceMain::client_start_streaming_audio_data(pid_t pid, int type)
 {
        int ret = -1;
        switch(type) {
                case MA_AUDIO_STREAMING_DATA_TYPE_CURRENT_UTTERANCE:
                        ret = mServicePlugin.start_streaming_utterance_data();
-                       mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED);
+                       process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED);
                        break;
                case MA_AUDIO_STREAMING_DATA_TYPE_PREVIOUS_UTTERANCE:
                        ret = mServicePlugin.start_streaming_previous_utterance_data();
@@ -199,13 +199,13 @@ int CServiceMain::mas_client_start_streaming_audio_data(int pid, int type)
                        break;
                case MA_AUDIO_STREAMING_DATA_TYPE_FOLLOW_UP_SPEECH:
                        ret = mServicePlugin.start_streaming_follow_up_data();
-                       mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED);
+                       process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED);
                        break;
        }
        return ret;
 }
 
-int CServiceMain::mas_client_stop_streaming_audio_data(int pid, int type)
+int CServiceMain::client_stop_streaming_audio_data(pid_t pid, int type)
 {
        int ret = -1;
        switch(type) {
@@ -222,7 +222,7 @@ int CServiceMain::mas_client_stop_streaming_audio_data(int pid, int type)
        return ret;
 }
 
-int CServiceMain::mas_client_update_voice_feedback_state(int pid, int state)
+int CServiceMain::client_update_voice_feedback_state(pid_t pid, int state)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -233,7 +233,7 @@ int CServiceMain::mas_client_update_voice_feedback_state(int pid, int state)
        return 0;
 }
 
-int CServiceMain::mas_client_set_assistant_specific_command(int pid, const char *command)
+int CServiceMain::client_set_assistant_specific_command(pid_t pid, const char *command)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -244,7 +244,7 @@ int CServiceMain::mas_client_set_assistant_specific_command(int pid, const char
        return 0;
 }
 
-int CServiceMain::mas_client_set_background_volume(int pid, double ratio)
+int CServiceMain::client_set_background_volume(pid_t pid, double ratio)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -255,7 +255,7 @@ int CServiceMain::mas_client_set_background_volume(int pid, double ratio)
        return 0;
 }
 
-int CServiceMain::mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid)
+int CServiceMain::client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -277,12 +277,12 @@ int CServiceMain::mas_client_set_preprocessing_allow_mode(int pid, ma_preprocess
                }
        }
 
-       mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED);
+       process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED);
 
        return 0;
 }
 
-int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result)
+int CServiceMain::client_send_preprocessing_result(pid_t pid, bool result)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -298,14 +298,14 @@ int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result)
 
        if (result) {
                MAS_LOGD("Preprocessing succeeded, bring (%s) to foreground", pid_appid.c_str());
-               mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED);
+               process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED);
        } else {
                MAS_LOGD("Preprocessing failed, bring (%s) to foreground", current_maclient_appid);
-               mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED);
+               process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED);
        }
 
        if (current_maclient_appid) {
-               int pid_by_appid = mClientManager.find_client_pid_by_appid(
+               pid_t pid_by_appid = mClientManager.find_client_pid_by_appid(
                        std::string{current_maclient_appid});
                mServiceIpc.send_preprocessing_result(pid_by_appid, result);
        }
@@ -313,7 +313,7 @@ int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result)
        return 0;
 }
 
-int CServiceMain::mas_client_set_wake_word_audio_require_flag(int pid, bool require)
+int CServiceMain::client_set_wake_word_audio_require_flag(pid_t pid, bool require)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -325,7 +325,7 @@ int CServiceMain::mas_client_set_wake_word_audio_require_flag(int pid, bool requ
        return 0;
 }
 
-int CServiceMain::mas_client_set_assistant_language(int pid, const char* language)
+int CServiceMain::client_set_assistant_language(pid_t pid, const char* language)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -337,7 +337,7 @@ int CServiceMain::mas_client_set_assistant_language(int pid, const char* languag
        return 0;
 }
 
-int CServiceMain::mas_client_add_wake_word(int pid, const char* wake_word, const char* language)
+int CServiceMain::client_add_wake_word(pid_t pid, const char* wake_word, const char* language)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -366,7 +366,7 @@ int CServiceMain::mas_client_add_wake_word(int pid, const char* wake_word, const
        return 0;
 }
 
-int CServiceMain::mas_client_remove_wake_word(int pid, const char* wake_word, const char* language)
+int CServiceMain::client_remove_wake_word(pid_t pid, const char* wake_word, const char* language)
 {
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
@@ -392,21 +392,21 @@ int CServiceMain::mas_client_remove_wake_word(int pid, const char* wake_word, co
        return 0;
 }
 
-int CServiceMain::mas_ui_client_initialize(int pid)
+int CServiceMain::ui_client_initialize(pid_t pid)
 {
        MAS_LOGD("[Enter] pid(%d)", pid);
 
        return 0;
 }
 
-int CServiceMain::mas_ui_client_deinitialize(int pid)
+int CServiceMain::ui_client_deinitialize(pid_t pid)
 {
        MAS_LOGD("[Enter] pid(%d)", pid);
 
        return 0;
 }
 
-int CServiceMain::mas_ui_client_change_assistant(const char* appid)
+int CServiceMain::ui_client_change_assistant(const char* appid)
 {
        MAS_LOGD("[Enter]");
 
@@ -415,16 +415,16 @@ int CServiceMain::mas_ui_client_change_assistant(const char* appid)
                return -1;
        }
 
-       bool use_custom_ui = mas_get_client_custom_ui_option_by_appid(appid);
+       bool use_custom_ui = get_client_custom_ui_option_by_appid(appid);
        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);
+       set_current_client_by_appid(appid);
+       pid_t pid = get_client_pid_by_appid(appid);
        if (pid != -1) {
-               mas_bring_client_to_foreground(appid);
-               mas_client_send_preprocessing_information(pid);
+               bring_client_to_foreground(appid);
+               client_send_preprocessing_information(pid);
                if (MA_VOICE_KEY_STATUS_PRESSED == mLastVoiceKeyStatus) {
-                       mas_client_send_voice_key_status_change(pid, mLastVoiceKeyStatus);
+                       client_send_voice_key_status_change(pid, mLastVoiceKeyStatus);
                }
 
                mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_ACTIVE);
@@ -445,7 +445,7 @@ int CServiceMain::mas_ui_client_change_assistant(const char* appid)
                                0 < strlen(mClientInfo[loop].appid) &&
                                0 < strlen(mClientInfo[loop].wakeup_word[0])) {
                                if (strncmp(appid, mClientInfo[loop].appid, MAX_APPID_LEN) == 0) {
-                                       mas_launch_client_by_appid(mClientInfo[loop].appid, CLIENT_LAUNCH_MODE_ACTIVATION);
+                                       launch_client_by_appid(mClientInfo[loop].appid, CLIENT_LAUNCH_MODE_ACTIVATION);
                                }
                        }
                }
@@ -454,7 +454,7 @@ int CServiceMain::mas_ui_client_change_assistant(const char* appid)
        return 0;
 }
 
-static int mas_assistant_info_cb(ma_assistant_info_s* info, void* user_data) {
+static int 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) {
@@ -464,7 +464,7 @@ static int mas_assistant_info_cb(ma_assistant_info_s* info, void* user_data) {
 }
 
 int CServiceMain::add_assistant_info(ma_assistant_info_s* info) {
-       MAS_LOGD("__mas_assistant_info_cb called");
+       MAS_LOGD("__assistant_info_cb called");
 
        if (NULL == info) {
                MAS_LOGE("info NULL, returning");
@@ -539,7 +539,7 @@ int CServiceMain::add_assistant_info(ma_assistant_info_s* info) {
                MAS_LOGD("Couldn't find an empty slot for storing assistant info");
        }
 
-       MAS_LOGD("__mas_assistant_info_cb end");
+       MAS_LOGD("__assistant_info_cb end");
 
        return 0;
 }
@@ -588,7 +588,7 @@ int CServiceMain::initialize_service_plugin(void)
        mCurrentPreprocessingClientInfo = -1;
        mWakeupClientAppId.clear();
 
-       if (0 == mServiceConfig.get_assistant_info(mas_assistant_info_cb, this)) {
+       if (0 == mServiceConfig.get_assistant_info(assistant_info_cb, this)) {
                for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
                        int inner_loop;
                        if (0 < strlen(mClientInfo[loop].appid)) {
@@ -676,7 +676,7 @@ int CServiceMain::process_activated_setting()
        return 0;
 }
 
-int CServiceMain::mas_get_current_client_pid()
+int CServiceMain::get_current_client_pid()
 {
        int ret = -1;
        if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) {
@@ -688,9 +688,9 @@ int CServiceMain::mas_get_current_client_pid()
        return ret;
 }
 
-int CServiceMain::mas_get_current_preprocessing_client_pid()
+pid_t CServiceMain::get_current_preprocessing_client_pid()
 {
-       int ret = -1;
+       pid_t ret = -1;
        if (mCurrentPreprocessingClientInfo >= 0 && mCurrentPreprocessingClientInfo < MAX_MACLIENT_INFO_NUM) {
                const char *appid = mClientInfo[mCurrentPreprocessingClientInfo].appid;
                if (appid) {
@@ -700,9 +700,26 @@ int CServiceMain::mas_get_current_preprocessing_client_pid()
        return ret;
 }
 
-int CServiceMain::mas_get_client_pid_by_appid(const char *appid)
+pid_t CServiceMain::get_current_audio_processing_pid()
 {
-       int ret = -1;
+       pid_t ret = -1;
+       if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) {
+               boost::optional<std::string> audio_processing_appid =
+                       mClientInfo[mCurrentClientInfo].audio_processing_appid;
+               if (audio_processing_appid) {
+                       boost::optional<pid_t> optional_pid_t;
+                       optional_pid_t = mApplicationManager.get_pid_by_appid((*audio_processing_appid).c_str());
+                       if (optional_pid_t) {
+                               ret = *optional_pid_t;
+                       }
+               }
+       }
+       return ret;
+}
+
+pid_t CServiceMain::get_client_pid_by_appid(const char *appid)
+{
+       pid_t ret = -1;
 
        if (appid) {
                ret = mClientManager.find_client_pid_by_appid(std::string{appid});
@@ -717,7 +734,7 @@ int CServiceMain::mas_get_client_pid_by_appid(const char *appid)
        return ret;
 }
 
-bool CServiceMain::mas_get_client_custom_ui_option_by_appid(const char *appid)
+bool CServiceMain::get_client_custom_ui_option_by_appid(const char *appid)
 {
        bool ret = false;
        for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
@@ -732,13 +749,13 @@ bool CServiceMain::mas_get_client_custom_ui_option_by_appid(const char *appid)
        return ret;
 }
 
-int CServiceMain::mas_get_client_pid_by_wakeup_word(const char *wakeup_word)
+int CServiceMain::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 *appid = get_client_appid_by_wakeup_word(wakeup_word);
+       return get_client_pid_by_appid(appid);
 }
 
-const char* CServiceMain::mas_get_client_appid_by_wakeup_word(const char *wakeup_word)
+const char* CServiceMain::get_client_appid_by_wakeup_word(const char *wakeup_word)
 {
        int loop;
        const char *appid = NULL;
@@ -784,7 +801,7 @@ const char* CServiceMain::mas_get_client_appid_by_wakeup_word(const char *wakeup
        return appid;
 }
 
-int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word)
+int CServiceMain::set_current_client_by_wakeup_word(const char *wakeup_word)
 {
        int loop;
        int ret = -1;
@@ -829,7 +846,7 @@ int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word)
 
        if (mCurrentClientInfo != prev_selection) {
                if (prev_selection >= 0 && prev_selection < MAX_MACLIENT_INFO_NUM) {
-                       int pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid);
+                       pid_t pid = get_client_pid_by_appid(mClientInfo[prev_selection].appid);
                        mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_INACTIVE);
                }
        }
@@ -837,7 +854,7 @@ int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word)
        return ret;
 }
 
-int CServiceMain::mas_set_current_client_by_appid(const char *appid)
+int CServiceMain::set_current_client_by_appid(const char *appid)
 {
        int ret = -1;
        int prev_selection = mCurrentClientInfo;
@@ -855,7 +872,7 @@ int CServiceMain::mas_set_current_client_by_appid(const char *appid)
 
        if (mCurrentClientInfo != prev_selection) {
                if (prev_selection >= 0 && prev_selection < MAX_MACLIENT_INFO_NUM) {
-                       int pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid);
+                       pid_t pid = get_client_pid_by_appid(mClientInfo[prev_selection].appid);
                        mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_INACTIVE);
                }
        }
@@ -863,7 +880,7 @@ int CServiceMain::mas_set_current_client_by_appid(const char *appid)
        return ret;
 }
 
-int CServiceMain::mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode)
+int CServiceMain::launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode)
 {
        int result = 0;
 
@@ -900,7 +917,7 @@ int CServiceMain::mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MO
        return result;
 }
 
-int CServiceMain::mas_bring_client_to_foreground(const char* appid)
+int CServiceMain::bring_client_to_foreground(const char* appid)
 {
        int ret = 0;
 
@@ -916,13 +933,13 @@ int CServiceMain::mas_bring_client_to_foreground(const char* appid)
        return ret;
 }
 
-int CServiceMain::mas_launch_client_by_wakeup_word(const char *wakeup_word)
+int CServiceMain::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);
+       const char *appid = get_client_appid_by_wakeup_word(wakeup_word);
+       return launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
 }
 
-int CServiceMain::mas_prelaunch_default_assistant()
+int CServiceMain::prelaunch_default_assistant()
 {
        /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */
        boost::optional<bool> prelaunch_mode =
@@ -932,14 +949,14 @@ int CServiceMain::mas_prelaunch_default_assistant()
                if (0 == mServicePlugin.get_default_assistant(&default_assistant)) {
                        if (!(mApplicationManager.is_application_running(default_assistant))) {
                                MAS_LOGD("prelaunching default_assistant_appid : %s", default_assistant);
-                               mas_launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH);
+                               launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH);
                        }
                }
        }
        return 0;
 }
 
-int CServiceMain::mas_update_voice_key_support_mode()
+int CServiceMain::update_voice_key_support_mode()
 {
        /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */
        bool successful = false;
@@ -985,7 +1002,7 @@ ma_preprocessing_allow_mode_e CServiceMain::get_preprocessing_allow_mode(const c
 /* This might need to be read from settings in the future, but using macro for now */
 //#define BRING_PREPROCESSING_ASSISTANT_TO_FRONT
 
-int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event)
+int CServiceMain::process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event)
 {
        const char* current_maclient_appid = NULL;
        const char* preprocessing_allow_appid = NULL;
@@ -1001,7 +1018,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN
 #ifndef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
                        /* If there is no need to bring preprocessing assistant to front,
                                current_maclient should always be brought to front */
-                       mas_bring_client_to_foreground(current_maclient_appid);
+                       bring_client_to_foreground(current_maclient_appid);
 #endif
                        mCurrentPreprocessingState = PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED;
                        if (check_preprocessing_assistant_exists()) {
@@ -1015,7 +1032,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN
 #ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
                                /* If preprocessing assistant does not exist, there is no way to enable
                                        preprocessing assistant, so bring current maclient to front right away */
-                               mas_bring_client_to_foreground(current_maclient_appid);
+                               bring_client_to_foreground(current_maclient_appid);
 #endif
                        }
                }
@@ -1043,7 +1060,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN
                                        would have been brought to front already on wakeup event */
 #ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
                                if (check_preprocessing_assistant_exists()) {
-                                       mas_bring_client_to_foreground(current_maclient_appid);
+                                       bring_client_to_foreground(current_maclient_appid);
                                }
 #endif
                                mCurrentPreprocessingState = PREPROCESSING_STATE_NONE;
@@ -1070,7 +1087,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN
                                        mPreferenceManager.get_bool(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID);
                                if (preprocessing_assistant) {
                                        MAS_LOGD("preprocessing_assistant_appid : %s", (*preprocessing_assistant).c_str());
-                                       mas_bring_client_to_foreground((*preprocessing_assistant).c_str());
+                                       bring_client_to_foreground((*preprocessing_assistant).c_str());
                                }
                        }
 #endif
@@ -1082,7 +1099,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN
 #ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
                        if (PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED == mCurrentPreprocessingState ||
                                PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED == mCurrentPreprocessingState) {
-                               mas_bring_client_to_foreground(current_maclient_appid);
+                               bring_client_to_foreground(current_maclient_appid);
                        }
 #endif
                        mCurrentPreprocessingState = PREPROCESSING_STATE_NONE;
@@ -1092,7 +1109,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN
        return 0;
 }
 
-int CServiceMain::mas_set_current_service_state(ma_service_state_e state)
+int CServiceMain::set_current_service_state(ma_service_state_e state)
 {
        mCurrentServiceState = state;
 
@@ -1100,7 +1117,7 @@ int CServiceMain::mas_set_current_service_state(ma_service_state_e state)
        int i;
 
        for (i = 0; i < count; i++) {
-               int pid = mClientManager.find_client_pid_by_index(i);
+               pid_t pid = mClientManager.find_client_pid_by_index(i);
 
                if (-1 != pid) {
                        int ret = mServiceIpc.change_service_state(pid, state);
@@ -1112,7 +1129,7 @@ int CServiceMain::mas_set_current_service_state(ma_service_state_e state)
        return 0;
 }
 
-ma_service_state_e CServiceMain::mas_get_current_service_state()
+ma_service_state_e CServiceMain::get_current_service_state()
 {
        return mCurrentServiceState;
 }
@@ -1299,6 +1316,7 @@ bool CServiceMain::app_create(void *data)
        mClientManager.set_application_manager(&mApplicationManager);
 
        mServiceIpc.set_client_manager(&mClientManager);
+       mServiceIpc.set_application_manager(&mApplicationManager);
        mServiceIpc.set_service_ipc_observer(this);
 
        mServicePlugin.set_service_ipc(&mServiceIpc);
@@ -1313,15 +1331,15 @@ bool CServiceMain::app_create(void *data)
 
        process_activated_setting();
 
-       mas_prelaunch_default_assistant();
-       mas_update_voice_key_support_mode();
+       prelaunch_default_assistant();
+       update_voice_key_support_mode();
 
        /* For the case of preprocessing assistant, it always have to be launched beforehand */
        boost::optional<std::string> preprocessing_assistant =
                mPreferenceManager.get_string(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID);
        if (preprocessing_assistant) {
                MAS_LOGD("prelaunching preprocessing_assistant_appid : %s", (*preprocessing_assistant).c_str());
-               mas_launch_client_by_appid((*preprocessing_assistant).c_str(), CLIENT_LAUNCH_MODE_PRELAUNCH);
+               launch_client_by_appid((*preprocessing_assistant).c_str(), CLIENT_LAUNCH_MODE_PRELAUNCH);
        }
 
        if (!mPackageManagerHandle) {
@@ -1366,7 +1384,7 @@ void CServiceMain::app_terminate(void *data)
        return;
 }
 
-int CServiceMain::on_initialize(int pid) {
+int CServiceMain::on_initialize(pid_t pid) {
        MAS_LOGD("[Enter] pid(%d)", pid);
 
        std::string pid_appid;
@@ -1388,9 +1406,9 @@ int CServiceMain::on_initialize(int pid) {
                        current_maclient_appid = mClientInfo[mCurrentClientInfo].appid;
                }
 
-               mas_client_send_preprocessing_information(pid);
+               client_send_preprocessing_information(pid);
                if (MA_VOICE_KEY_STATUS_PRESSED == mLastVoiceKeyStatus) {
-                       mas_client_send_voice_key_status_change(pid, mLastVoiceKeyStatus);
+                       client_send_voice_key_status_change(pid, mLastVoiceKeyStatus);
                }
                if (current_maclient_appid && 0 == pid_appid.compare(current_maclient_appid)) {
                        MAS_LOGD("MA client with current maclient appid connected!");
@@ -1398,7 +1416,7 @@ int CServiceMain::on_initialize(int pid) {
                        if (0 == mWakeupClientAppId.compare(pid_appid)) {
                                mWakeupClientAppId.clear();
                                mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_ACTIVE);
-                               mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
+                               process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
                        } else {
                                MAS_LOGE("[ERROR] mWakeupClientAppId and appid differ : %s %s",
                                        mWakeupClientAppId.c_str(), pid_appid.c_str());
@@ -1407,7 +1425,7 @@ int CServiceMain::on_initialize(int pid) {
                        MAS_LOGD("MA client connected, but its appid does not match with current maclient");
                }
 
-               mServiceIpc.change_service_state(pid, mas_get_current_service_state());
+               mServiceIpc.change_service_state(pid, get_current_service_state());
        } else {
                MAS_LOGE("[ERROR] Fail to retrieve appid");
        }
@@ -1415,15 +1433,15 @@ int CServiceMain::on_initialize(int pid) {
        return 0;
 }
 
-int CServiceMain::on_deinitialize(int pid) {
+int CServiceMain::on_deinitialize(pid_t pid) {
        MAS_LOGD("[Enter] pid(%d)", pid);
        mClientManager.destroy_client_by_pid(pid);
        return 0;
 }
 
-int CServiceMain::on_get_audio_format(int pid, int& rate, int& channel, int& audio_type) {
+int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) {
        int main_rate, main_channel, main_audio_type;
-       int ret = mas_client_get_audio_format(pid,
+       int ret = client_get_audio_format(pid,
                &main_rate, &main_channel, &main_audio_type);
        rate = main_rate;
        channel = main_channel;
@@ -1431,85 +1449,85 @@ int CServiceMain::on_get_audio_format(int pid, int& rate, int& channel, int& aud
        return ret;
 }
 
-int CServiceMain::on_get_audio_source_type(int pid, std::string& type) {
+int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) {
        char *main_type = nullptr;
-       int ret = mas_client_get_audio_source_type(pid, &main_type);
+       int ret = client_get_audio_source_type(pid, &main_type);
        if (0 == ret && main_type) {
                type = std::string{main_type};
        }
        return ret;
 }
 
-int CServiceMain::on_send_asr_result(int pid, int event, std::string asr_result) {
-       return mas_client_send_asr_result(pid, event, asr_result.c_str());
+int CServiceMain::on_send_asr_result(pid_t pid, int event, std::string asr_result) {
+       return client_send_asr_result(pid, event, asr_result.c_str());
 }
 
-int CServiceMain::on_send_result(int pid, std::string display_text,
+int CServiceMain::on_send_result(pid_t pid, std::string display_text,
        std::string utterance_text, std::string result_json) {
-       return mas_client_send_result(pid,
+       return client_send_result(pid,
                display_text.c_str(), utterance_text.c_str(), result_json.c_str());
 }
 
-int CServiceMain::on_send_recognition_result(int pid, int result) {
-       return mas_client_send_recognition_result(pid, result);
+int CServiceMain::on_send_recognition_result(pid_t pid, int result) {
+       return client_send_recognition_result(pid, result);
 }
 
-int CServiceMain::on_start_streaming_audio_data(int pid, int type) {
-       return mas_client_start_streaming_audio_data(pid, type);
+int CServiceMain::on_start_streaming_audio_data(pid_t pid, int type) {
+       return client_start_streaming_audio_data(pid, type);
 }
 
-int CServiceMain::on_stop_streaming_audio_data(int pid, int type) {
-       return mas_client_stop_streaming_audio_data(pid, type);
+int CServiceMain::on_stop_streaming_audio_data(pid_t pid, int type) {
+       return client_stop_streaming_audio_data(pid, type);
 }
 
-int CServiceMain::on_update_voice_feedback_state(int pid, int state) {
-       return mas_client_update_voice_feedback_state(pid, state);
+int CServiceMain::on_update_voice_feedback_state(pid_t pid, int state) {
+       return client_update_voice_feedback_state(pid, state);
 }
 
-int CServiceMain::on_send_assistant_specific_command(int pid, std::string command) {
-       return mas_client_set_assistant_specific_command(pid, command.c_str());
+int CServiceMain::on_send_assistant_specific_command(pid_t pid, std::string command) {
+       return client_set_assistant_specific_command(pid, command.c_str());
 }
 
-int CServiceMain::on_set_background_volume(int pid, double ratio) {
-       return mas_client_set_background_volume(pid, ratio);
+int CServiceMain::on_set_background_volume(pid_t pid, double ratio) {
+       return client_set_background_volume(pid, ratio);
 }
 
-int CServiceMain::on_set_preprocessing_allow_mode(int pid, int mode, std::string app_id) {
-       return mas_client_set_preprocessing_allow_mode(pid,
+int CServiceMain::on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) {
+       return client_set_preprocessing_allow_mode(pid,
                static_cast<ma_preprocessing_allow_mode_e>(mode), app_id.c_str());
 }
 
-int CServiceMain::on_send_preprocessing_result(int pid, int result) {
-       return mas_client_send_preprocessing_result(pid, result);
+int CServiceMain::on_send_preprocessing_result(pid_t pid, int result) {
+       return client_send_preprocessing_result(pid, result);
 }
 
-int CServiceMain::on_set_wake_word_audio_require_flag(int pid, int require) {
-       return mas_client_set_wake_word_audio_require_flag(pid, require);
+int CServiceMain::on_set_wake_word_audio_require_flag(pid_t pid, int require) {
+       return client_set_wake_word_audio_require_flag(pid, require);
 }
 
-int CServiceMain::on_set_assistant_language(int pid, std::string language) {
-       return mas_client_set_assistant_language(pid, language.c_str());
+int CServiceMain::on_set_assistant_language(pid_t pid, std::string language) {
+       return client_set_assistant_language(pid, language.c_str());
 }
 
-int CServiceMain::on_add_wake_word(int pid, std::string wake_word, std::string language) {
-       return mas_client_add_wake_word(pid, wake_word.c_str(), language.c_str());
+int CServiceMain::on_add_wake_word(pid_t pid, std::string wake_word, std::string language) {
+       return client_add_wake_word(pid, wake_word.c_str(), language.c_str());
 }
 
-int CServiceMain::on_remove_wake_word(int pid, std::string wake_word, std::string language) {
-       return mas_client_remove_wake_word(pid, wake_word.c_str(), language.c_str());
+int CServiceMain::on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) {
+       return client_remove_wake_word(pid, wake_word.c_str(), language.c_str());
 }
 
-int CServiceMain::on_ui_initialize(int pid)
+int CServiceMain::on_ui_initialize(pid_t pid)
 {
-       return mas_ui_client_initialize(pid);
+       return ui_client_initialize(pid);
 }
 
-int CServiceMain::on_ui_deinitialize(int pid)
+int CServiceMain::on_ui_deinitialize(pid_t pid)
 {
-       return mas_ui_client_deinitialize(pid);
+       return ui_client_deinitialize(pid);
 }
 
 int CServiceMain::on_ui_change_assistant(std::string app_id)
 {
-       return mas_ui_client_change_assistant(app_id.c_str());
+       return ui_client_change_assistant(app_id.c_str());
 }
index eb02cf4..6cef985 100644 (file)
@@ -92,7 +92,7 @@ static Eina_Bool process_wakeup_event_by_appid_timer(void* data)
        char* appid = static_cast<char*>(param->data);
        MAS_LOGD("[ENTER] appid(%s)", appid);
 
-       int pid = -1;
+       pid_t pid = -1;
        if (!appid) return ECORE_CALLBACK_CANCEL;
 
        CServicePlugin* plugin = param->plugin;
@@ -103,7 +103,7 @@ static Eina_Bool process_wakeup_event_by_appid_timer(void* data)
                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 use_custom_ui = service_main->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) {
@@ -111,15 +111,15 @@ static Eina_Bool process_wakeup_event_by_appid_timer(void* data)
                        service_ipc->masc_ui_dbus_change_assistant(appid);
                }
 
-               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->set_current_client_by_appid(appid);
+               if ((pid = service_main->get_client_pid_by_appid(appid)) != -1) {
+                       service_main->client_send_preprocessing_information(pid);
                        service_ipc->change_active_state(pid, MA_ACTIVE_STATE_ACTIVE);
-                       service_main->mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
+                       service_main->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);
+                       service_main->launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
                }
        }
 
@@ -149,7 +149,7 @@ static Eina_Bool process_wakeup_event_by_word_timer(void* data)
        param = nullptr;
 
        if (service_main) {
-               const char* appid = service_main->mas_get_client_appid_by_wakeup_word(wakeup_word);
+               const char* appid = service_main->get_client_appid_by_wakeup_word(wakeup_word);
                if (appid) {
                        param = new(std::nothrow) AsyncParam;
                        if (param) {
@@ -262,7 +262,7 @@ static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data
        }
 }
 
-static bool __validate_streaming_event_order(int pid, mas_speech_streaming_event_e *event)
+static bool __validate_streaming_event_order(pid_t pid, mas_speech_streaming_event_e *event)
 {
        bool ret = false;
 
@@ -324,7 +324,7 @@ void handle_speech_streaming_event_failure(void* data)
        if (plugin) service_main = plugin->get_service_main();
 
        if (service_main) {
-               service_main->mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
+               service_main->client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
        }
 
        delete param;
@@ -352,8 +352,12 @@ static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffe
        }
 
        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();
+               /* First check if we have dedicated audio processing app for current client */
+               pid_t pid = service_main->get_current_audio_processing_pid();
+               /* If not, send audio data to the main client */
+               if (-1 == pid) pid = service_main->get_current_client_pid();
+
+               int preprocessing_pid = service_main->get_current_preprocessing_client_pid();
                if (pid == -1) {
                        MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
                } else {
@@ -417,8 +421,8 @@ static void __setting_changed_cb(void *user_data)
 
        CServiceMain* service_main = plugin->get_service_main();
        if (service_main) {
-               service_main->mas_prelaunch_default_assistant();
-               service_main->mas_update_voice_key_support_mode();
+               service_main->prelaunch_default_assistant();
+               service_main->update_voice_key_support_mode();
        }
        MAS_LOGD("[SUCCESS] __setting_changed_cb is called");
 }
@@ -433,7 +437,7 @@ static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e sec
        CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
        CServiceMain* service_main = plugin->get_service_main();
        if (service_ipc && service_main) {
-               int pid = service_main->mas_get_current_client_pid();
+               pid_t pid = service_main->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);
@@ -451,7 +455,7 @@ static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target
        CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
        CServiceMain* service_main = plugin->get_service_main();
        if (service_ipc && service_main) {
-               int pid = service_main->mas_get_client_pid_by_appid(assistant_name);
+               pid_t pid = service_main->get_client_pid_by_appid(assistant_name);
                if (-1 != pid) {
                        int ret = service_ipc->send_wakeup_engine_command(pid, command);
                        if (0 != ret) {
@@ -470,7 +474,7 @@ static void __wakeup_service_state_changed_cb(ma_service_state_e state, void* us
 
        CServiceMain* service_main = plugin->get_service_main();
        if (service_main) {
-               service_main->mas_set_current_service_state(state);
+               service_main->set_current_service_state(state);
        }
 }
 
@@ -484,7 +488,7 @@ static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e s
        CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
        CServiceMain* service_main = plugin->get_service_main();
        if (service_ipc && service_main) {
-               int pid = service_main->mas_get_current_client_pid();
+               pid_t pid = service_main->get_current_client_pid();
                int ret = service_ipc->change_voice_key_status(pid, status);
                if (0 != ret) {
                        MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret);
index da5cb94..1900dcc 100644 (file)
@@ -26,11 +26,12 @@ public:
        CDummyApplicationManager() {};
        virtual ~CDummyApplicationManager() {};
 
-       bool is_application_running(pid_t pid) { return true; }
-       bool is_application_running(const std::string& appid) { return true; }
-       bool bring_app_to_foreground(const std::string& appid) { return true; }
-       bool launch_app_async(const std::string& appid, bool background) { return true; }
-       boost::optional<std::string> get_appid_by_pid(pid_t pid) { return boost::optional<std::string>{}; }
+       bool is_application_running(pid_t pid) override { return true; }
+       bool is_application_running(const std::string& appid) override { return true; }
+       bool bring_app_to_foreground(const std::string& appid) override { return true; }
+       bool launch_app_async(const std::string& appid, bool background) override { return true; }
+       boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
+       boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
 };
 
 class StorageWithNoClient : public testing::Test
@@ -51,7 +52,7 @@ public:
 
 TEST_F(StorageWithNoClient, HasOneClientAfterCreate) {
        const std::string arbitrary_client_appid{"Client1"};
-       const int arbitrary_client_pid{1};
+       const pid_t arbitrary_client_pid{1};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
 
@@ -62,7 +63,7 @@ TEST_F(StorageWithNoClient, HasOneClientAfterCreate) {
 
 TEST_F(StorageWithNoClient, ValidityReturnsTrueForCreatedClient) {
        const std::string arbitrary_client_appid{"Client1"};
-       const int arbitrary_client_pid{1};
+       const pid_t arbitrary_client_pid{1};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
 
@@ -73,7 +74,7 @@ TEST_F(StorageWithNoClient, ValidityReturnsTrueForCreatedClient) {
 
 TEST_F(StorageWithNoClient, ValidityReturnsFalseForNotCreatedClient) {
        const std::string arbitrary_client_appid{"Client1"};
-       const int arbitrary_client_pid{1};
+       const pid_t arbitrary_client_pid{1};
 
        const std::string noexist_client_appid{"Client987654321"};
 
@@ -97,82 +98,82 @@ public:
        void TearDown() override {
        }
        const std::string preloaded_client_appid_1{"Client1"};
-       const int preloaded_client_pid_1{1};
+       const pid_t preloaded_client_pid_1{1};
        CClientManager client_manager;
        CDummyApplicationManager application_manager;
 };
 
 TEST_F(StorageWithOneClient, ReturnsExistingPIDByIndex) {
        const std::string arbitrary_client_appid{"Client2"};
-       const int arbitrary_client_pid{2};
+       const pid_t arbitrary_client_pid{2};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
 
-       int pid = client_manager.find_client_pid_by_index(0);
+       pid_t pid = client_manager.find_client_pid_by_index(0);
 
        ASSERT_EQ(pid, preloaded_client_pid_1);
 }
 
 TEST_F(StorageWithOneClient, ReturnsCreatedPIDByIndex) {
        const std::string arbitrary_client_appid{"Client2"};
-       const int arbitrary_client_pid{2};
+       const pid_t arbitrary_client_pid{2};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
 
-       int pid = client_manager.find_client_pid_by_index(1);
+       pid_t pid = client_manager.find_client_pid_by_index(1);
 
        ASSERT_EQ(pid, arbitrary_client_pid);
 }
 
 TEST_F(StorageWithOneClient, PreservesExistingItemNotRequestedForRemoval) {
        const std::string arbitrary_client_appid{"Client2"};
-       const int arbitrary_client_pid{2};
+       const pid_t arbitrary_client_pid{2};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
        client_manager.destroy_client_by_pid(arbitrary_client_pid);
 
-       int pid = client_manager.find_client_pid_by_index(0);
+       pid_t pid = client_manager.find_client_pid_by_index(0);
 
        ASSERT_EQ(pid, preloaded_client_pid_1);
 }
 
 TEST_F(StorageWithOneClient, PreservesCreatedItemNotRequestedForRemoval) {
        const std::string arbitrary_client_appid{"Client2"};
-       const int arbitrary_client_pid{2};
+       const pid_t arbitrary_client_pid{2};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
        client_manager.destroy_client_by_pid(preloaded_client_pid_1);
 
-       int pid = client_manager.find_client_pid_by_index(0);
+       pid_t pid = client_manager.find_client_pid_by_index(0);
 
        ASSERT_EQ(pid, arbitrary_client_pid);
 }
 
 TEST_F(StorageWithOneClient, ReturnsCorrectExistingPIDByAppID) {
        const std::string arbitrary_client_appid{"Client2"};
-       const int arbitrary_client_pid{2};
+       const pid_t arbitrary_client_pid{2};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
 
-       int pid = client_manager.find_client_pid_by_appid(preloaded_client_appid_1);
+       pid_t pid = client_manager.find_client_pid_by_appid(preloaded_client_appid_1);
 
        ASSERT_EQ(pid, preloaded_client_pid_1);
 }
 
 TEST_F(StorageWithOneClient, ReturnsCorrectCreatedPIDByAppID) {
        const std::string arbitrary_client_appid{"Client2"};
-       const int arbitrary_client_pid{2};
+       const pid_t arbitrary_client_pid{2};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
 
-       int pid = client_manager.find_client_pid_by_appid(arbitrary_client_appid);
+       pid_t pid = client_manager.find_client_pid_by_appid(arbitrary_client_appid);
 
        ASSERT_EQ(pid, arbitrary_client_pid);
 }
 
 TEST_F(StorageWithOneClient, ReturnsCorrectExistingAppIDByPID) {
        const std::string arbitrary_client_appid{"Client2"};
-       const int arbitrary_client_pid{2};
+       const pid_t arbitrary_client_pid{2};
 
        client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
 
index b14cf72..807e52b 100644 (file)
@@ -42,6 +42,7 @@ public:
                return true;
        }
        boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
+       boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
 public:
        boost::optional<std::string> launched_appid;
        boost::optional<bool> launched_option_background;
@@ -114,7 +115,7 @@ TEST_F(DefaultFixure, BringsDefaultAssistantToFrontOnAssistantActivatedPreproces
        ma_assistant_info_s info;
        info.app_id = assistant_appid.c_str();
        service.add_assistant_info(&info);
-       service.mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
+       service.process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
 
        bool brought = false;
        if (application_manager.brought_to_foreground_appid) {