return MA_ERROR_NONE;
}
+
+int __ma_ui_cb_enable_common_ui(bool enable)
+{
+ ma_ui_enable_common_ui_cb callback = NULL;
+ void* user_data;
+
+ ma_ui_client_get_enable_common_ui_cb(g_ma_ui, &callback, &user_data);
+
+ if (NULL != callback) {
+ ma_ui_client_use_callback(g_ma_ui);
+ callback(enable, user_data);
+ ma_ui_client_not_use_callback(g_ma_ui);
+ SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] enable common UI callback is called");
+ } else {
+ SLOG(LOG_DEBUG, TAG_MAUI, "[WARNING] enable common UI callback is NULL");
+ }
+
+ return MA_ERROR_NONE;
+}
+
int ma_ui_get_state(ma_state_e* state)
{
if (0 != __ma_ui_get_feature_enabled()) {
return MA_ERROR_NONE;
}
+int ma_ui_set_enable_common_ui_cb(ma_ui_enable_common_ui_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;
+ }
+
+ 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_enable_common_ui_cb(g_ma_ui, callback, user_data);
+
+ return MA_ERROR_NONE;
+}
+
+int ma_ui_unset_enable_common_ui_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_enable_common_ui_cb(g_ma_ui, NULL, NULL);
+
+ return MA_ERROR_NONE;
+}
+
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;
ma_state_changed_cb state_changed_cb;
void* state_changed_user_data;
ma_language_changed_cb lang_changed_cb;
void* lang_changed_user_data;
+ ma_ui_recognition_result_cb recognition_result_cb;
+ void* recognition_result_user_data;
+ ma_ui_enable_common_ui_cb enable_common_ui_cb;
+ void* enable_common_ui_user_data;
/* ASR result */
ma_asr_result_event_e asr_result_event;
char* asr_result_text;
- ma_ui_recognition_result_cb recognition_result_cb;
- void* recognition_result_user_data;
-
/* state */
ma_state_e previous_state;
ma_state_e current_state;
client->state_changed_user_data = NULL;
client->lang_changed_cb = NULL;
client->lang_changed_user_data = NULL;
+ client->recognition_result_cb = NULL;
+ client->recognition_result_user_data = NULL;
+ client->enable_common_ui_cb = NULL;
+ client->enable_common_ui_user_data = NULL;
client->asr_result_event = 0;
client->asr_result_text = NULL;
return MA_ERROR_NONE;
}
+int ma_ui_client_set_enable_common_ui_cb(ma_h ma, ma_ui_enable_common_ui_cb callback, void* user_data)
+{
+ ma_ui_client_s* client = __ui_client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ client->enable_common_ui_cb = callback;
+ client->enable_common_ui_user_data = user_data;
+
+ return MA_ERROR_NONE;
+}
+
+int ma_ui_client_get_enable_common_ui_cb(ma_h ma, ma_ui_enable_common_ui_cb* callback, void** user_data)
+{
+ ma_ui_client_s* client = __ui_client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ *callback = client->enable_common_ui_cb;
+ *user_data = client->enable_common_ui_user_data;
+
+ return MA_ERROR_NONE;
+}
int ma_ui_client_get_recognition_result_cb(ma_h ma, ma_ui_recognition_result_cb* callback, void** user_data);
+int ma_ui_client_set_enable_common_ui_cb(ma_h ma, ma_ui_enable_common_ui_cb callback, void* user_data);
+
+int ma_ui_client_get_enable_common_ui_cb(ma_h ma, ma_ui_enable_common_ui_cb* callback, void** user_data);
#ifdef __cplusplus
}
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);
extern int __ma_ui_cb_send_recognition_result(int result);
+extern int __ma_ui_cb_enable_common_ui(int enable);
static Eina_Bool ma_ui_listener_event_callback(void* data, Ecore_Fd_Handler* fd_handler)
{
__ma_ui_cb_send_recognition_result(result);
}
- } /* MAS_UI_METHOD_SEND_RESULT */
+ } /* MAS_UI_METHOD_SEND_RECOGNITION_RESULT */
+
+ if (dbus_message_is_method_call(msg, if_name, MAS_UI_METHOD_ENABLE_COMMON_UI)) {
+ SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] Send recognition result");
+ int enable = 0;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &enable,
+ 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 Enable common UI : enable(%d)", enable);
+
+ __ma_ui_cb_enable_common_ui((enable) ? true : false);
+ }
+
+ } /* MAS_UI_METHOD_ENABLE_COMMON_UI */
+
else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) {
SLOG(LOG_DEBUG, TAG_MAUI, "[DEBUG] Owner Changed");
/* remove a rule for daemon error */
#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_SEND_RECOGNITION_RESULT "mas_ui_method_send_recognition_result"
#define MAS_UI_METHOD_ERROR "mas_ui_method_error"
+#define MAS_UI_METHOD_SEND_RECOGNITION_RESULT "mas_ui_method_send_recognition_result"
+#define MAS_UI_METHOD_ENABLE_COMMON_UI "mas_ui_method_enable_common_ui"
/**************************************************************************************
*** Definitions for xml file
*/
typedef void (*ma_ui_recognition_result_cb)(ma_recognition_result_event_e result, void* user_data);
+/**
+ * @brief Called when the multi-assistant service enables or disables the common UI.
+ * @since_tizen 5.5
+ *
+ * @param[in] enable The status whether the common UI is enabled
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @see ma_ui_set_enable_common_ui_cb()
+ * @see ma_ui_set_enable_common_ui_cb()
+ */
+typedef void (*ma_ui_enable_common_ui_cb)(bool enable, void* user_data);
+
/**
* @brief Initializes multi-assistant UI.
* @since_tizen 5.0
* @pre The state should be #MA_STATE_INITIALIZED.
*/
int ma_ui_unset_recognition_result_cb(void);
+
+/**
+ * @brief Sets a callback for getting common UI enabled status.
+ * @since_tizen 5.5
+ *
+ * @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_enable_common_ui_cb(ma_ui_enable_common_ui_cb callback, void* user_data);
+
+/**
+ * @brief Unsets a callback for common UI enabled status.
+ * @since_tizen 5.5
+ *
+ * @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_enable_common_ui_cb(void);
+
#ifdef __cplusplus
}
#endif