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 <FSys_SystemInfoImpl.h>
26 #include "FTel_SimStateManagerImpl.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Security;
31 using namespace Tizen::System;
34 namespace Tizen { namespace Telephony
36 SimStateManager::SimStateManager(void)
37 : __pSimStateManagerImpl(null)
41 SimStateManager::~SimStateManager(void)
43 delete __pSimStateManagerImpl;
47 SimStateManager::Construct(void)
49 static const wchar_t _TELEPHONY[] = L"http://tizen.org/feature/network.telephony";
51 SysAssertf(__pSimStateManagerImpl == null,
52 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
55 bool isTelephonySupported = false;
57 r = _SystemInfoImpl::GetSysInfo(_TELEPHONY, isTelephonySupported);
58 SysTryReturnResult(NID_TEL, r == E_SUCCESS && isTelephonySupported, E_UNSUPPORTED_OPERATION, "Telephony is not supported.");
60 __pSimStateManagerImpl = new (std::nothrow)_SimStateManagerImpl();
61 SysTryReturnResult(NID_TEL, __pSimStateManagerImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed");
63 r = __pSimStateManagerImpl->Construct();
67 SysLogException(NID_TEL, r, "[%s] Propagating.", GetErrorMessage(r));
68 delete __pSimStateManagerImpl;
69 __pSimStateManagerImpl = null;
76 SimStateManager::SetSimEventListener(ITelephonySimEventListener* pListener)
78 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
82 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
83 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
85 r = __pSimStateManagerImpl->SetSimEventListener(pListener);
86 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
92 SimStateManager::GetPinLockSetting(ISimStateManagerGetPinLockSettingResultListener* pListener)
94 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
98 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
99 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
101 r = __pSimStateManagerImpl->GetPinLockSetting(pListener);
102 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
108 SimStateManager::GetSimState(void) const
110 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
112 result r = E_SUCCESS;
114 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
115 SysTryReturn(NID_NET, r == E_SUCCESS, SIM_STATE_UNKNOWN, r,
116 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(r));
118 return __pSimStateManagerImpl->GetSimState();
122 SimStateManager::GetSimInfo(SimInfo& simInfo) const
124 SysAssertf(__pSimStateManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
126 result r = E_SUCCESS;
128 r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
129 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "The application does not have the privilege to call this method.");
131 r = __pSimStateManagerImpl->GetSimInfo(simInfo);
132 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
137 } } // Tizen::Telephony