2 * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __VOICE_CONTROL_COMMAND_H__
19 #define __VOICE_CONTROL_COMMAND_H__
24 * @defgroup CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE Voice control command
25 * @ingroup CAPI_UIX_VOICE_CONTROL_MODULE
27 * @brief The @ref CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE API provides functions for creating/destroying command list and add/remove/retrieve commands of list.
38 * @brief Definition for fixed command format
41 #define VC_COMMAND_FORMAT_FIXED 0
44 * @brief Definition for fixed and variable fixed command format
47 #define VC_COMMAND_FORMAT_FIXED_AND_VFIXED 1
50 * @brief Definition for variable fixed and fixed command format
53 #define VC_COMMAND_FORMAT_VFIXED_AND_FIXED 2
56 * @brief Definition for fixed and non-fixed command format
59 #define VC_COMMAND_FORMAT_FIXED_AND_NONFIXED 3
62 * @brief Definition for non-fixed and fixed command format
65 #define VC_COMMAND_FORMAT_NONFIXED_AND_FIXED 4
69 * @brief The voice command handle.
70 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
72 typedef struct vc_cmd_s* vc_cmd_h;
75 * @brief The voice command list handle.
76 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
78 typedef struct vc_cmd_list_s* vc_cmd_list_h;
81 * @brief Called to retrieve The commands in list.
82 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
84 * @param[in] vc_command The command handle
85 * @param[in] user_data The user data passed from the foreach function
87 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
88 * @pre vc_cmd_list_foreach_commands() will invoke this callback.
90 * @see vc_cmd_list_foreach_commands()
92 typedef bool (*vc_cmd_list_cb)(vc_cmd_h vc_command, void* user_data);
96 * @brief Creates a handle for command list.
97 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
99 * @remarks If the function succeeds, @a The list handle must be released with vc_cmd_list_destroy().
101 * @param[out] vc_cmd_list The command list handle
103 * @return 0 on success, otherwise a negative error value
104 * @retval #VC_ERROR_NONE Successful
105 * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory
106 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
107 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
108 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
110 * @see vc_cmd_list_destroy()
112 int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list);
115 * @brief Destroys the handle for command list.
116 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
118 * @param[in] vc_cmd_list The command list handle
119 * @param[in] free_command The command free option @c true = release each commands in list,
120 * @c false = remove command from list
122 * @return 0 on success, otherwise a negative error value
123 * @retval #VC_ERROR_NONE Successful
124 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
125 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
126 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
128 * @see vc_cmd_list_create()
130 int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool free_command);
133 * @brief Gets command count of list.
134 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
136 * @param[in] vc_cmd_list The command list handle
137 * @param[out] count The count
139 * @return 0 on success, otherwise a negative error value
140 * @retval #VC_ERROR_NONE Successful
141 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
142 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
143 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
145 int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count);
148 * @brief Adds command to command list.
149 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
151 * @param[in] vc_cmd_list The command list handle
152 * @param[in] vc_command The command handle
154 * @return 0 on success, otherwise a negative error value
155 * @retval #VC_ERROR_NONE Successful
156 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
157 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
158 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
160 * @see vc_cmd_list_remove()
162 int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command);
165 * @brief Removes command from command list.
166 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
168 * @param[in] vc_cmd_list The command list handle
169 * @param[in] vc_command The command handle
171 * @return 0 on success, otherwise a negative error value
172 * @retval #VC_ERROR_NONE Successful
173 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
174 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
175 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
177 * @see vc_cmd_list_add()
179 int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command);
182 * @brief Retrieves all commands of command list using callback function.
183 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
185 * @param[in] vc_cmd_list The command list handle
186 * @param[in] callback Callback function to invoke
187 * @param[in] user_data The user data to be passed to the callback function
189 * @return 0 on success, otherwise a negative error value
190 * @retval #VC_ERROR_NONE Successful
191 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
192 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
193 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
195 * @post This function invokes vc_cmd_list_cb() repeatedly for getting commands.
197 * @see vc_cmd_list_cb()
199 int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data);
202 * @brief Retrieves all commands on the system command list using a callback function.
205 * @param[in] callback Callback function to invoke
206 * @param[in] user_data The user data to be passed to the callback function
208 * @return 0 on success, otherwise a negative error value
209 * @retval #VC_ERROR_NONE Successful
210 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
211 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
212 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
214 * @post This function invokes vc_cmd_list_cb() for each command.
216 * @see vc_cmd_list_cb()
218 int vc_cmd_list_foreach_system_command(vc_cmd_list_cb callback, void* user_data);
221 * @brief Moves index to first command.
222 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
224 * @param[in] vc_cmd_list The command list handle
226 * @return 0 on success, otherwise a negative error value
227 * @retval #VC_ERROR_NONE Successful
228 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
229 * @retval #VC_ERROR_EMPTY List empty
230 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
231 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
233 * @see vc_cmd_list_last()
235 int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list);
238 * @brief Moves index to last command.
239 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
241 * @param[in] vc_cmd_list The command list handle
243 * @return 0 on success, otherwise a negative error value
244 * @retval #VC_ERROR_NONE Successful
245 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
246 * @retval #VC_ERROR_EMPTY List empty
247 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
248 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
250 * @see vc_cmd_list_first()
252 int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list);
255 * @brief Moves index to next command.
256 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
258 * @param[in] vc_cmd_list The command list handle
260 * @return 0 on success, otherwise a negative error value
261 * @retval #VC_ERROR_NONE Successful
262 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
263 * @retval #VC_ERROR_EMPTY List empty
264 * @retval #VC_ERROR_ITERATION_END List reached end
265 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
266 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
268 * @see vc_cmd_list_prev()
270 int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list);
273 * @brief Moves index to previous command.
274 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
276 * @param[in] vc_cmd_list The command list handle
278 * @return 0 on success, otherwise a negative error value
279 * @retval #VC_ERROR_NONE Successful
280 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
281 * @retval #VC_ERROR_EMPTY List empty
282 * @retval #VC_ERROR_ITERATION_END List reached end
283 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
284 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
286 * @see vc_cmd_list_next()
288 int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list);
291 * @brief Get current command from command list by index.
292 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
294 * @param[in] vc_cmd_list The command list handle
295 * @param[out] vc_command The command handle
297 * @return 0 on success, otherwise a negative error value
298 * @retval #VC_ERROR_NONE Successful
299 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
300 * @retval #VC_ERROR_EMPTY List empty
301 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
302 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
304 * @see vc_cmd_list_first()
305 * @see vc_cmd_list_last()
306 * @see vc_cmd_list_prev()
307 * @see vc_cmd_list_next()
309 int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command);
312 * @brief Creates a handle for command.
313 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
315 * @remarks If the function succeeds, @a The command handle must be released
316 * with vc_cmd_destroy() or vc_cmd_list_destroy().
317 * You should set command and type if command is valid.
318 * The command format is set to #VC_CMD_FORMAT_FIXED by default and can be changed with vc_cmd_set_format().
320 * @param[out] vc_command The command handle
322 * @return 0 on success, otherwise a negative error value
323 * @retval #VC_ERROR_NONE Successful
324 * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory
325 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
326 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
327 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
329 * @see vc_cmd_destroy()
331 int vc_cmd_create(vc_cmd_h* vc_command);
334 * @brief Destroys the handle.
335 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
337 * @param[in] vc_command The command handle
339 * @return 0 on success, otherwise a negative error value
340 * @retval #VC_ERROR_NONE Successful
341 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
342 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
343 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
345 * @see vc_cmd_create()
347 int vc_cmd_destroy(vc_cmd_h vc_command);
350 * @brief Sets command or action.
351 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
353 * @param[in] vc_command The command handle
354 * @param[in] command The command or action text
356 * @return 0 on success, otherwise a negative error value
357 * @retval #VC_ERROR_NONE Successful
358 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
359 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
360 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
362 * @see vc_cmd_get_command()
364 int vc_cmd_set_command(vc_cmd_h vc_command, const char* command);
367 * @brief Gets command.
368 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
370 * @remark If the function succeeds, @a command must be released with free() by you if they are not NULL.
372 * @param[in] vc_command The command handle
373 * @param[out] command The command text
375 * @return 0 on success, otherwise a negative error value
376 * @retval #VC_ERROR_NONE Successful
377 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
378 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
379 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
381 * @see vc_cmd_set_command()
383 int vc_cmd_get_command(vc_cmd_h vc_command, char** command);
386 * @brief Gets the unfixed command.
389 * @remark If the function succeeds, the @a command must be released with free() if it is not NULL.
390 * If the command of the given @a vc_command is NULL (@a vc_command is NOT NULL), @a command will be also NULL.
391 * This function should be used for commands which have non-fixed format.
393 * @param[in] vc_command The command handle
394 * @param[out] command The unfixed command text
396 * @return 0 on success, otherwise a negative error value
397 * @retval #VC_ERROR_NONE Successful
398 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
399 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
400 * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature
402 int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command);
405 * @brief Sets command type.
406 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
408 * @remark If you do not set the command type, the default value is -1.
409 * You should set type if command is valid
411 * @param[in] vc_command The command handle
412 * @param[in] type The command type
414 * @return 0 on success, otherwise a negative error value
415 * @retval #VC_ERROR_NONE Successful
416 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
417 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
418 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
420 * @see vc_cmd_get_type()
422 int vc_cmd_set_type(vc_cmd_h vc_command, int type);
425 * @brief Gets command type.
426 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
428 * @param[in] vc_command The command handle
429 * @param[out] type The command type
431 * @return 0 on success, otherwise a negative error value
432 * @retval #VC_ERROR_NONE Successful
433 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
434 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
435 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
437 * @see vc_cmd_set_type()
439 int vc_cmd_get_type(vc_cmd_h vc_command, int* type);
442 * @brief Sets the command format.
445 * @remark The default format is #VC_CMD_FORMAT_FIXED.
447 * @param[in] vc_command The command handle
448 * @param[in] format The command format
450 * @return 0 on success, otherwise a negative error value
451 * @retval #VC_ERROR_NONE Successful
452 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
453 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
454 * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature
456 * @see vc_cmd_get_format()
458 int vc_cmd_set_format(vc_cmd_h vc_command, int format);
461 * @brief Gets the command format.
464 * @remark The default format is #VC_CMD_FORMAT_FIXED.
466 * @param[in] vc_command The command handle
467 * @param[out] format The command format
469 * @return 0 on success, otherwise a negative error value
470 * @retval #VC_ERROR_NONE Successful
471 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
472 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
473 * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature
475 * @see vc_cmd_set_format()
477 int vc_cmd_get_format(vc_cmd_h vc_command, int* format);
488 #endif /* __VOICE_CONTROL_COMMAND_H__ */