2 * Copyright (c) 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.
19 using System.Runtime.InteropServices;
20 using Tizen.Uix.VoiceControl;
21 using static Interop.VoiceControlCommand;
24 /// Partial interop class.
26 internal static partial class Interop
29 /// VoiceControl interop class.
31 internal static class VoiceControl
33 internal static string LogTag = "Tizen.Uix.VoiceControl";
35 private const int ErrorVoiceControl = -0x02F50000;
37 internal enum ErrorCode
39 None = Tizen.Internals.Errors.ErrorCode.None, /* Successful */
40 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /* Out of Memory */
41 IoError = Tizen.Internals.Errors.ErrorCode.IoError, /* I/O error */
42 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /* Invalid parameter */
43 TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut, /* No answer from service */
44 RecorderBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy, /* Busy recorder */
45 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /* Permission denied */
46 NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /* VC NOT supported */
47 InvalidState = ErrorVoiceControl | 0x011, /* Invalid state */
48 InvalidLanguage = ErrorVoiceControl | 0x012, /* Invalid language */
49 EngineNotFound = ErrorVoiceControl | 0x013, /* No available engine */
50 OperationFailed = ErrorVoiceControl | 0x014, /* Operation failed */
51 OperationRejected = ErrorVoiceControl | 0x015, /* Operation rejected */
52 IterationEnd = ErrorVoiceControl | 0x016, /* List reached end */
53 Empty = ErrorVoiceControl | 0x017, /* List empty */
54 ServiceReset = ErrorVoiceControl | 0x018, /* Service daemon reset */
55 InProgressToReady = ErrorVoiceControl | 0x019, /* In progress to ready */
56 InProgressToRecording = ErrorVoiceControl | 0x020, /* In progress to recording */
57 InProgressToProcessing = ErrorVoiceControl | 0x021 /* In progress to processing */
60 internal enum VoiceCommandType
62 Foreground = 1, /* Foreground command type. */
63 BackGround = 2 /* background command type. */
66 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_initialize")]
67 internal static extern ErrorCode VcInitialize();
69 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_deinitialize")]
70 internal static extern ErrorCode VcDeinitialize();
72 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_prepare")]
73 internal static extern ErrorCode VcPrepare();
75 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unprepare")]
76 internal static extern ErrorCode VcUnprepare();
78 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_foreach_supported_languages")]
79 internal static extern ErrorCode VcForeachSupportedLanguages(VcSupportedLanguageCb callback, IntPtr userData);
81 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_current_language")]
82 internal static extern ErrorCode VcGetCurrentLanguage(out string language);
84 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_state")]
85 internal static extern ErrorCode VcGetState(out State state);
87 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_service_state")]
88 internal static extern ErrorCode VcGetServiceState(out ServiceState state);
90 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_system_command_list")]
91 internal static extern ErrorCode VcGetSystemCommandList(out IntPtr vc_sys_cmd_list);
93 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_invocation_name")]
94 internal static extern ErrorCode VcSetInvocationName(string name);
96 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_request_dialog")]
97 internal static extern ErrorCode VcRequestDialog(string dispText, string uttText, bool autoStart);
99 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_command_list")]
100 internal static extern ErrorCode VcSetCommandList(SafeCommandListHandle cmdList, VoiceCommandType type);
102 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_command_list")]
103 internal static extern ErrorCode VcUnsetCommandList(VoiceCommandType type);
105 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_result")]
106 internal static extern ErrorCode VcGetResult(VcResultCb callback, IntPtr userData);
108 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_result_cb")]
109 internal static extern ErrorCode VcSetResultCb(VcResultCb callback, IntPtr userData);
111 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_result_cb")]
112 internal static extern ErrorCode VcUnsetResultCb();
114 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_service_state_changed_cb")]
115 internal static extern ErrorCode VcSetServiceStateChangedCb(VcServiceStateChangedCb callback, IntPtr userData);
117 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_service_state_changed_cb")]
118 internal static extern ErrorCode VcUnsetServiceStateChangedCb();
120 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_state_changed_cb")]
121 internal static extern ErrorCode VcSetStateChangedCb(VcStateChangedCb callback, IntPtr userData);
123 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_state_changed_cb")]
124 internal static extern ErrorCode VcUnsetStateChangedCb();
126 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_current_language_changed_cb")]
127 internal static extern ErrorCode VcSetCurrentLanguageChangedCb(VcCurrentLanguageChangedCb callback, IntPtr userData);
129 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_current_language_changed_cb")]
130 internal static extern ErrorCode VcUnsetCurrentLanguageChangedCb();
132 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_error_cb")]
133 internal static extern ErrorCode VcSetErrorCb(VcErrorCb callback, IntPtr userData);
135 [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_error_cb")]
136 internal static extern ErrorCode VcUnsetErrorCb();
138 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
139 internal delegate void VcResultCb(ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData);
141 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
142 internal delegate void VcCurrentLanguageChangedCb(IntPtr previous, IntPtr current, IntPtr userData);
144 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
145 internal delegate bool VcSupportedLanguageCb(IntPtr language, IntPtr userData);
147 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
148 internal delegate void VcStateChangedCb(State previous, State current, IntPtr userData);
150 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
151 internal delegate void VcServiceStateChangedCb(ServiceState previous, ServiceState current, IntPtr userData);
153 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
154 internal delegate void VcErrorCb(ErrorCode reason, IntPtr userData);