*/
#include <aul.h>
+#include <system_info.h>
#include "vc_client.h"
#include "vc_command.h"
static vc_h g_vc = NULL;
+static int g_feature_enabled = -1;
+
#if 0
static Ecore_Event_Handler* g_focus_in_hander = NULL;
static Ecore_Event_Handler* g_focus_out_hander = NULL;
Eina_Bool __vc_notify_state_changed(void *data);
Eina_Bool __vc_notify_error(void *data);
+static int __vc_get_feature_enabled()
+{
+ if (0 == g_feature_enabled) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported");
+ return VC_ERROR_NOT_SUPPORTED;
+ } else if (-1 == g_feature_enabled) {
+ bool vc_supported = false;
+ bool mic_supported = false;
+ if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) {
+ if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) {
+ if (false == vc_supported || false == mic_supported) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported");
+ g_feature_enabled = 0;
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
+ g_feature_enabled = 1;
+ }
+ }
+ }
+
+ return 0;
+}
static const char* __vc_get_error_code(vc_error_e err)
{
int vc_initialize(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Initialize");
/* check handle */
int vc_deinitialize(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Deinitialize");
if (false == vc_client_is_valid(g_vc)) {
int vc_prepare(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Prepare");
vc_state_e state;
int vc_unprepare(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Unprepare");
vc_state_e state;
int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user_data)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Foreach Supported Language");
if (NULL == callback) {
int vc_get_current_language(char** language)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get Current Language");
if (NULL == language) {
int vc_get_state(vc_state_e* state)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get State");
if (NULL == state) {
int vc_get_service_state(vc_service_state_e* state)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Get Service State");
if (NULL == state) {
int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Set Command list");
if (NULL == vc_cmd_list) {
int vc_unset_command_list(int type)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Unset Command list");
vc_state_e state;
int vc_set_exclusive_command_option(bool value)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCC, "===== [Client] Set exclusive command");
vc_state_e state;
int vc_set_result_cb(vc_result_cb callback, void* user_data)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == callback)
return VC_ERROR_INVALID_PARAMETER;
int vc_unset_result_cb(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
vc_state_e state;
if (0 != vc_client_get_client_state(g_vc, &state)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : A handle is not available");
int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == callback)
return VC_ERROR_INVALID_PARAMETER;
int vc_unset_service_state_changed_cb(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
vc_state_e state;
if (0 != vc_client_get_client_state(g_vc, &state)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : A handle is not available");
int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (callback == NULL)
return VC_ERROR_INVALID_PARAMETER;
int vc_unset_state_changed_cb(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
vc_state_e state;
if (0 != vc_client_get_client_state(g_vc, &state)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset state changed callback : A handle is not available");
int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == callback)
return VC_ERROR_INVALID_PARAMETER;
int vc_unset_current_language_changed_cb(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
vc_state_e state;
if (0 != vc_client_get_client_state(g_vc, &state)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset current language changed : A handle is not available");
int vc_set_error_cb(vc_error_cb callback, void* user_data)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == callback)
return VC_ERROR_INVALID_PARAMETER;
int vc_unset_error_cb(void)
{
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
vc_state_e state;
if (0 != vc_client_get_client_state(g_vc, &state)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset error callback : A handle is not available");
#include <libintl.h>
#include <stdlib.h>
+#include <system_info.h>
#include "vc_command.h"
#include "vc_main.h"
#include "voice_control_common.h"
#include "voice_control_key_defines.h"
+static int g_feature_enabled = -1;
+
+static int __vc_cmd_get_feature_enabled()
+{
+ if (0 == g_feature_enabled) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported");
+ return VC_ERROR_NOT_SUPPORTED;
+ } else if (-1 == g_feature_enabled) {
+ bool vc_supported = false;
+ bool mic_supported = false;
+ if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) {
+ if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) {
+ if (false == vc_supported || false == mic_supported) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported");
+ g_feature_enabled = 0;
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
+ g_feature_enabled = 1;
+ }
+ }
+ }
+
+ return 0;
+}
int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool release_command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list || NULL == count) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Get command count : Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list || NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list || NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_remove_all(vc_cmd_list_h vc_cmd_list, bool release_command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
SLOG(LOG_DEBUG, TAG_VCCMD, "===== Destroy all command");
if (NULL == vc_cmd_list) {
int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_cmd_list || NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_create(vc_cmd_h* vc_command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_destroy(vc_cmd_h vc_command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_set_id(vc_cmd_h vc_command, int id)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_get_id(vc_cmd_h vc_command, int* id)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command || NULL == id) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_set_command(vc_cmd_h vc_command, const char* command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_get_command(vc_cmd_h vc_command, char** command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command || NULL == command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command || NULL == command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid handle ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_set_type(vc_cmd_h vc_command, int type)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_get_type(vc_cmd_h vc_command, int* type)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command || NULL == type) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_set_format(vc_cmd_h vc_command, vc_cmd_format_e format)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_get_format(vc_cmd_h vc_command, vc_cmd_format_e* format)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command || NULL == format) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_set_pid(vc_cmd_h vc_command, int pid)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command || NULL == pid) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_set_domain(vc_cmd_h vc_command, int domain)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain)
{
+ if (0 != __vc_cmd_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
if (NULL == vc_command || NULL == domain) {
SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Invalid parameter ");
return VC_ERROR_INVALID_PARAMETER;
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
*/
* @defgroup CAPI_UIX_VOICE_CONTROL_MODULE Voice control
* @ingroup CAPI_UIX_FRAMEWORK
* @brief The @ref CAPI_UIX_VOICE_CONTROL_MODULE API provides functions for registering command and getting notification when registered command is recognized.
- *
+ *
* @section CAPI_UIX_VOICE_CONTROL_MODULE_HEADER Required Header
* \#include <voice_control.h><br>
- *
+ *
* @section CAPI_UIX_VOICE_CONTROL_MODULE_OVERVIEW Overview
* A main function of Voice Control API register command and gets notification for recognition result.
* Applications can add their own commands and be provided result when their command is recognized by user voice input.
- *
- * To use of Voice Control, use the following steps:
+ *
+ * To use of Voice Control, use the following steps: <br>
* 1. Initialize <br>
- * 2. Register callback functions for notifications <br>
+ * 2. Register callback functions for notifications <br>
* 3. Connect to voice control service asynchronously. The state should be changed to Ready <br>
- * 4. Make command list as the following step <br>
+ * 4. Make command list as the following step and Step 4 is called repeatedly for each command which an application wants <br>
* 4-1. Create command list handle <br>
* 4-2. Create command handle <br>
* 4-3. Set command and type for command handle <br>
* 4-4. Add command handle to command list <br>
- * Step 4 is called repeatedly for each command which an application wants <br>
* 5. Set command list for recognition <br>
* 6. If an application wants to finish voice control,<br>
* 6-1. Destroy command and command list handle <br>
* 6-2. Deinitialize <br>
*
- * An application can obtain command handle from command list, and also get information from handle.
+ * An application can obtain command handle from command list, and also get information from handle.
*
*
- * The Voice Control API also notifies you (by callback mechanism) when the states of client and service are changed,
+ * The Voice Control API also notifies you (by callback mechanism) when the states of client and service are changed,
* command is recognized, current language is changed or error occurred.
- * An application should register callback functions: vc_state_changed_cb(), vc_service_state_changed_cb(), vc_result_cb(),
+ * An application should register callback functions: vc_state_changed_cb(), vc_service_state_changed_cb(), vc_result_cb(),
* vc_current_language_changed_cb(), vc_error_cb().
*
* @section CAPI_UIX_VOICE_CONTROL_MODULE_STATE_DIAGRAM State Diagram
* The following table shows state-dependent function calls.
* It is forbidden to call functions listed below in wrong states.
* Violation of this rule may result in an unpredictable behavior.
- *
+ *
* <table>
* <tr>
* <th>FUNCTION</th>
* <td> All callback function should be registered in Initialized state </td>
* </tr>
* </table>
- *
- * @section CAPI_UIX_STT_MODULE_FEATURE Related Features
+ *
+ * @section CAPI_UIX_VOICE_CONTROL_MODULE Related Features
* This API is related with the following features:<br>
* - http://tizen.org/feature/microphone<br>
+ * - http://tizen.org/feature/speech.control<br>
*
* It is recommended to design feature related codes in your application for reliability.<br>
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.<br>