f4b25d0348342dbaef2f899c54d7c355031b4c66
[platform/framework/native/telephony.git] / inc / FTelSimInfo.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        FTelSimInfo.h
19  * @brief       This is the header file for the %SimInfo class.
20  *
21  * This header file contains the declarations of the %SimInfo class.
22  */
23 #ifndef _FTEL_SIM_INFO_H_
24 #define _FTEL_SIM_INFO_H_
25
26
27 #include <FBase.h>
28 #include <FTelTypes.h>
29
30
31 namespace Tizen { namespace Telephony
32 {
33 class _SimInfoImpl;
34
35
36 /**
37  * @class       SimInfo
38  * @brief       This class provides information of the currently inserted SIM card.
39  * @since       2.0
40  *
41  * The %SimInfo class provides methods to get information from the SIM card such as MCC, MNC, SPN, ICC ID, the name of operator,
42  * and whether the SIM card is available or not.
43  *
44  * The following example demonstrates how to use the %SimInfo class to get the SIM information.
45  *
46  * @code
47  *
48  *  #include <FBase.h>
49  *  #include <FTelephony.h>
50  *
51  *   using namespace Tizen::Base;
52  *   using namespace Tizen::Telephony;
53  *
54  *   class MyClass
55  *       : public Object
56  *   {
57  *   public:
58  *       void GetSimInfo(void);
59  *   };
60  *
61  *   void
62  *   MyClass::GetSimInfo(void)
63  *   {
64  *       int mnc;
65  *       int mcc;
66  *       bool isAvailable;
67  *       String spn;
68  *       String iccId;
69  *       String operatorName;
70  *       SimType simType;
71  *
72  *       SimStateManager* pSimStateManager = new (std::nothrow) SimStateManager();
73  *       SimInfo simInfo;
74  *
75  *       result r = pSimStateManager->Construct();
76  *       if (IsFailed(r))
77  *       {
78  *               delete pSimStateManager;
79  *               return;
80  *       }
81  *
82  *       r = pSimStateManager->GetSimInfo(simInfo);
83  *       if (IsFailed(r))
84  *       {
85  *               delete pSimStateManager;
86  *               return;
87  *       }
88  *
89  *       mnc = simInfo.GetMnc();
90  *       mcc = simInfo.GetMcc();
91  *       spn = simInfo.GetSpn();
92  *       iccId = simInfo.GetIccId();
93  *       operatorName = simInfo.GetOperatorName();
94  *       isAvailable = simInfo.IsAvailable();
95  *       simType = simInfo.GetSimType();
96  *
97  *       delete pSimStateManager;
98  *   }
99  *
100  *
101  * @endcode
102  */
103 class _OSP_EXPORT_ SimInfo
104         : public Tizen::Base::Object
105 {
106 public:
107         /**
108          * This is the default constructor for this class.
109          *
110          * @since               2.0
111          */
112         SimInfo(void);
113
114         /**
115          * Copying of objects using this copy constructor is allowed.
116          *
117          * @since       2.1
118          *
119          * @param[in]   rhs   An instance of %SimInfo
120          */
121         SimInfo(const SimInfo& rhs);
122
123         /**
124          * This destructor overrides Tizen::Base::Object::~Object().
125          *
126          * @since       2.0
127          */
128         virtual ~SimInfo(void);
129
130         /**
131          * Initializes this instance of %SimInfo.
132          *
133          * @brief   <i> [Deprecated] </i>
134          * @deprecated  This method is deprecated. Instead of using this method, it is recommended to use the SimStateManager::GetSimInfo() method to get the initialized %SimInfo instance.
135          *
136          * @since               2.0
137          * @feature %http://tizen.org/feature/network.telephony
138          * @return              An error code
139          * @exception   E_SUCCESS       The method is successful.
140          * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
141          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
142          * @exception   E_UNSUPPORTED_OPERATION  The Emulator or target device does not support the required feature. @b Since: @b 2.1
143          *                                                                               For more information, see <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
144          * @remarks     Before calling this method, check whether the feature is supported by %Tizen::System::SystemInfo::GetValue() methods.
145          */
146         result Construct(void);
147
148         /**
149          * Gets the Mobile Network Code (MNC) of the SIM International Mobile Subscriber Identity (IMSI) information.
150          *
151          * @since       2.0
152          *
153          * @privlevel   public
154      * @privilege   %http://tizen.org/privilege/telephony @n
155      *                          (%http://tizen.org/privilege/systeminfo is deprecated.)
156          *
157          * @return      The MNC of the SIM card, @n
158          *              else @c -1 if the method fails
159          * @exception   E_SUCCESS       The method is successful.
160          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
161          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
162          * @remarks             The specific error code can be accessed using the GetLastResult() method.
163          */
164         int GetMnc(void) const;
165
166         /**
167          * Gets the Mobile Country Code (MCC) of the SIM IMSI information.
168          *
169          * @since       2.0
170          *
171          * @privlevel   public
172      * @privilege   %http://tizen.org/privilege/telephony @n
173      *                          (%http://tizen.org/privilege/systeminfo is deprecated.)
174          *
175          * @return      The MCC of the SIM card, @n
176          *              else @c -1 if the method fails
177          * @exception   E_SUCCESS       The method is successful.
178          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
179          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
180          * @remarks             The specific error code can be accessed using the GetLastResult() method.
181          */
182         int GetMcc(void) const;
183
184         /**
185          * Gets the Service Provider Name (SPN) string of the SIM card.
186          *
187          * @since       2.0
188          *
189          * @privlevel   public
190      * @privilege   %http://tizen.org/privilege/telephony @n
191      *                          (%http://tizen.org/privilege/systeminfo is deprecated.)
192          *
193          * @return      The SPN of the SIM card, @n
194          *              else an empty string if there is no SIM card in the device, or if an SPN is not assigned to the SIM card
195          * @exception   E_SUCCESS       The method is successful.
196          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
197          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
198          * @remarks             The specific error code can be accessed using the GetLastResult() method.
199          */
200         Tizen::Base::String GetSpn(void) const;
201
202         /**
203          * Gets the Integrated Circuit Card Identifier (ICCID) of the SIM card. @n
204          * One useful case to detect the change of SIM cards is to store this value and compare it with the most recent value.
205          * The %GetIccId() method provides a unique identification number for the SIM card.
206          *
207          * @since       2.0
208          *
209          * @privlevel   public
210      * @privilege   %http://tizen.org/privilege/telephony @n
211      *                          (%http://tizen.org/privilege/systeminfo is deprecated.)
212          *
213          * @return  The ICCID of the SIM card, @n
214          *          else an empty string if the method fails
215          * @exception   E_SUCCESS       The method is successful.
216          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
217          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
218          * @remarks             The specific error code can be accessed using the GetLastResult() method.
219          */
220         Tizen::Base::String GetIccId(void) const;
221
222     /**
223          * Gets the operator name of Common PCN Handset Specification (CPHS) of the SIM card.
224          *
225          * @since       2.0
226          *
227          * @privlevel   public
228      * @privilege   %http://tizen.org/privilege/telephony @n
229      *                          (%http://tizen.org/privilege/systeminfo is deprecated.)
230          *
231          * @return      The operator name of the SIM card, @n
232          *              else an empty string if there is no SIM card in the device, or if an operator name is not assigned to the SIM card
233          * @exception   E_SUCCESS       The method is successful.
234          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
235          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
236          * @remarks If this method has failed, then this method returns an empty string.
237          * @remarks             The specific error code can be accessed using the GetLastResult() method.
238          */
239         Tizen::Base::String GetOperatorName(void) const;
240
241         /**
242          * Gets the phone number of the SIM card.
243          *
244          * @since       2.0
245          *
246          * @privlevel   public
247      * @privilege   %http://tizen.org/privilege/telephony @n
248      *                          (%http://tizen.org/privilege/systeminfo is deprecated.)
249          *
250          * @return      The phone number of the SIM card, @n
251          *              else an empty string if there is no SIM card in the device, or if a Mobile Station International Subscriber Directory Number
252          *              (MSISDN) is not assigned to the SIM card
253          * @exception   E_SUCCESS    The method is successful.
254          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
255          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
256          * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
257          * @remarks             The specific error code can be accessed using the GetLastResult() method.
258          */
259         Tizen::Base::String GetPhoneNumber(void) const;
260
261         /**
262          * Gets the International Mobile Subscriber Identity (IMSI) of the SIM card.
263          *
264          * @since       2.0
265          *
266          * @privlevel  partner
267          * @privilege   %http://tizen.org/privilege/useridentity
268          *
269          * @return      The IMSI of the SIM card, @n
270          *              else an empty string if the method fails
271          * @exception   E_SUCCESS       The method is successful.
272          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
273          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
274          * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
275          * @remarks             The specific error code can be accessed using the GetLastResult() method.
276          */
277         Tizen::Base::String GetImsi(void) const;
278
279         /**
280          * Gets the type of SIM card.
281          *
282          * @since       2.1
283          *
284          * @privlevel   public
285          * @privilege   %http://tizen.org/privilege/telephony
286          *
287          * @return              The type of SIM card
288          *
289          * @exception   E_SUCCESS       The method is successful.
290          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
291          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
292          * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
293          * @remarks             The specified error code can be accessed using the GetLastResult() method.
294          */
295         SimType GetSimType(void) const;
296
297         /**
298          * Checks whether a SIM card is present in the device or not.
299          *
300          * @since       2.0
301          *
302          * @privlevel   public
303      * @privilege   %http://tizen.org/privilege/telephony @n
304      *                          (%http://tizen.org/privilege/systeminfo is deprecated.)
305          *
306          * @return  @c true if the SIM card is present in the device, @n
307          *          else @c false
308          * @exception   E_SUCCESS       The method is successful.
309          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
310          * @remarks             The specific error code can be accessed using the GetLastResult() method.
311          */
312         bool IsAvailable(void) const;
313
314         /**
315          * Copying of objects using this copy assignment operator is allowed.
316          *
317          * @since               2.1
318          *
319          * @param[in]   rhs An instance of %SimInfo
320          */
321         SimInfo& operator =(const SimInfo& rhs);
322
323         /**
324          * Compares the specified instance of %SimInfo with the calling instance.
325          *
326          * @since               2.0
327          *
328          * @return              @c true if the values match, @n
329          *                              else @c false
330          * @param[in]   rhs     The other Tizen::Base::Object to compare
331          * @see                 Tizen::Base::Object::Equals()
332          */
333         virtual bool Equals(const Tizen::Base::Object& rhs) const;
334
335         /**
336          * Gets the hash value of the current instance.
337          *
338          * @since               2.0
339          *
340          * @return      The hash value of the current instance
341          */
342         virtual int GetHashCode(void) const;
343
344 private:
345         _SimInfoImpl* __pSimInfoImpl;
346
347         friend class _SimInfoImpl;
348 }; // SimInfo
349
350 }} // Tizen::Telephony
351
352 #endif // _FTEL_SIM_INFO_H_