Add missing handler for preprocessing result message
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 17 Sep 2019 07:12:26 +0000 (16:12 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 18 Sep 2019 01:58:31 +0000 (10:58 +0900)
Change-Id: Ia462aab4a2665147ff307d3d7471bc7705de26ca

inc/multi_assistant_main.h
inc/multi_assistant_service.h
src/multi_assistant_dbus.c
src/multi_assistant_dbus_server.c
src/multi_assistant_dbus_server.h
src/multi_assistant_service.c

index 89cad53..4fcc7ef 100644 (file)
@@ -64,6 +64,7 @@
 #define MA_METHOD_SEND_ASSISTANT_SPECIFIC_COMMAND      "ma_method_send_assistant_specific_command"
 #define MA_METHOD_SET_BACKGROUND_VOLUME                                "ma_method_set_background_volume"
 #define MA_METHOD_SET_PREPROCESSING_ALLOW_MODE         "ma_method_set_preprocessing_allow_mode"
+#define MA_METHOD_SEND_PREPROCESSING_RESULT                    "ma_method_send_preprocessing_result"
 #define MA_METHOD_ERROR                                                                "ma_method_error"
 
 #define MA_UI_METHOD_INITIALIZE                                                "ma_ui_method_initialize"
index 60b0361..862dcd1 100644 (file)
@@ -55,6 +55,8 @@ int mas_client_set_background_volume(int pid, double ratio);
 
 int mas_client_set_preprocessing_allow_mode(int pid, int mode, const char* appid);
 
+int mas_client_send_preprocessing_result(int pid, bool result);
+
 int mas_client_update_recognition_result(int pid, int result);
 
 int mas_ui_client_initialize(int pid);
index fd8ffcc..cd9fb36 100644 (file)
@@ -763,6 +763,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                } 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);
 
+               } 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);
+
                } 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);
 
index b79c157..c2bff18 100644 (file)
@@ -601,6 +601,37 @@ int ma_service_dbus_set_preprocessing_allow_mode(DBusConnection* conn, DBusMessa
        return 0;
 }
 
+int ma_service_dbus_send_preprocessing_result(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       int pid;
+       int ret = 0;
+       int result;
+
+       dbus_message_get_args(msg, &err,
+               DBUS_TYPE_INT32, &pid,
+               DBUS_TYPE_INT32, &result,
+               DBUS_TYPE_INVALID);
+
+       MAS_LOGD("[DEBUG] MAS SEND PREPROCESSING RESULT");
+
+       if (dbus_error_is_set(&err)) {
+               MAS_LOGE("[IN ERROR] mas send preprocessing result : Get arguments error (%s)", err.message);
+               dbus_error_free(&err);
+               ret = -1; //MAS_ERROR_OPERATION_FAILED;
+       } else {
+               MAS_LOGD("[IN] mas send preprocessing result : pid(%d), result(%d)", pid, result);
+               ret =  mas_client_send_preprocessing_result(pid, (bool)result);
+       }
+
+       MAS_LOGD("<<<<<");
+       MAS_LOGD("  ");
+
+       return 0;
+}
+
 int ma_service_ui_dbus_initialize(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
index f988b18..a205cac 100644 (file)
@@ -51,6 +51,8 @@ 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_ui_dbus_initialize(DBusConnection* conn, DBusMessage* msg);
 
 int ma_service_ui_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg);
index 38d28f8..1c4eff0 100644 (file)
@@ -466,6 +466,24 @@ int mas_client_set_preprocessing_allow_mode(int pid, int mode, const char* appid
        return 0;
 }
 
+int mas_client_send_preprocessing_result(int pid, bool result)
+{
+       const char* pid_appid = NULL;
+       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;
+       }
+       if (!is_current_preprocessing_assistant(pid_appid)) return -1;
+
+       if (result) {
+               mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED);
+       } else {
+               mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED);
+       }
+       return 0;
+}
+
 int mas_client_update_recognition_result(int pid, int state)
 {
        multi_assistant_service_plugin_update_recognition_result(NULL, state);