Fix errata
[platform/core/csapi/uix-stt.git] / Tizen.Uix.Stt / Tizen.Uix.Stt / ErrorOccurredEventArgs.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
18 using System;
19 using static Interop.Stt;
20
21 namespace Tizen.Uix.Stt
22 {
23     /// <summary>
24     /// This class holds information related to the STT ErrorOccurred Event
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class ErrorOccurredEventArgs
28     {
29         private IntPtr _handle;
30
31         internal ErrorOccurredEventArgs(IntPtr handle, Interop.Stt.SttError error)
32         {
33             this._handle = handle;
34             switch (error)
35             {
36                 case Interop.Stt.SttError.None:
37                     {
38                         ErrorValue = Error.None;
39                         break;
40                     }
41
42                 case Interop.Stt.SttError.OutOfMemory:
43                     {
44                         ErrorValue = Error.OutOfMemory;
45                         break;
46                     }
47
48                 case Interop.Stt.SttError.IoError:
49                     {
50                         ErrorValue = Error.IoError;
51                         break;
52                     }
53
54                 case Interop.Stt.SttError.InvalidParameter:
55                     {
56                         ErrorValue = Error.InvalidParameter;
57                         break;
58                     }
59
60                 case Interop.Stt.SttError.TimedOut:
61                     {
62                         ErrorValue = Error.TimedOut;
63                         break;
64                     }
65
66                 case Interop.Stt.SttError.RecorderBusy:
67                     {
68                         ErrorValue = Error.RecorderBusy;
69                         break;
70                     }
71
72                 case Interop.Stt.SttError.OutOfNetwork:
73                     {
74                         ErrorValue = Error.OutOfNetwork;
75                         break;
76                     }
77
78                 case Interop.Stt.SttError.PermissionDenied:
79                     {
80                         ErrorValue = Error.PermissionDenied;
81                         break;
82                     }
83
84                 case Interop.Stt.SttError.NotSupported:
85                     {
86                         ErrorValue = Error.NotSupported;
87                         break;
88                     }
89
90                 case Interop.Stt.SttError.InvalidState:
91                     {
92                         ErrorValue = Error.InvalidState;
93                         break;
94                     }
95
96                 case Interop.Stt.SttError.InvalidLanguage:
97                     {
98                         ErrorValue = Error.InvalidLanguage;
99                         break;
100                     }
101
102                 case Interop.Stt.SttError.EngineNotFound:
103                     {
104                         ErrorValue = Error.EngineNotFound;
105                         break;
106                     }
107
108                 case Interop.Stt.SttError.OperationFailed:
109                     {
110                         ErrorValue = Error.OperationFailed;
111                         break;
112                     }
113
114                 case Interop.Stt.SttError.NotSupportedFeature:
115                     {
116                         ErrorValue = Error.NotSupportedFeature;
117                         break;
118                     }
119
120                 case Interop.Stt.SttError.RecordingTimedOut:
121                     {
122                         ErrorValue = Error.RecordingTimedOut;
123                         break;
124                     }
125
126                 case Interop.Stt.SttError.NoSpeech:
127                     {
128                         ErrorValue = Error.NoSpeech;
129                         break;
130                     }
131
132                 case Interop.Stt.SttError.InProgressToReady:
133                     {
134                         ErrorValue = Error.InProgressToReady;
135                         break;
136                     }
137
138                 case Interop.Stt.SttError.InProgressToRecording:
139                     {
140                         ErrorValue = Error.InProgressToRecording;
141                         break;
142                     }
143
144                 case Interop.Stt.SttError.InProgressToProcessing:
145                     {
146                         ErrorValue = Error.InProgressToProcessing;
147                         break;
148                     }
149
150                 case Interop.Stt.SttError.ServiceReset:
151                     {
152                         ErrorValue = Error.ServiceReset;
153                         break;
154                     }
155
156             }
157         }
158
159         /// <summary>
160         /// The Error Value
161         /// </summary>
162         /// <since_tizen> 3 </since_tizen>
163         public Error ErrorValue
164         {
165             get;
166             internal set;
167         }
168
169         /// <summary>
170         /// Gets the current error message.
171         /// </summary>
172         /// <since_tizen> 3 </since_tizen>
173         /// <returns>
174         /// string error message
175         /// </returns>
176         public string ErrorMessage
177         {
178             get
179             {
180                 string errorMesage = "";
181                 SttError error = SttGetErrorMessage(_handle, out errorMesage);
182                 if (error != SttError.None)
183                 {
184                     Log.Error(LogTag, "GetErrorMessage Failed with error " + error);
185                     return "";
186                 }
187
188                 return errorMesage;
189             }
190
191         }
192     }
193 }