b85670c458b94f3b44533b7f189d37b2fe86da9a
[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
155          *
156          * @return      The MNC of the SIM card, @n
157          *              else @c -1 if the method fails
158          * @exception   E_SUCCESS       The method is successful.
159          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
160          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
161          * @remarks             The specific error code can be accessed using the GetLastResult() method.
162          */
163         int GetMnc(void) const;
164
165         /**
166          * Gets the Mobile Country Code (MCC) of the SIM IMSI information.
167          *
168          * @since       2.0
169          *
170          * @privlevel   public
171          * @privilege   %http://tizen.org/privilege/telephony
172          *
173          * @return      The MCC of the SIM card, @n
174          *              else @c -1 if the method fails
175          * @exception   E_SUCCESS       The method is successful.
176          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
177          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
178          * @remarks             The specific error code can be accessed using the GetLastResult() method.
179          */
180         int GetMcc(void) const;
181
182         /**
183          * Gets the Service Provider Name (SPN) string of the SIM card.
184          *
185          * @since       2.0
186          *
187          * @privlevel   public
188          * @privilege   %http://tizen.org/privilege/telephony
189          *
190          * @return      The SPN of the SIM card, @n
191          *              else an empty string if there is no SIM card in the device, or if an SPN is not assigned to the SIM card
192          * @exception   E_SUCCESS       The method is successful.
193          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
194          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
195          * @remarks             The specific error code can be accessed using the GetLastResult() method.
196          */
197         Tizen::Base::String GetSpn(void) const;
198
199         /**
200          * Gets the Integrated Circuit Card Identifier (ICCID) of the SIM card. @n
201          * One useful case to detect the change of SIM cards is to store this value and compare it with the most recent value.
202          * The %GetIccId() method provides a unique identification number for the SIM card.
203          *
204          * @since       2.0
205          *
206          * @privlevel   public
207          * @privilege   %http://tizen.org/privilege/telephony
208          *
209          * @return  The ICCID of the SIM card, @n
210          *          else an empty string if the method fails
211          * @exception   E_SUCCESS       The method is successful.
212          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
213          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
214          * @remarks             The specific error code can be accessed using the GetLastResult() method.
215          */
216         Tizen::Base::String GetIccId(void) const;
217
218     /**
219          * Gets the operator name of Common PCN Handset Specification (CPHS) of the SIM card.
220          *
221          * @since       2.0
222          *
223          * @privlevel   public
224          * @privilege   %http://tizen.org/privilege/telephony
225          *
226          * @return      The operator name of the SIM card, @n
227          *              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
228          * @exception   E_SUCCESS       The method is successful.
229          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
230          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
231          * @remarks If this method has failed, then this method returns an empty string.
232          * @remarks             The specific error code can be accessed using the GetLastResult() method.
233          */
234         Tizen::Base::String GetOperatorName(void) const;
235
236         /**
237          * Gets the phone number of the SIM card.
238          *
239          * @since       2.0
240          *
241          * @privlevel   public
242          * @privilege   %http://tizen.org/privilege/telephony
243          *
244          * @return      The phone number of the SIM card, @n
245          *              else an empty string if there is no SIM card in the device, or if a Mobile Station International Subscriber Directory Number
246          *              (MSISDN) is not assigned to the SIM card
247          * @exception   E_SUCCESS    The method is successful.
248          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
249          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
250          * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
251          * @remarks             The specific error code can be accessed using the GetLastResult() method.
252          */
253         Tizen::Base::String GetPhoneNumber(void) const;
254
255         /**
256          * Gets the International Mobile Subscriber Identity (IMSI) of the SIM card.
257          *
258          * @since       2.0
259          *
260          * @privlevel  partner
261          * @privilege   %http://tizen.org/privilege/useridentity
262          *
263          * @return      The IMSI of the SIM card, @n
264          *              else an empty string if the method fails
265          * @exception   E_SUCCESS       The method is successful.
266          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
267          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
268          * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
269          * @remarks             The specific error code can be accessed using the GetLastResult() method.
270          */
271         Tizen::Base::String GetImsi(void) const;
272
273         /**
274          * Gets the type of SIM card.
275          *
276          * @since       2.1
277          *
278          * @privlevel   public
279          * @privilege   %http://tizen.org/privilege/telephony
280          *
281          * @return              The type of SIM card
282          *
283          * @exception   E_SUCCESS       The method is successful.
284          * @exception   E_DEVICE_UNAVAILABLE    The operation has failed due to a missing SIM card.
285          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
286          * @exception   E_SYSTEM        The method cannot proceed due to a severe system error.
287          * @remarks             The specified error code can be accessed using the GetLastResult() method.
288          */
289         SimType GetSimType(void) const;
290
291         /**
292          * Checks whether a SIM card is present in the device or not.
293          *
294          * @since       2.0
295          *
296          * @privlevel   public
297          * @privilege   %http://tizen.org/privilege/telephony
298          *
299          * @return  @c true if the SIM card is present in the device, @n
300          *          else @c false
301          * @exception   E_SUCCESS       The method is successful.
302          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
303          * @remarks             The specific error code can be accessed using the GetLastResult() method.
304          */
305         bool IsAvailable(void) const;
306
307         /**
308          * Copying of objects using this copy assignment operator is allowed.
309          *
310          * @since               2.1
311          *
312          * @param[in]   rhs An instance of %SimInfo
313          */
314         SimInfo& operator =(const SimInfo& rhs);
315
316         /**
317          * Compares the specified instance of %SimInfo with the calling instance.
318          *
319          * @since               2.0
320          *
321          * @return              @c true if the values match, @n
322          *                              else @c false
323          * @param[in]   rhs     The other Tizen::Base::Object to compare
324          * @see                 Tizen::Base::Object::Equals()
325          */
326         virtual bool Equals(const Tizen::Base::Object& rhs) const;
327
328         /**
329          * Gets the hash value of the current instance.
330          *
331          * @since               2.0
332          *
333          * @return      The hash value of the current instance
334          */
335         virtual int GetHashCode(void) const;
336
337 private:
338         _SimInfoImpl* __pSimInfoImpl;
339
340         friend class _SimInfoImpl;
341 }; // SimInfo
342
343 }} // Tizen::Telephony
344
345 #endif // _FTEL_SIM_INFO_H_