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 FTelNetworkInfo.cpp
19 * @brief This is the implementation file for NetworkInfo class.
22 #include <FTelNetworkInfo.h>
23 #include <FBaseSysLog.h>
24 #include <FSec_AccessController.h>
25 #include <FSys_SystemInfoImpl.h>
26 #include "FTel_NetworkInfoImpl.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Security;
31 using namespace Tizen::System;
34 namespace Tizen { namespace Telephony
37 NetworkInfo::NetworkInfo(void)
38 : __pNetworkInfoImpl(null)
40 __pNetworkInfoImpl = new (std::nothrow) _NetworkInfoImpl();
41 SysTryReturnVoidResult(NID_TEL, __pNetworkInfoImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
44 NetworkInfo::NetworkInfo(const NetworkInfo& value)
46 __pNetworkInfoImpl = new (std::nothrow) _NetworkInfoImpl(*(value.__pNetworkInfoImpl));
47 SysTryReturnVoidResult(NID_TEL, __pNetworkInfoImpl != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
50 NetworkInfo::~NetworkInfo(void)
52 delete __pNetworkInfoImpl;
56 NetworkInfo::operator=(const NetworkInfo& rhs)
60 *__pNetworkInfoImpl = *(rhs.__pNetworkInfoImpl);
67 NetworkInfo::GetMnc(void) const
72 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
74 SysTryReturn(NID_TEL, r == E_SUCCESS, mnc, E_PRIVILEGE_DENIED,
75 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
77 mnc = __pNetworkInfoImpl->GetMnc();
83 NetworkInfo::GetMcc(void) const
88 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
90 SysTryReturn(NID_TEL, r == E_SUCCESS, mcc, E_PRIVILEGE_DENIED,
91 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
93 mcc = __pNetworkInfoImpl->GetMcc();
99 NetworkInfo::GetPlmn(void) const
104 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
106 SysTryReturn(NID_TEL, r == E_SUCCESS, plmn, E_PRIVILEGE_DENIED,
107 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
109 plmn = __pNetworkInfoImpl->GetPlmn();
115 NetworkInfo::GetCellId(void) const
120 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
122 SysTryReturn(NID_TEL, r == E_SUCCESS, cellId, E_PRIVILEGE_DENIED,
123 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
125 cellId = __pNetworkInfoImpl->GetCellId();
131 NetworkInfo::GetLac(void) const
136 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
138 SysTryReturn(NID_TEL, r == E_SUCCESS, lac, E_PRIVILEGE_DENIED,
139 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
141 lac = __pNetworkInfoImpl->GetLac();
147 NetworkInfo::GetOperatorName(void) const
152 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
154 SysTryReturn(NID_TEL, r == E_SUCCESS, operatorName, E_PRIVILEGE_DENIED,
155 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
157 operatorName = __pNetworkInfoImpl->GetOperatorName();
163 NetworkInfo::Equals(const Object& obj) const
165 const NetworkInfo* pOther = dynamic_cast<const NetworkInfo*>(&obj);
177 return __pNetworkInfoImpl->Equals(*pOther->__pNetworkInfoImpl);
181 NetworkInfo::GetHashCode(void) const
183 return __pNetworkInfoImpl->GetHashCode();
187 NetworkInfo::GetRssi(void)
189 static const wchar_t _TELEPHONY[] = L"http://tizen.org/feature/network.telephony";
194 result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
195 SysTryReturn(NID_TEL, r == E_SUCCESS, rssi, E_PRIVILEGE_DENIED,
196 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
198 bool isTelephonySupported = false;
200 r = _SystemInfoImpl::GetSysInfo(_TELEPHONY, isTelephonySupported);
201 SysTryReturn(NID_TEL, r == E_SUCCESS && isTelephonySupported, rssi, E_UNSUPPORTED_OPERATION,
202 "[%s] Telephony is not supported.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
204 rssi = _NetworkInfoImpl::GetRssi();
208 SysTryReturn(NID_TEL, r == E_SUCCESS, rssi, r, "[%s] Propagating.", GetErrorMessage(r));
213 }} // Tizen::Telephony