Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Telephony / Tizen.Telephony / Modem.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.Telephony;
19 namespace Tizen.Telephony
20 {
21     /// <summary>
22     /// This Class provides API's to obtain information from the modem.
23     /// </summary>
24     public class Modem
25     {
26         internal IntPtr _handle;
27
28         /// <summary>
29         /// Modem Class Constructor
30         /// </summary>
31         /// <since_tizen> 3 </since_tizen>
32         /// <param name="handle">
33         /// SlotHandle received in the Manager.Init API
34         /// </param>
35         /// <feature>http://tizen.org/feature/network.telephony</feature>
36         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
37         /// <exception cref="ArgumentNullException">
38         /// This exception occurs if handle provided is null
39         /// </exception>
40         public Modem(SlotHandle handle)
41         {
42             if (handle == null)
43             {
44                 throw new ArgumentNullException();
45             }
46
47             _handle = handle._handle;
48         }
49
50         /// <summary>
51         /// Enumeration for Modem Power Status.
52         /// </summary>
53         public enum PowerStatus
54         {
55             /// <summary>
56             /// Unknown
57             /// </summary>
58             Unknown = -1,
59             /// <summary>
60             /// Modem power ON
61             /// </summary>
62             On,
63             /// <summary>
64             /// Modem power OFF
65             /// </summary>
66             Off,
67             /// <summary>
68             /// Modem power RESET
69             /// </summary>
70             Reset,
71             /// <summary>
72             /// Modem power LOW
73             /// </summary>
74             Low
75         };
76
77         /// <summary>
78         /// Gets the IMEI (International Mobile Station Equipment Identity) of a mobile phone.
79         /// The IMEI number is used by a GSM network to identify valid devices and therefore can be used for stopping a stolen phone from accessing that network.
80         /// </summary>
81         /// <since_tizen> 3 </since_tizen>
82         /// <privilege>http://tizen.org/privilege/telephony</privilege>
83         /// <value>
84         /// The International Mobile Station Equipment Identity
85         /// empty string if unable to complete the operation
86         /// </value>
87         public string Imei
88         {
89             get
90             {
91                 string imei;
92                 TelephonyError error = Interop.Modem.GetImei(_handle, out imei);
93                 if (error != TelephonyError.None)
94                 {
95                     Tizen.Log.Error(Interop.Telephony.LogTag, "GetImei Failed with error " + error);
96                     return "";
97                 }
98
99                 return imei;
100             }
101         }
102
103         /// <summary>
104         /// Gets the power status of the modem.
105         /// </summary>
106         /// <since_tizen> 3 </since_tizen>
107         /// <privilege>http://tizen.org/privilege/telephony</privilege>
108         /// <value>
109         /// The Modem power status (0=on,1=off,2=reset,3=low)
110         /// </value>
111         public PowerStatus CurrentPowerStatus
112         {
113             get
114             {
115                 PowerStatus status;
116                 TelephonyError error = Interop.Modem.GetPowerStatus(_handle, out status);
117                 if (error != TelephonyError.None)
118                 {
119                     Tizen.Log.Error(Interop.Telephony.LogTag, "GetImei Failed with error " + error);
120                     return PowerStatus.Unknown;
121                 }
122
123                 return status;
124             }
125
126         }
127
128         /// <summary>
129         /// Gets the MEID (Mobile Equipment Identifier) of a mobile phone. (for CDMA)
130         /// </summary>
131         /// <since_tizen> 3 </since_tizen>
132         /// <privilege>http://tizen.org/privilege/telephony</privilege>
133         /// <value>
134         /// The Mobile Equipment Identifier
135         /// empty string if unable to complete the operation
136         /// </value>
137         public string Meid
138         {
139             get
140             {
141                 string meid;
142                 TelephonyError error = Interop.Modem.GetMeid(_handle, out meid);
143                 if (error != TelephonyError.None)
144                 {
145                     Tizen.Log.Error(Interop.Telephony.LogTag, "GetMeid Failed with error " + error);
146                     return "";
147                 }
148
149                 return meid;
150             }
151
152         }
153     }
154 }