From 03113a0628f8ac51cd4f1eccc3d4d6b2bd0ab0f7 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 17 Sep 2019 16:31:57 +0900 Subject: [PATCH] Add API : ma_send_preprocessing_result Change-Id: I89e4aaf610516355ceae56ffa091e3af3516ac2e --- client/ma.c | 37 +++++++++++++++++++++++++++++ client/ma_dbus.c | 49 +++++++++++++++++++++++++++++++++++++++ client/ma_dbus.h | 2 ++ common/ma_defs.h | 1 + include/multi_assistant.h | 19 +++++++++++++++ 5 files changed, 108 insertions(+) diff --git a/client/ma.c b/client/ma.c index 627cea9..6e4ff98 100644 --- a/client/ma.c +++ b/client/ma.c @@ -1633,4 +1633,41 @@ int ma_unset_preprocessing_information_changed_cb(void) ma_client_set_preprocessing_information_changed_cb(g_ma, NULL, NULL); return MA_ERROR_NONE; +} + +int ma_send_preprocessing_result(bool is_success) +{ + SLOG(LOG_DEBUG, TAG_MAC, "[Manager] Send preprocessing result"); + + if (0 != __ma_get_feature_enabled()) { + SLOG(LOG_DEBUG, TAG_MAC, "@@@ [Manager] not supported"); + return MA_ERROR_NOT_SUPPORTED; + } + + if (0 != __ma_check_privilege()) { + return MA_ERROR_PERMISSION_DENIED; + } + + ma_state_e state; + if (0 != ma_client_get_client_state(g_ma, &state)) { + SLOG(LOG_ERROR, TAG_MAC, "[ERROR] A handle is not available"); + SLOG(LOG_DEBUG, TAG_MAC, "@@@"); + return MA_ERROR_INVALID_STATE; + } + + if (state != MA_STATE_READY) { + SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); + SLOG(LOG_DEBUG, TAG_MAC, "@@@"); + return MA_ERROR_INVALID_STATE; + } + + /* Send preprocessing result */ + int pid = getpid(); + int ret = ma_dbus_send_preprocessing_result(pid, is_success); + if (0 != ret) { + SLOG(LOG_WARN, TAG_MAC, "[WARNING] retry to send preprocessing result"); + } else { + SLOG(LOG_DEBUG, TAG_MAC, "[DEBUG] Success to send"); + } + return ret; } \ No newline at end of file diff --git a/client/ma_dbus.c b/client/ma_dbus.c index 278be1d..69f268e 100644 --- a/client/ma_dbus.c +++ b/client/ma_dbus.c @@ -1252,3 +1252,52 @@ int ma_dbus_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e return 0; } + +int ma_dbus_send_preprocessing_result(int pid, bool result) +{ + if (0 != __dbus_check()) { + return MA_ERROR_OPERATION_FAILED; + } + + DBusMessage* msg; + + msg = dbus_message_new_method_call( + MA_SERVER_SERVICE_NAME, + MA_SERVER_SERVICE_OBJECT_PATH, + MA_SERVER_SERVICE_INTERFACE, + MA_METHOD_SEND_PREPROCESSING_RESULT); + + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_MAC, "@@ Request multi-assistant send preprocessing result : Fail to make message"); //LCOV_EXCL_LINE + return MA_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_MAC, "[DEBUG] multi-assistant send preprocessing result"); + } + + int tmp_result = (result ? 1 : 0); + dbus_message_append_args(msg, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &tmp_result, + DBUS_TYPE_INVALID); + + dbus_message_set_no_reply(msg, TRUE); + + DBusError error; + dbus_error_init (&error); + if (!dbus_connection_send(g_conn_sender, msg, NULL)) { + if (dbus_error_is_set (&error)) { + SLOG(LOG_ERROR, TAG_MAC, "[Dbus ERROR] Fail to Send : %s", error.message); //LCOV_EXCL_LINE + dbus_error_free (&error); + } else { + SLOG(LOG_ERROR, TAG_MAC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE + } + return MA_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_MAC, "[Dbus DEBUG] Success to Send"); + dbus_connection_flush(g_conn_sender); + } + + dbus_message_unref(msg); + + return 0; +} diff --git a/client/ma_dbus.h b/client/ma_dbus.h index 2dc4cf8..73cb77b 100644 --- a/client/ma_dbus.h +++ b/client/ma_dbus.h @@ -59,6 +59,8 @@ int ma_dbus_set_background_volume(int pid, double ratio); int ma_dbus_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char *app_id); +int ma_dbus_send_preprocessing_result(int pid, bool result); + #ifdef __cplusplus } #endif diff --git a/common/ma_defs.h b/common/ma_defs.h index c4cb5b4..f5d59aa 100644 --- a/common/ma_defs.h +++ b/common/ma_defs.h @@ -78,6 +78,7 @@ extern "C" #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" diff --git a/include/multi_assistant.h b/include/multi_assistant.h index 09b2ffc..afe8587 100644 --- a/include/multi_assistant.h +++ b/include/multi_assistant.h @@ -638,6 +638,25 @@ int ma_set_preprocessing_information_changed_cb(ma_preprocessing_information_cha */ int ma_unset_preprocessing_information_changed_cb(void); +/** + * @brief Sends the preprocessing result. + * @since_tizen 5.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] is_success The result value to be sent, indicating whether the preprocessing succeeded or not + * + * @return @c 0 on success, otherwise a negative error value + * @retval #MA_ERROR_NONE Successful + * @retval #MA_ERROR_NOT_SUPPORTED Not supported + * @retval #MA_ERROR_PERMISSION_DENIED Permission denied + * @retval #MA_ERROR_INVALID_STATE Invalid state + * @retval #MA_ERROR_OPERATION_FAILED Operation failed + * + * @pre The state should be #MA_STATE_READY. + */ +int ma_send_preprocessing_result(bool is_success); + #ifdef __cplusplus } #endif -- 2.34.1