2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FTelSimInfo.cpp
19 * @brief This is the implementation file for SimInfo class.
22 #include <FTelSimInfo.h>
23 #include <FBaseSysLog.h>
24 #include <FSec_AccessController.h>
25 #include "FTel_SimInfoImpl.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Security;
30 namespace Tizen { namespace Telephony
32 SimInfo::SimInfo(void)
33 : __pSimInfoImpl(null)
37 SimInfo::~SimInfo(void)
39 delete __pSimInfoImpl;
43 SimInfo::Construct(void)
45 SysAssertf(__pSimInfoImpl == null,
46 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50 __pSimInfoImpl = new (std::nothrow)_SimInfoImpl();
51 SysTryReturnResult(NID_TEL, __pSimInfoImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
53 r = __pSimInfoImpl->Construct();
57 SysLogException(NID_TEL, r, "[%s] Propagating.", GetErrorMessage(r));
58 delete __pSimInfoImpl;
59 __pSimInfoImpl = null;
66 SimInfo::GetMnc(void) const
68 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
73 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
75 SysTryReturn(NID_TEL, r == E_SUCCESS, mnc, E_PRIVILEGE_DENIED,
76 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
78 mnc = __pSimInfoImpl->GetMnc();
82 SysTryReturn(NID_TEL, r == E_SUCCESS, mnc, r, "[%s] Propagating.", GetErrorMessage(r));
88 SimInfo::GetMcc(void) const
90 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
95 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
97 SysTryReturn(NID_TEL, r == E_SUCCESS, mcc, E_PRIVILEGE_DENIED,
98 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
100 mcc = __pSimInfoImpl->GetMcc();
104 SysTryReturn(NID_TEL, r == E_SUCCESS, mcc, r, "[%s] Propagating.", GetErrorMessage(r));
110 SimInfo::GetSpn(void) const
112 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
117 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
119 SysTryReturn(NID_TEL, r == E_SUCCESS, spn, E_PRIVILEGE_DENIED,
120 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
122 spn = __pSimInfoImpl->GetSpn();
126 SysTryReturn(NID_TEL, r == E_SUCCESS, spn, r, "[%s] Propagating.", GetErrorMessage(r));
132 SimInfo::GetIccId(void) const
134 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
139 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
141 SysTryReturn(NID_TEL, r == E_SUCCESS, iccId, E_PRIVILEGE_DENIED,
142 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
144 iccId = __pSimInfoImpl->GetIccId();
148 SysTryReturn(NID_TEL, r == E_SUCCESS, iccId, r, "[%s] Propagating.", GetErrorMessage(r));
154 SimInfo::GetOperatorName(void) const
156 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
161 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
163 SysTryReturn(NID_TEL, r == E_SUCCESS, operatorName, E_PRIVILEGE_DENIED,
164 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
166 operatorName = __pSimInfoImpl->GetOperatorName();
170 SysTryReturn(NID_TEL, r == E_SUCCESS, operatorName, r, "[%s] Propagating.", GetErrorMessage(r));
176 SimInfo::GetPhoneNumber(void) const
178 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
183 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
185 SysTryReturn(NID_TEL, r == E_SUCCESS, phoneNumber, E_PRIVILEGE_DENIED,
186 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
188 phoneNumber = __pSimInfoImpl->GetPhoneNumber();
192 SysTryReturn(NID_TEL, r == E_SUCCESS, phoneNumber, r, "[%s] Propagating.", GetErrorMessage(r));
198 SimInfo::GetImsi(void) const
200 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
206 imsi = __pSimInfoImpl->GetImsi();
208 result r = GetLastResult();
210 if (r == E_PRIVILEGE_DENIED)
212 SysLogException(NID_TEL, E_PRIVILEGE_DENIED,"[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
214 else if(r != E_SUCCESS)
216 SysLogException(NID_TEL, r, "[%s] Propagating.", GetErrorMessage(r));
223 SimInfo::IsAvailable(void) const
225 SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
229 bool isAvailable = false;
230 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
232 SysTryReturn(NID_TEL, r == E_SUCCESS, isAvailable, E_PRIVILEGE_DENIED,
233 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
235 isAvailable = __pSimInfoImpl->IsAvailable();
240 } } // Tizen::Telephony