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 FTelSimStateManager.cpp
19 * @brief This is the implementation file for SimStateManager class.
22 #include <FBaseSysLog.h>
23 #include <FSec_AccessController.h>
24 #include <FTelSimStateManager.h>
25 #include "FTel_SimStateManagerImpl.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Security;
32 namespace Tizen { namespace Telephony
34 SimStateManager::SimStateManager(void)
35 : __pSimStateManagerImpl(null)
39 SimStateManager::~SimStateManager(void)
41 delete __pSimStateManagerImpl;
45 SimStateManager::Construct(void)
47 SysAssertf(__pSimStateManagerImpl == null,
48 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52 __pSimStateManagerImpl = new (std::nothrow)_SimStateManagerImpl();
53 SysTryReturnResult(NID_TEL, __pSimStateManagerImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
55 r = __pSimStateManagerImpl->Construct();
59 SysLogException(NID_TEL, r, "[%s] Propagating.", GetErrorMessage(r));
60 delete __pSimStateManagerImpl;
61 __pSimStateManagerImpl = null;
68 SimStateManager::SetSimEventListener(ITelephonySimEventListener* pListener)
70 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
74 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
75 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
77 r = __pSimStateManagerImpl->SetSimEventListener(pListener);
78 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
84 SimStateManager::GetPinLockSetting(ISimStateManagerGetPinLockSettingResultListener* pListener)
86 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
90 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
91 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
93 r = __pSimStateManagerImpl->GetPinLockSetting(pListener);
94 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
100 SimStateManager::GetSimState(void) const
102 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
104 result r = E_SUCCESS;
106 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
107 SysTryReturn(NID_NET, r == E_SUCCESS, SIM_STATE_UNKNOWN, r,
108 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
110 return __pSimStateManagerImpl->GetSimState();
114 SimStateManager::GetSimInfo(SimInfo& simInfo) const
116 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
118 result r = E_SUCCESS;
120 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
121 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
123 r = __pSimStateManagerImpl->GetSimInfo(simInfo);
124 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
129 } } // Tizen::Telephony