Updating Doxygen
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.VoiceControl / Tizen.Uix.VoiceControl / VoiceCommand.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 using System;
18 using static Interop.VoiceControl;
19 using static Interop.VoiceControlCommand;
20
21 namespace Tizen.Uix.VoiceControl
22 {
23     /// <summary>
24     /// Enumeration for Command Format
25     /// </summary>
26     public enum CommandFormat
27     {
28         /// <summary>
29         /// fixed command format.
30         /// </summary>
31         Fixed = 0,
32         /// <summary>
33         /// fixed and variable fixed command format.
34         /// </summary>
35         FixedAndVFixed = 1,
36         /// <summary>
37         /// variable fixed and fixed command format.
38         /// </summary>
39         VFixedAndFixed = 2,
40         /// <summary>
41         /// fixed and non-fixed command format.
42         /// </summary>
43         FixedAndNonFixed = 3,
44         /// <summary>
45         /// non-fixed and fixed command format.
46         /// </summary>
47         NonFixedAndFixed = 4,
48         /// <summary>
49         /// Undefined
50         /// </summary>
51         Undefined = 5
52     };
53
54     /// <summary>
55     /// This class represents a Voice Command
56     /// </summary>
57     public class VoiceCommand
58     {
59         internal SafeCommandHandle _handle;
60
61         /// <summary>
62         /// Public Constructor
63         /// </summary>
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>
68         public VoiceCommand()
69         {
70             SafeCommandHandle handle;
71             ErrorCode error = VcCmdCreate(out handle);
72             if (error != ErrorCode.None)
73             {
74                 Log.Error(LogTag, "Create Failed with error " + error);
75                 throw ExceptionFactory.CreateException(error);
76             }
77             _handle = handle;
78         }
79
80         internal VoiceCommand(SafeCommandHandle handle)
81         {
82             _handle = handle;
83         }
84
85         /// <summary>
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
89         /// </summary>
90         public string UnfixedCommand
91         {
92             get
93             {
94                 string unfixedCommand;
95                 ErrorCode error = VcCmdGetUnfixedCommand(_handle, out unfixedCommand);
96                 if (error != ErrorCode.None)
97                 {
98                     Log.Error(LogTag, "UnfixedCommand Failed with error " + error);
99                     return "";
100                 }
101
102                 return unfixedCommand;
103             }
104         }
105
106         /// <summary>
107         /// Gets/Sets command type.
108         /// </summary>
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
113         {
114             get
115             {
116                 CommandType cmdType = CommandType.Undefined;
117                 int type;
118                 ErrorCode error = VcCmdGetType(_handle, out type);
119                 if (error != ErrorCode.None)
120                 {
121                     Log.Error(LogTag, "GetType Failed with error " + error);
122                     return CommandType.Undefined;
123                 }
124
125                 if (type != -1)
126                 {
127                     cmdType = (CommandType)type;
128                 }
129
130                 return cmdType;
131             }
132             set
133             {
134                 ErrorCode error = VcCmdSetType(_handle, value);
135                 if (error != ErrorCode.None)
136                 {
137                     Log.Error(LogTag, "SetType Failed with error " + error);
138                 }
139             }
140         }
141
142         /// <summary>
143         /// Gets/Sets the command format.
144         /// </summary>
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
149         {
150             get
151             {
152                 CommandFormat format;
153                 ErrorCode error = VcCmdGetFormat(_handle, out format);
154                 if (error != ErrorCode.None)
155                 {
156                     Log.Error(LogTag, "GetFormat Failed with error " + error);
157                     return CommandFormat.Undefined;
158                 }
159
160                 return format;
161             }
162             set
163             {
164                 ErrorCode error = VcCmdSetFormat(_handle, value);
165                 if (error != ErrorCode.None)
166                 {
167                     Log.Error(LogTag, "SetFormat Failed with error " + error);
168                 }
169             }
170         }
171
172         /// <summary>
173         /// Gets/Sets command
174         /// in case of get empty string will be returned in case of some internal error
175         /// </summary>
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
179         {
180             get
181             {
182                 string command;
183                 ErrorCode error = VcCmdGetCommand(_handle, out command);
184                 if (error != ErrorCode.None)
185                 {
186                     Log.Error(LogTag, "GetCommand Failed with error " + error);
187                     return "";
188                 }
189
190                 return command;
191             }
192             set
193             {
194                 ErrorCode error = VcCmdSetCommand(_handle, value);
195                 if (error != ErrorCode.None)
196                 {
197                     Log.Error(LogTag, "SetCommand Failed with error " + error);
198                 }
199             }
200         }
201     }
202 }