static int g_feature_enabled = -1;
+static bool g_err_callback_status = false;
+
const char* stt_tag()
{
return "sttc";
return STT_ERROR_NONE;
}
+int stt_get_error_message(stt_h stt, char** err_msg)
+{
+ if (0 != __stt_get_feature_enabled()) {
+ return STT_ERROR_NOT_SUPPORTED;
+ }
+
+ if (NULL == stt || NULL == err_msg) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (false == g_err_callback_status) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] This callback should be called during an err_callback");
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ stt_client_s* client = stt_client_get(stt);
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get error msg : A handle is not valid");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL != client->err_msg) {
+ *err_msg = strdup(client->err_msg);
+ SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Error msg (%s)", *err_msg);
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Error msg (NULL)");
+ }
+
+ SLOG(LOG_DEBUG, TAG_STTC, "=====");
+ SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+ return STT_ERROR_NONE;
+}
+
int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support)
{
if (0 != __stt_get_feature_enabled()) {
if (NULL != client->error_cb) {
stt_client_use_callback(client);
+ g_err_callback_status = true;
client->error_cb(client->stt, client->reason, client->error_user_data);
+ g_err_callback_status = false;
stt_client_not_use_callback(client);
SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is called : reason [%d]", client->reason);
} else {
return EINA_FALSE;
}
-int __stt_cb_error(int uid, int reason)
+int __stt_cb_error(int uid, int reason, char* err_msg)
{
stt_client_s* client = stt_client_get_by_uid(uid);
if (NULL == client) {
client->reason = reason;
client->internal_state = STT_INTERNAL_STATE_NONE;
+ if (NULL != client->err_msg) {
+ free(client->err_msg);
+ client->err_msg = NULL;
+ }
+ client->err_msg = strdup(err_msg);
+
SLOG(LOG_INFO, TAG_STTC, "internal state is initialized to 0");
if (NULL != client->error_cb) {
client->data_count = 0;
client->msg = NULL;
+ client->reason = 0;
+ client->err_msg = NULL;
+
client->before_state = STT_STATE_CREATED;
client->current_state = STT_STATE_CREATED;
free(data->current_engine_id);
}
+ if (NULL != data->err_msg) {
+ free(data->err_msg);
+ }
+
free(data);
free(stt);
/* error data */
int reason;
+ char* err_msg;
} stt_client_s;
static DBusConnection* g_conn_listener = NULL;
-extern int __stt_cb_error(int uid, int reason);
+extern int __stt_cb_error(int uid, int reason, char* err_msg);
extern int __stt_cb_result(int uid, int event, char** data, int data_count, const char* msg);
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt Get Error message : Get arguments error (%s)", err.message);
dbus_error_free(&err);
} else {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), msg(%s)", uid, reason, err_msg);
- __stt_cb_error(uid, reason);
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), err_msg(%s)", uid, reason, (NULL == err_msg) ? "NULL" : err_msg);
+ __stt_cb_error(uid, reason, err_msg);
}
SLOG(LOG_DEBUG, TAG_STTC, "=====");
int stt_get_state(stt_h stt, stt_state_e* state);
/**
+ * @brief Gets the current error message.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ * @remarks This function should be called during an stt error callback. If not, the error as operation failure will be returned. \n
+ * If the function succeeds, @a err_msg must be released using free() when it is no longer required.
+ *
+ * @param[in] stt The STT handle
+ * @param[out] err_msg The current error message
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STT_ERROR_NONE Successful
+ * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
+ * @retval #STT_ERROR_OPERATION_FAILED Operation failure
+ *
+ * @see stt_set_error_cb()
+ * @see stt_unset_error_cb()
+*/
+int stt_get_error_message(stt_h stt, char** err_msg);
+
+/**
* @brief Checks whether the recognition type is supported.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @privlevel public
if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] <<<< error message : Out Of Memory !");
} else {
- SLOG(LOG_DEBUG, TAG_STTD, "<<<< Send error message : uid(%d), reason(%d), err_msg(%s)", uid, reason, err_msg);
+ SLOG(LOG_DEBUG, TAG_STTD, "<<<< Send error message : uid(%d), reason(%d), err_msg(%s)", uid, reason, (NULL == err_msg) ? "NULL" : err_msg);
dbus_connection_flush(g_conn_sender);
}