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.
18 using static Interop.VoiceControl;
19 using static Interop.VoiceControlCommand;
21 namespace Tizen.Uix.VoiceControl
24 /// Enumeration for Command Format
26 public enum CommandFormat
29 /// fixed command format.
33 /// fixed and variable fixed command format.
37 /// variable fixed and fixed command format.
41 /// fixed and non-fixed command format.
45 /// non-fixed and fixed command format.
55 /// This class represents a Voice Command
57 public class VoiceCommand
59 internal SafeCommandHandle _handle;
62 /// Public Constructor
64 /// <exception cref="InvalidOperationException"> This Exception can be due to Invalid State. </exception>
65 /// <exception cref="OutOfMemoryException"> This Exception can be due to Out Of Memory. </exception>
66 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
67 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
70 SafeCommandHandle handle;
71 ErrorCode error = VcCmdCreate(out handle);
72 if (error != ErrorCode.None)
74 Log.Error(LogTag, "Create Failed with error " + error);
75 throw ExceptionFactory.CreateException(error);
80 internal VoiceCommand(SafeCommandHandle handle)
86 /// Gets the unfixed command.
87 /// This property should be used for commands which have non-fixed format.
88 /// empty string will be returned in case of some internal error
90 public string UnfixedCommand
94 string unfixedCommand;
95 ErrorCode error = VcCmdGetUnfixedCommand(_handle, out unfixedCommand);
96 if (error != ErrorCode.None)
98 Log.Error(LogTag, "UnfixedCommand Failed with error " + error);
102 return unfixedCommand;
107 /// Gets/Sets command type.
109 /// <remarks>If you do not set the command type, the default value is Undefined. You should set type if command is valid</remarks>
110 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
111 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
112 public CommandType Type
116 CommandType cmdType = CommandType.Undefined;
118 ErrorCode error = VcCmdGetType(_handle, out type);
119 if (error != ErrorCode.None)
121 Log.Error(LogTag, "GetType Failed with error " + error);
122 return CommandType.Undefined;
127 cmdType = (CommandType)type;
134 ErrorCode error = VcCmdSetType(_handle, value);
135 if (error != ErrorCode.None)
137 Log.Error(LogTag, "SetType Failed with error " + error);
143 /// Gets/Sets the command format.
145 /// <remarks>The default format is Fixed</remarks>
146 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
147 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
148 public CommandFormat Format
152 CommandFormat format;
153 ErrorCode error = VcCmdGetFormat(_handle, out format);
154 if (error != ErrorCode.None)
156 Log.Error(LogTag, "GetFormat Failed with error " + error);
157 return CommandFormat.Undefined;
164 ErrorCode error = VcCmdSetFormat(_handle, value);
165 if (error != ErrorCode.None)
167 Log.Error(LogTag, "SetFormat Failed with error " + error);
173 /// Gets/Sets command
174 /// in case of get empty string will be returned in case of some internal error
176 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
177 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
178 public string Command
183 ErrorCode error = VcCmdGetCommand(_handle, out command);
184 if (error != ErrorCode.None)
186 Log.Error(LogTag, "GetCommand Failed with error " + error);
194 ErrorCode error = VcCmdSetCommand(_handle, value);
195 if (error != ErrorCode.None)
197 Log.Error(LogTag, "SetCommand Failed with error " + error);