Clean up code according to coding rule
[platform/core/uifw/voice-control.git] / include / voice_control_common.h
1 /*
2 * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #ifndef __VOICE_CONTROL_COMMON_H__
19 #define __VOICE_CONTROL_COMMON_H__
20
21 #include <voice_control_command.h>
22
23 /**
24 * @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE
25 * @{
26 */
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 /**
34 * @brief Enumerations of error codes.
35 * @since_tizen 2.4
36 */
37 typedef enum {
38         VC_ERROR_NONE                   = TIZEN_ERROR_NONE,                     /**< Successful */
39         VC_ERROR_OUT_OF_MEMORY          = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of Memory */
40         VC_ERROR_IO_ERROR               = TIZEN_ERROR_IO_ERROR,                 /**< I/O error */
41         VC_ERROR_INVALID_PARAMETER      = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
42         VC_ERROR_TIMED_OUT              = TIZEN_ERROR_TIMED_OUT,                /**< No answer from service */
43         VC_ERROR_RECORDER_BUSY          = TIZEN_ERROR_RESOURCE_BUSY,            /**< Busy recorder */
44         VC_ERROR_PERMISSION_DENIED      = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
45         VC_ERROR_NOT_SUPPORTED          = TIZEN_ERROR_NOT_SUPPORTED,            /**< VC NOT supported */
46         VC_ERROR_INVALID_STATE          = TIZEN_ERROR_VOICE_CONTROL | 0x011,    /**< Invalid state */
47         VC_ERROR_INVALID_LANGUAGE       = TIZEN_ERROR_VOICE_CONTROL | 0x012,    /**< Invalid language */
48         VC_ERROR_ENGINE_NOT_FOUND       = TIZEN_ERROR_VOICE_CONTROL | 0x013,    /**< No available engine */
49         VC_ERROR_OPERATION_FAILED       = TIZEN_ERROR_VOICE_CONTROL | 0x014,    /**< Operation failed */
50         VC_ERROR_OPERATION_REJECTED     = TIZEN_ERROR_VOICE_CONTROL | 0x015,    /**< Operation rejected */
51         VC_ERROR_ITERATION_END          = TIZEN_ERROR_VOICE_CONTROL | 0x016,    /**< List reached end */
52         VC_ERROR_EMPTY                  = TIZEN_ERROR_VOICE_CONTROL | 0x017     /**< List empty */
53 } vc_error_e;
54
55 /**
56 * @brief Enumerations of result event.
57 * @since_tizen 2.4
58 */
59 typedef enum {
60         VC_RESULT_EVENT_RESULT_SUCCESS  = 0,    /**< Normal result */
61         VC_RESULT_EVENT_REJECTED        = 1     /**< Rejected result */
62 } vc_result_event_e;
63
64 /**
65 * @brief Enumerations of service state.
66 * @since_tizen 2.4
67 */
68 typedef enum {
69         VC_SERVICE_STATE_NONE           = 0,    /**< 'None' state */
70         VC_SERVICE_STATE_READY          = 1,    /**< 'Ready' state */
71         VC_SERVICE_STATE_RECORDING      = 2,    /**< 'Recording' state */
72         VC_SERVICE_STATE_PROCESSING     = 3     /**< 'Processing' state */
73 } vc_service_state_e;
74
75 /**
76 * @brief Enumerations of client state.
77 * @since_tizen 2.4
78 */
79 typedef enum {
80         VC_STATE_NONE                   = 0,    /**< 'None' state */
81         VC_STATE_INITIALIZED            = 1,    /**< 'Initialized' state */
82         VC_STATE_READY                  = 2     /**< 'Ready' state */
83 } vc_state_e;
84
85
86 /**
87 * @brief Called when client gets the recognition result.
88 * @since_tizen 2.4
89 *
90 * @remarks If the duplicated commands are recognized, the event(e.g. #VC_RESULT_EVENT_REJECTED) of command may be rejected \n
91 *       for selecting command as priority. If you set similar or same commands or the recognized results are multi-results,
92 *       vc_cmd_list has the multi commands.
93 *
94 * @param[in] event The result event (e.g. #VC_RESULT_EVENT_RESULT_SUCCESS, #VC_RESULT_EVENT_REJECTED)
95 * @param[in] vc_cmd_list The recognized command list
96 * @param[in] result The spoken text
97 * @param[in] user_data The user data passed from the callback registration function
98 *
99 * @pre An application registers callback function.
100 *
101 * @see vc_set_result_cb()
102 */
103 typedef void (*vc_result_cb)(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void *user_data);
104
105 /**
106 * @brief Called when default language is changed.
107 * @since_tizen 2.4
108 *
109 * @param[in] previous Previous language
110 * @param[in] current Current language
111 * @param[in] user_data The user data passed from the callback registration function
112 *
113 * @pre An application registers this callback to detect changing mode.
114 *
115 * @see vc_set_current_language_changed_cb()
116 */
117 typedef void (*vc_current_language_changed_cb)(const char* previous, const char* current, void* user_data);
118
119 /**
120 * @brief Called to retrieve supported language.
121 * @since_tizen 2.4
122 *
123 * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
124 *               followed by ISO 639-1 for the two-letter language code. \n
125 *               For example, "ko_KR" for Korean, "en_US" for American English.
126 * @param[in] user_data The user data passed from the foreach function
127 *
128 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
129 *
130 * @pre The function will invoke this callback.
131 */
132 typedef bool (*vc_supported_language_cb)(const char* language, void* user_data);
133
134 /**
135 * @brief Called when the state of voice control client is changed.
136 * @since_tizen 2.4
137 *
138 * @param[in] previous A previous state
139 * @param[in] current A current state
140 * @param[in] user_data The user data passed from the callback registration function
141 *
142 * @pre An application registers this callback to detect changing state.
143 *
144 * @see vc_set_state_changed_cb()
145 */
146 typedef void (*vc_state_changed_cb)(vc_state_e previous, vc_state_e current, void* user_data);
147
148 /**
149 * @brief Called when the state of voice control service is changed.
150 * @since_tizen 2.4
151 *
152 * @param[in] previous A previous state
153 * @param[in] current A current state
154 * @param[in] user_data The user data passed from the callback registration function
155 *
156 * @pre An application registers this callback to detect changing service state.
157 *
158 * @see vc_set_service_state_changed_cb()
159 */
160 typedef void (*vc_service_state_changed_cb)(vc_service_state_e previous, vc_service_state_e current, void* user_data);
161
162 /**
163 * @brief Called when error occurred.
164 * @since_tizen 2.4
165 *
166 * @param[in] reason The error type (e.g. #VC_ERROR_OUT_OF_MEMORY, #VC_ERROR_TIMED_OUT)
167 * @param[in] user_data The user data passed from the callback registration function
168 *
169 * @pre An application registers this callback to detect error.
170 *
171 * @see vc_set_error_cb()
172 */
173 typedef void (*vc_error_cb)(vc_error_e reason, void *user_data);
174
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180 /**
181  * @}@}
182  */
183
184 #endif /* VOICE_CONTROL_COMMON */