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">
65 /// This Exception can be due to the following reaons
67 /// 2. Permission Denied
72 SafeCommandHandle handle;
73 ErrorCode error = VcCmdCreate(out handle);
74 if (error != ErrorCode.None)
76 Log.Error(LogTag, "Create Failed with error " + error);
77 throw ExceptionFactory.CreateException(error);
82 internal VoiceCommand(SafeCommandHandle handle)
88 /// Gets the unfixed command.
89 /// This property should be used for commands which have non-fixed format.
90 /// empty string will be returned in case of some internal error
92 public string GetUnfixedCommand
96 string unfixedCommand;
97 ErrorCode error = VcCmdGetUnfixedCommand(_handle, out unfixedCommand);
98 if (error != ErrorCode.None)
100 Log.Error(LogTag, "GetUnfixedCommand Failed with error " + error);
104 return unfixedCommand;
109 /// Gets/Sets command type.
111 /// <remarks>If you do not set the command type, the default value is Undefined. You should set type if command is valid</remarks>
112 /// <exception cref="InvalidOperationException">
113 /// This Exception can be due to the following reaons for set operation
114 /// 1. Invalid parameter
115 /// 2. Permission Denied
118 public CommandType Type
122 CommandType cmdType = CommandType.Undefined;
124 ErrorCode error = VcCmdGetType(_handle, out type);
125 if (error != ErrorCode.None)
127 Log.Error(LogTag, "GetType Failed with error " + error);
128 return CommandType.Undefined;
133 cmdType = (CommandType)type;
140 ErrorCode error = VcCmdSetType(_handle, value);
141 if (error != ErrorCode.None)
143 Log.Error(LogTag, "SetType Failed with error " + error);
149 /// Gets/Sets the command format.
151 /// <remarks>The default format is Fixed</remarks>
152 /// <exception cref="InvalidOperationException">
153 /// This Exception can be due to the following reaons for set operation
154 /// 1. Invalid parameter
155 /// 2. Permission Denied
158 public CommandFormat Format
162 CommandFormat format;
163 ErrorCode error = VcCmdGetFormat(_handle, out format);
164 if (error != ErrorCode.None)
166 Log.Error(LogTag, "GetFormat Failed with error " + error);
167 return CommandFormat.Undefined;
174 ErrorCode error = VcCmdSetFormat(_handle, value);
175 if (error != ErrorCode.None)
177 Log.Error(LogTag, "SetFormat Failed with error " + error);
183 /// Gets/Sets command
184 /// in case of get empty string will be returned in case of some internal error
186 /// <exception cref="InvalidOperationException">
187 /// This Exception can be due to the following reaons for set operation
188 /// 1. Invalid parameter
189 /// 2. Permission Denied
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);