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 FTelNetworkManager.cpp
19 * @brief This is the implementation file for NetworkManager class.
22 #include <FTelNetworkManager.h>
23 #include <FBaseSysLog.h>
24 #include <FTelITelephonyNetworkEventListener.h>
25 #include <FTelITelephonyNetworkSettingListener.h>
26 #include <FSec_AccessController.h>
27 #include "FTel_NetworkManagerImpl.h"
29 using namespace Tizen::Security;
31 namespace Tizen { namespace Telephony
33 NetworkManager::NetworkManager(void)
34 : __pNetworkManagerImpl(null)
39 NetworkManager::~NetworkManager(void)
41 delete __pNetworkManagerImpl;
45 NetworkManager::Construct(ITelephonyNetworkEventListener* pListener)
47 SysAssertf(__pNetworkManagerImpl == null,
48 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52 __pNetworkManagerImpl = new (std::nothrow) _NetworkManagerImpl();
53 SysTryReturnResult(NID_TEL, __pNetworkManagerImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
55 r = __pNetworkManagerImpl->Construct(pListener);
59 SysLogException(NID_TEL, r, "[%s] Propagating.", GetErrorMessage(r));
60 delete __pNetworkManagerImpl;
61 __pNetworkManagerImpl = null;
68 NetworkManager::GetNetworkStatus(NetworkStatus& networkStatus) const
70 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
74 r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
75 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
77 r = __pNetworkManagerImpl->GetNetworkStatus(networkStatus);
78 SysTryReturnResult(NID_TEL, r == E_SUCCESS, r, "Propagating.");
84 NetworkManager::GetNetworkInfo(NetworkInfo& networkInfo) const
86 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
90 r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
91 SysTryReturnResult(NID_TEL, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
94 r = __pNetworkManagerImpl->GetNetworkInfo(networkInfo);
95 SysTryReturnResult(NID_TEL, r == E_SUCCESS, r, "Propagating.");
103 NetworkManager::SetNetworkSettingListener(ITelephonyNetworkSettingListener* pListener)
105 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
107 result r = __pNetworkManagerImpl->SetNetworkSettingListener(pListener);
109 if (r == E_PRIVILEGE_DENIED)
111 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
113 else if( r != E_SUCCESS)
115 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
123 NetworkManager::GetNetworkSelectionMode(void)
125 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
127 result r = __pNetworkManagerImpl->GetNetworkSelectionMode();
129 if (r == E_PRIVILEGE_DENIED)
131 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
133 else if( r != E_SUCCESS)
135 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
143 NetworkManager::SelectNetwork(const NetworkInfo& networkInfo)
145 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
147 result r = __pNetworkManagerImpl->SelectNetwork(networkInfo);
149 if (r == E_PRIVILEGE_DENIED)
151 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
153 else if( r != E_SUCCESS)
155 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
163 NetworkManager::SelectNetwork(void)
165 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
167 result r = __pNetworkManagerImpl->SelectNetwork();
169 if (r == E_PRIVILEGE_DENIED)
171 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
173 else if( r != E_SUCCESS)
175 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
183 NetworkManager::SearchNetwork(void)
185 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
187 result r = __pNetworkManagerImpl->SearchNetwork();
189 if (r == E_PRIVILEGE_DENIED)
191 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
193 else if( r != E_SUCCESS)
195 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
201 }} // Tizen::Telephony