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.
17 using static Interop.VoiceControlCommand;
18 using static Interop.VoiceControlWidget;
20 namespace Tizen.Uix.VoiceControlWidget
23 /// Enumeration for the command format.
25 /// <since_tizen> 3 </since_tizen>
26 public enum CommandFormat
29 /// The fixed command format.
33 /// The fixed and variable fixed command format.
37 /// The variable fixed and fixed command format.
41 /// The fixed and non-fixed command format.
45 /// The non-fixed and fixed command format.
49 /// The action command
53 /// The partial matched command
63 /// This class represents a voice command.
65 /// <since_tizen> 3 </since_tizen>
66 public class VoiceCommand
68 internal SafeCommandHandle _handle;
71 /// The public constructor.
73 /// <since_tizen> 3 </since_tizen>
74 /// <exception cref="InvalidOperationException">This exception can be due to an invalid state.</exception>
75 /// <exception cref="OutOfMemoryException">This exception can be due to out Of memory.</exception>
76 /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
77 /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
80 SafeCommandHandle handle;
81 ErrorCode error = VcCmdCreate(out handle);
82 if (error != ErrorCode.None)
84 Log.Error(LogTag, "Create Failed with error " + error);
85 throw ExceptionFactory.CreateException(error);
90 internal VoiceCommand(SafeCommandHandle handle)
96 /// Gets the unfixed command.
97 /// This property should be used for commands which have non-fixed format.
98 /// An empty string will be returned in case of some internal error.
100 /// <since_tizen> 3 </since_tizen>
101 public string UnfixedCommand
105 string unfixedCommand;
106 ErrorCode error = VcCmdGetUnfixedCommand(_handle, out unfixedCommand);
107 if (error != ErrorCode.None)
109 Log.Error(LogTag, "UnfixedCommand Failed with error " + error);
113 return unfixedCommand;
118 /// Gets or sets the command type.
120 /// <since_tizen> 3 </since_tizen>
121 /// <remarks>If you do not set the command type, the default value is undefined. You should set the type if the command is valid.</remarks>
122 /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
123 /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
124 public CommandType Type
128 CommandType cmdType = CommandType.Undefined;
130 ErrorCode error = VcCmdGetType(_handle, out type);
131 if (error != ErrorCode.None)
133 Log.Error(LogTag, "GetType Failed with error " + error);
134 return CommandType.Undefined;
139 cmdType = (CommandType)type;
146 ErrorCode error = VcCmdSetType(_handle, value);
147 if (error != ErrorCode.None)
149 Log.Error(LogTag, "SetType Failed with error " + error);
155 /// Gets or sets the command format.
157 /// <since_tizen> 3 </since_tizen>
158 /// <remarks>The default format is Fixed.</remarks>
159 /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
160 /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
161 public CommandFormat Format
165 CommandFormat format;
166 ErrorCode error = VcCmdGetFormat(_handle, out format);
167 if (error != ErrorCode.None)
169 Log.Error(LogTag, "GetFormat Failed with error " + error);
170 return CommandFormat.Undefined;
177 ErrorCode error = VcCmdSetFormat(_handle, value);
178 if (error != ErrorCode.None)
180 Log.Error(LogTag, "SetFormat Failed with error " + error);
186 /// Gets or sets the command.
187 /// A get empty string will be returned in case of some internal error.
189 /// <since_tizen> 3 </since_tizen>
190 /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
191 /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
192 public string Command
197 ErrorCode error = VcCmdGetCommand(_handle, out command);
198 if (error != ErrorCode.None)
200 Log.Error(LogTag, "GetCommand Failed with error " + error);
208 ErrorCode error = VcCmdSetCommand(_handle, value);
209 if (error != ErrorCode.None)
211 Log.Error(LogTag, "SetCommand Failed with error " + error);