return result;
}
-int ma_dbus_request_speech_data(int pid)
-{
- 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_REQUEST_SPEECH_DATA);
-
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_MAC, "@@ Request multi-assistant recording audio format : Fail to make message"); //LCOV_EXCL_LINE
- return MA_ERROR_OPERATION_FAILED;
- } else {
- SLOG(LOG_DEBUG, TAG_MAC, "[DEBUG] multi-assistant recording audio format");
- }
-
- dbus_message_append_args(msg,
- DBUS_TYPE_INT32, &pid,
- DBUS_TYPE_INVALID);
-
- DBusError err;
- dbus_error_init(&err);
-
- DBusMessage* result_msg = NULL;
- int result = MA_ERROR_OPERATION_FAILED;
-
- result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
- dbus_message_unref(msg);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_DEBUG, TAG_MAC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE
- dbus_error_free(&err);
- }
-
- if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err,
- DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_MAC, "@@ Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- result = MA_ERROR_OPERATION_FAILED;
- }
- dbus_message_unref(result_msg);
-
- if (0 == result) {
- SLOG(LOG_DEBUG, TAG_MAC, "@@ multi-assistant request speech data : result = %d", result);
- } else {
- SLOG(LOG_ERROR, TAG_MAC, "@@ multi-assistant request speech data : result = %d", result);
- }
- } else {
- SLOG(LOG_ERROR, TAG_MAC, "@@ Result message is NULL");
- ma_dbus_reconnect();
- result = MA_ERROR_TIMED_OUT;
- }
-
- return result;
-}
-
int ma_dbus_get_recording_audio_format(int pid, int *rate, ma_audio_channel_e *channel, ma_audio_type_e *audio_type)
{
int ma_dbus_request_deinitialize(int pid);
-
int ma_dbus_get_recording_audio_format(int pid, int *rate, ma_audio_channel_e *channel, ma_audio_type_e *audio_type);
int ma_dbus_send_asr_result(int pid, ma_asr_result_event_e event, const char* asr_result);
return MA_ERROR_NONE;
}
+static void __ma_ui_notify_change_assistant(const char* app_id)
+{
+ ma_ui_change_assistant_cb callback = NULL;
+ void* user_data;
+
+ ma_ui_client_get_change_assistant_cb(g_ma_ui, &callback, &user_data);
+
+ if (NULL != callback) {
+ ma_ui_client_use_callback(g_ma_ui);
+ callback(app_id, user_data);
+ ma_ui_client_not_use_callback(g_ma_ui);
+ SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] result callback is called");
+ } else {
+ SLOG(LOG_DEBUG, TAG_MAUI, "[WARNING] result callback is NULL");
+ }
+}
+
+int __ma_ui_cb_change_assistant(const char* app_id)
+{
+ ma_state_e state;
+ if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
+ SLOG(LOG_ERROR, TAG_MAUI, "[ERROR] Invalid client");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
+ SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] change assitant, app_id(%s)", app_id);
+ __ma_ui_notify_change_assistant(app_id);
+
+ return MA_ERROR_NONE;
+}
+
int __ma_ui_cb_error(int reason, char* msg)
{
ma_state_e state;
return MA_ERROR_NONE;
}
+int ma_ui_set_change_assistant_cb(ma_ui_change_assistant_cb callback, void* user_data)
+{
+ if (0 != __ma_ui_get_feature_enabled()) {
+ SLOG(LOG_DEBUG, TAG_MAUI, "@@@ [UI] not supported");
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_MAUI, "[UI] Set a default assistant");
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_MAUI, "[UI ERROR] Invalid parameter");
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
+ ma_state_e state;
+ if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
+ SLOG(LOG_ERROR, TAG_MAUI, "[UI ERROR] A handle is not available");
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (MA_STATE_INITIALIZED!= state) {
+ SLOG(LOG_ERROR, TAG_MAUI, "[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_ui_client_set_change_assistant_cb(g_ma_ui, callback, user_data);
+
+ return MA_ERROR_NONE;
+}
+
+int ma_ui_unset_change_assistant_cb(void)
+{
+ if (0 != __ma_ui_get_feature_enabled()) {
+ SLOG(LOG_DEBUG, TAG_MAUI, "@@@ [UI] not supported");
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_MAUI, "[UI] Set a default assistant");
+
+ ma_state_e state;
+ if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
+ SLOG(LOG_ERROR, TAG_MAUI, "[UI ERROR] A handle is not available");
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (MA_STATE_INITIALIZED!= state) {
+ SLOG(LOG_ERROR, TAG_MAUI, "[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_ui_client_set_change_assistant_cb(g_ma_ui, NULL, NULL);
+
+ return MA_ERROR_NONE;
+}
+
void* result_user_data;
ma_ui_asr_result_cb asr_result_cb;
void* asr_result_user_data;
+ ma_ui_change_assistant_cb change_assistant_cb;
+ void* change_assistant_user_data;
ma_error_cb error_cb;
void* error_user_data;
client->result_user_data = NULL;
client->asr_result_cb = NULL;
client->asr_result_user_data = NULL;
+ client->change_assistant_cb = NULL;
+ client->change_assistant_user_data = NULL;
client->error_cb = NULL;
client->error_user_data = NULL;
return MA_ERROR_NONE;
}
+int ma_ui_client_set_change_assistant_cb(ma_h ma, ma_ui_change_assistant_cb callback, void* user_data)
+{
+ ma_ui_client_s* client = __ui_client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ client->change_assistant_cb = callback;
+ client->change_assistant_user_data = user_data;
+
+ return MA_ERROR_NONE;
+}
+
+int ma_ui_client_get_change_assistant_cb(ma_h ma, ma_ui_change_assistant_cb* callback, void** user_data)
+{
+ ma_ui_client_s* client = __ui_client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ *callback = client->change_assistant_cb;
+ *user_data = client->change_assistant_user_data;
+
+ return MA_ERROR_NONE;
+}
+
int ma_ui_client_set_error_cb(ma_h ma, ma_error_cb callback, void* user_data)
{
ma_ui_client_s* client = __ui_client_get(ma);
int ma_ui_client_get_result_cb(ma_h ma, ma_ui_result_cb* callback, void** user_data);
+int ma_ui_client_set_change_assistant_cb(ma_h ma, ma_ui_change_assistant_cb callback, void* user_data);
+
+int ma_ui_client_get_change_assistant_cb(ma_h ma, ma_ui_change_assistant_cb* callback, void** user_data);
+
int ma_ui_client_set_error_cb(ma_h ma, ma_error_cb callback, void* user_data);
int ma_ui_client_get_error_cb(ma_h ma, ma_error_cb* callback, void** user_data);
extern int __ma_ui_cb_error(int reason, char* msg);
extern int __ma_ui_cb_send_asr_result(int event, char* asr_result);
extern int __ma_ui_cb_send_result(const char* display_text, const char* utterance_text, const char* result_json);
+extern int __ma_ui_cb_change_assistant(const char* app_id);
static Eina_Bool ma_ui_listener_event_callback(void* data, Ecore_Fd_Handler* fd_handler)
} /* MAS_UI_METHOD_SEND_RESULT */
+ if (dbus_message_is_method_call(msg, if_name, MAS_UI_METHOD_CHANGE_ASSISTANT)) {
+ SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] Send change assistant request");
+ char* app_id = NULL;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_STRING, &app_id,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_MAUI, "[ERROR] Dbus Error (%s)", err.message);
+ dbus_error_free(&err);
+ } else {
+ SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] multi-assistant ui Send change assistant request : app_id(%s)", app_id);
+
+ __ma_ui_cb_change_assistant(app_id);
+ }
+
+ } /* MAS_UI_METHOD_CHANGE_ASSISTANT */
+
else if (dbus_message_is_signal(msg, if_name, MAS_UI_METHOD_ERROR)) {
SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] Get Error");
int reason;
#define MAS_UI_METHOD_HELLO "mas_ui_method_hello"
#define MAS_UI_METHOD_SEND_ASR_RESULT "mas_ui_method_send_asr_result"
#define MAS_UI_METHOD_SEND_RESULT "mas_ui_method_send_result"
+#define MAS_UI_METHOD_CHANGE_ASSISTANT "mas_ui_method_change_assistant"
#define MAS_UI_METHOD_ERROR "mas_ui_method_error"
/**************************************************************************************
*/
int ma_send_result(const char* display_text, const char* utterance_text, const char* result_json);
-
#ifdef __cplusplus
}
#endif
*/
typedef void (*ma_ui_result_cb)(const char* display_text, const char* utterance_text, const char* result_json, void* user_data);
+/**
+ * @brief Called when the multi-assistant service sends the request for changing assistant.
+ * @since_tizen 5.0
+ * @remarks The @a app_id can be used only in the callback. To use outside, make a copy.
+ *
+ * @param[in] app_id The text shown on the display
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ */
+typedef void (*ma_ui_change_assistant_cb)(const char* app_id, void* user_data);
/**
* @brief Initializes multi-assistant UI.
*/
int ma_ui_unset_result_cb(void);
+/**
+ * @brief Sets a callback for getting change assistant info.
+ * @since_tizen 5.0
+ *
+ * @param[in] callback The callback function
+ * @param[in] user_data The user data passed to the callback function
+ *
+ * @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_INVALID_PARAMETER Invalid parameter
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #MA_STATE_INITIALIZED.
+ */
+int ma_ui_set_change_assistant_cb(ma_ui_change_assistant_cb callback, void* user_data);
+/**
+ * @brief Unsets a callback for getting change assistant info.
+ * @since_tizen 5.0
+ *
+ * @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_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #MA_STATE_INITIALIZED.
+ */
+int ma_ui_unset_change_assistant_cb(void);
#ifdef __cplusplus
}