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, _PRV_TELEPHONY);
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, _PRV_TELEPHONY);
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));
122 NetworkManager::GetNetworkSelectionMode(void)
124 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
126 result r = __pNetworkManagerImpl->GetNetworkSelectionMode();
128 if (r == E_PRIVILEGE_DENIED)
130 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
132 else if( r != E_SUCCESS)
134 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
142 NetworkManager::SelectNetwork(const NetworkInfo& networkInfo)
144 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
146 result r = __pNetworkManagerImpl->SelectNetwork(networkInfo);
148 if (r == E_PRIVILEGE_DENIED)
150 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
152 else if( r != E_SUCCESS)
154 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
162 NetworkManager::SelectNetwork(void)
164 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
166 result r = __pNetworkManagerImpl->SelectNetwork();
168 if (r == E_PRIVILEGE_DENIED)
170 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
172 else if( r != E_SUCCESS)
174 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
182 NetworkManager::SearchNetwork(void)
184 SysAssertf(__pNetworkManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
186 result r = __pNetworkManagerImpl->SearchNetwork();
188 if (r == E_PRIVILEGE_DENIED)
190 SysLogException(NID_TEL, E_PRIVILEGE_DENIED, "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
192 else if( r != E_SUCCESS)
194 SysLogException(NID_TEL, r,"[%s] Propagating.", GetErrorMessage(r));
200 }} // Tizen::Telephony