Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.VoiceControl / Interop / Interop.VoiceControl.cs
1 /*
2 * Copyright (c) 2016 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 using System;
19 using System.Runtime.InteropServices;
20 using Tizen.Uix.VoiceControl;
21 using static Interop.VoiceControlCommand;
22
23 /// <summary>
24 /// Partial Interop Class
25 /// </summary>
26 internal static partial class Interop
27 {
28     /// <summary>
29     /// VoiceControl Interop Class
30     /// </summary>
31     internal static class VoiceControl
32     {
33         internal static string LogTag = "Tizen.Uix.VoiceControl";
34
35         private const int ErrorVoiceControl = -0x02F50000;
36
37         internal enum ErrorCode
38         {
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 (Since 3.0) */
55             InProgressToReady = ErrorVoiceControl | 0x019,  /**< In progress to ready (Since 3.0) */
56             InProgressToRecording = ErrorVoiceControl | 0x020,  /**< In progress to recording (Since 3.0) */
57             InProgressToProcessing = ErrorVoiceControl | 0x021  /**< In progress to processing (Since 3.0) */
58         };
59
60         internal enum VoiceCommandType
61         {
62             Foreground = 1,   /* Foreground command type. */
63             BackGround = 2   /* background command type. */
64         };
65
66         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_initialize")]
67         internal static extern ErrorCode VcInitialize();
68
69         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_deinitialize")]
70         internal static extern ErrorCode VcDeinitialize();
71
72         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_prepare")]
73         internal static extern ErrorCode VcPrepare();
74
75         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unprepare")]
76         internal static extern ErrorCode VcUnprepare();
77
78         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_foreach_supported_languages")]
79         internal static extern ErrorCode VcForeachSupportedLanguages(VcSupportedLanguageCb callback, IntPtr userData);
80
81         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_current_language")]
82         internal static extern ErrorCode VcGetCurrentLanguage(out string language);
83
84         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_state")]
85         internal static extern ErrorCode VcGetState(out State state);
86
87         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_service_state")]
88         internal static extern ErrorCode VcGetServiceState(out ServiceState state);
89
90         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_system_command_list")]
91         internal static extern ErrorCode VcGetSystemCommandList(out IntPtr vc_sys_cmd_list);
92
93         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_invocation_name")]
94         internal static extern ErrorCode VcSetInvocationName(string name);
95
96         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_request_dialog")]
97         internal static extern ErrorCode VcRequestDialog(string dispText, string uttText, bool autoStart);
98
99         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_command_list")]
100         internal static extern ErrorCode VcSetCommandList(SafeCommandListHandle cmdList, VoiceCommandType type);
101
102         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_command_list")]
103         internal static extern ErrorCode VcUnsetCommandList(VoiceCommandType type);
104
105         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_result")]
106         internal static extern ErrorCode VcGetResult(VcResultCb callback, IntPtr userData);
107
108         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_result_cb")]
109         internal static extern ErrorCode VcSetResultCb(VcResultCb callback, IntPtr userData);
110
111         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_result_cb")]
112         internal static extern ErrorCode VcUnsetResultCb();
113
114         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_service_state_changed_cb")]
115         internal static extern ErrorCode VcSetServiceStateChangedCb(VcServiceStateChangedCb callback, IntPtr userData);
116
117         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_service_state_changed_cb")]
118         internal static extern ErrorCode VcUnsetServiceStateChangedCb();
119
120         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_state_changed_cb")]
121         internal static extern ErrorCode VcSetStateChangedCb(VcStateChangedCb callback, IntPtr userData);
122
123         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_state_changed_cb")]
124         internal static extern ErrorCode VcUnsetStateChangedCb();
125
126         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_current_language_changed_cb")]
127         internal static extern ErrorCode VcSetCurrentLanguageChangedCb(VcCurrentLanguageChangedCb callback, IntPtr userData);
128
129         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_current_language_changed_cb")]
130         internal static extern ErrorCode VcUnsetCurrentLanguageChangedCb();
131
132         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_error_cb")]
133         internal static extern ErrorCode VcSetErrorCb(VcErrorCb callback, IntPtr userData);
134
135         [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_error_cb")]
136         internal static extern ErrorCode VcUnsetErrorCb();
137
138         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
139         internal delegate void VcResultCb(ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData);
140
141         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
142         internal delegate void VcCurrentLanguageChangedCb(IntPtr previous, IntPtr current, IntPtr userData);
143
144         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
145         internal delegate bool VcSupportedLanguageCb(IntPtr language, IntPtr userData);
146
147         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
148         internal delegate void VcStateChangedCb(State previous, State current, IntPtr userData);
149
150         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
151         internal delegate void VcServiceStateChangedCb(ServiceState previous, ServiceState current, IntPtr userData);
152
153         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
154         internal delegate void VcErrorCb(ErrorCode reason, IntPtr userData);
155     }
156 }