Review UIX-TTS API cs files
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.Tts / Tizen.Uix.Tts / 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.Tts;
20
21 namespace Tizen.Uix.Tts
22 {
23     /// <summary>
24     /// This class holds information related to the TTS 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, int utteranceId, Interop.Tts.TtsError error)
32         {
33             this._handle = handle;
34             this.UtteranceId = utteranceId;
35             switch (error)
36             {
37                 case Interop.Tts.TtsError.None:
38                     {
39                         ErrorValue = Error.None;
40                         break;
41                     }
42
43                 case Interop.Tts.TtsError.OutOfMemory:
44                     {
45                         ErrorValue = Error.OutOfMemory;
46                         break;
47                     }
48
49                 case Interop.Tts.TtsError.IoError:
50                     {
51                         ErrorValue = Error.IoError;
52                         break;
53                     }
54
55                 case Interop.Tts.TtsError.InvalidParameter:
56                     {
57                         ErrorValue = Error.InvalidParameter;
58                         break;
59                     }
60
61                 case Interop.Tts.TtsError.TimedOut:
62                     {
63                         ErrorValue = Error.TimedOut;
64                         break;
65                     }
66
67                 case Interop.Tts.TtsError.OutOfNetwork:
68                     {
69                         ErrorValue = Error.OutOfNetwork;
70                         break;
71                     }
72
73                 case Interop.Tts.TtsError.PermissionDenied:
74                     {
75                         ErrorValue = Error.PermissionDenied;
76                         break;
77                     }
78
79                 case Interop.Tts.TtsError.NotSupported:
80                     {
81                         ErrorValue = Error.NotSupported;
82                         break;
83                     }
84
85                 case Interop.Tts.TtsError.InvalidState:
86                     {
87                         ErrorValue = Error.InvalidState;
88                         break;
89                     }
90
91                 case Interop.Tts.TtsError.InvalidVoice:
92                     {
93                         ErrorValue = Error.InvalidVoice;
94                         break;
95                     }
96
97                 case Interop.Tts.TtsError.EngineNotFound:
98                     {
99                         ErrorValue = Error.EngineNotFound;
100                         break;
101                     }
102
103                 case Interop.Tts.TtsError.OperationFailed:
104                     {
105                         ErrorValue = Error.OperationFailed;
106                         break;
107                     }
108
109                 case Interop.Tts.TtsError.AudioPolicyBlocked:
110                     {
111                         ErrorValue = Error.AudioPolicyBlocked;
112                         break;
113                     }
114             }
115         }
116
117         /// <summary>
118         /// The utterance ID.
119         /// </summary>
120         /// <since_tizen> 3 </since_tizen>
121         public int UtteranceId
122         {
123             get;
124             internal set;
125         }
126
127         /// <summary>
128         /// The error value.
129         /// </summary>
130         /// <since_tizen> 3 </since_tizen>
131         public Error ErrorValue
132         {
133             get;
134             internal set;
135         }
136
137         /// <summary>
138         /// Gets the current error message.
139         /// </summary>
140         /// <since_tizen> 3 </since_tizen>
141         /// <returns>
142         /// String error message.
143         /// </returns>
144         public string ErrorMessage
145         {
146             get
147             {
148                 string errorMesage = "";
149                 TtsError error = TtsGetErrorMessage(_handle, out errorMesage);
150                 if (error != TtsError.None)
151                 {
152                     Log.Error(LogTag, "GetErrorMessage Failed with error " + error);
153                     return "";
154                 }
155
156                 return errorMesage;
157             }
158
159         }
160     }
161 }