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 /// <since_tizen> 3 </since_tizen>
27 public enum CommandFormat
30 /// fixed command format.
34 /// fixed and variable fixed command format.
38 /// variable fixed and fixed command format.
42 /// fixed and non-fixed command format.
46 /// non-fixed and fixed command format.
56 /// This class represents a Voice Command
58 /// <since_tizen> 3 </since_tizen>
59 public class VoiceCommand
61 internal SafeCommandHandle _handle;
64 /// Public Constructor
66 /// <since_tizen> 3 </since_tizen>
67 /// <exception cref="InvalidOperationException"> This Exception can be due to Invalid State. </exception>
68 /// <exception cref="OutOfMemoryException"> This Exception can be due to Out Of Memory. </exception>
69 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
70 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
73 SafeCommandHandle handle;
74 ErrorCode error = VcCmdCreate(out handle);
75 if (error != ErrorCode.None)
77 Log.Error(LogTag, "Create Failed with error " + error);
78 throw ExceptionFactory.CreateException(error);
83 internal VoiceCommand(SafeCommandHandle handle)
89 /// Gets the unfixed command.
90 /// This property should be used for commands which have non-fixed format.
91 /// empty string will be returned in case of some internal error
93 /// <since_tizen> 3 </since_tizen>
94 public string UnfixedCommand
98 string unfixedCommand;
99 ErrorCode error = VcCmdGetUnfixedCommand(_handle, out unfixedCommand);
100 if (error != ErrorCode.None)
102 Log.Error(LogTag, "UnfixedCommand Failed with error " + error);
106 return unfixedCommand;
111 /// Gets/Sets command type.
113 /// <since_tizen> 3 </since_tizen>
114 /// <remarks>If you do not set the command type, the default value is Undefined. You should set type if command is valid</remarks>
115 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
116 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
117 public CommandType Type
121 CommandType cmdType = CommandType.Undefined;
123 ErrorCode error = VcCmdGetType(_handle, out type);
124 if (error != ErrorCode.None)
126 Log.Error(LogTag, "GetType Failed with error " + error);
127 return CommandType.Undefined;
132 cmdType = (CommandType)type;
139 ErrorCode error = VcCmdSetType(_handle, value);
140 if (error != ErrorCode.None)
142 Log.Error(LogTag, "SetType Failed with error " + error);
148 /// Gets/Sets the command format.
150 /// <since_tizen> 3 </since_tizen>
151 /// <remarks>The default format is Fixed</remarks>
152 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
153 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
154 public CommandFormat Format
158 CommandFormat format;
159 ErrorCode error = VcCmdGetFormat(_handle, out format);
160 if (error != ErrorCode.None)
162 Log.Error(LogTag, "GetFormat Failed with error " + error);
163 return CommandFormat.Undefined;
170 ErrorCode error = VcCmdSetFormat(_handle, value);
171 if (error != ErrorCode.None)
173 Log.Error(LogTag, "SetFormat Failed with error " + error);
179 /// Gets/Sets command
180 /// in case of get empty string will be returned in case of some internal error
182 /// <since_tizen> 3 </since_tizen>
183 /// <exception cref="UnauthorizedAccessException"> This Exception can be due to Permission Denied. </exception>
184 /// <exception cref="NotSupportedException"> This Exception can be due to Not Supported. </exception>
185 public string Command
190 ErrorCode error = VcCmdGetCommand(_handle, out command);
191 if (error != ErrorCode.None)
193 Log.Error(LogTag, "GetCommand Failed with error " + error);
201 ErrorCode error = VcCmdSetCommand(_handle, value);
202 if (error != ErrorCode.None)
204 Log.Error(LogTag, "SetCommand Failed with error " + error);