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 FTel_NetworkInfoImpl.cpp
19 * @brief This is the implementation file for _NetworkInfoImpl class.
22 #include <telephony_network.h>
23 #include <FTelNetworkInfo.h>
24 #include <FBaseErrors.h>
25 #include <FBaseSysLog.h>
26 #include "FTel_NetworkInfoImpl.h"
28 using namespace Tizen::Base;
30 namespace Tizen { namespace Telephony
34 _NetworkInfoImpl::_NetworkInfoImpl(void)
39 , __networkType(_NETWORK_TYPE_UNDEFINED)
43 _NetworkInfoImpl::_NetworkInfoImpl(const _NetworkInfoImpl& value)
44 : __cellId(value.__cellId)
48 , __plmn(value.__plmn)
49 , __operatorName(value.__operatorName)
50 , __networkType(value.__networkType)
54 _NetworkInfoImpl::~_NetworkInfoImpl(void)
59 _NetworkInfoImpl::GetCellId(void) const
65 _NetworkInfoImpl::GetLac(void) const
71 _NetworkInfoImpl::GetMcc(void) const
77 _NetworkInfoImpl::GetMnc(void) const
82 _NetworkInfoImpl::GetPlmn(void) const
88 _NetworkInfoImpl::GetOperatorName(void) const
90 return __operatorName;
94 _NetworkInfoImpl::GetNetworkType(void) const
100 _NetworkInfoImpl::Equals(const Object& obj) const
102 const _NetworkInfoImpl* pOther = static_cast<const _NetworkInfoImpl*>(&obj);
105 || __cellId != pOther->__cellId
106 || __lac != pOther->__lac
107 || __mcc != pOther->__mcc
108 || __mnc != pOther->__mnc
109 || __plmn != pOther->__plmn
110 || __operatorName != pOther->__operatorName
111 || __networkType != pOther->__networkType)
120 _NetworkInfoImpl::GetHashCode(void) const
122 static const int _PRIME_NUMBER = 31;
125 hashCode = _PRIME_NUMBER * __mcc;
126 hashCode = (_PRIME_NUMBER * hashCode) ^ __mnc;
127 hashCode = (_PRIME_NUMBER * hashCode) ^ __cellId;
128 hashCode = (_PRIME_NUMBER * hashCode) ^ __lac;
129 hashCode = (_PRIME_NUMBER * hashCode) ^ __plmn.GetHashCode();
130 hashCode = (_PRIME_NUMBER * hashCode) ^ __operatorName.GetHashCode();
131 hashCode = (_PRIME_NUMBER * hashCode) ^ __networkType;
136 _NetworkInfoImpl::GetRssi(void)
138 static const int rssiArray[] = {10, 25, 45, 60, 75, 75, 90};
139 network_info_rssi_e rssi;
140 int err = NETWORK_INFO_ERROR_NONE;
142 err = network_info_get_rssi(&rssi);
143 SysLog(NID_TEL, "network_info_get_rssi() returned %d value and the rssi value is %d", err, rssi);
144 SysTryReturn(NID_TEL, err == NETWORK_INFO_ERROR_NONE, 0, E_SYSTEM,
145 "[%s] A system error has occurred. Failed to get the received signal strength indication.", GetErrorMessage(E_SYSTEM));
147 return rssiArray[rssi];
151 _NetworkInfoImpl::SetCellId(int cellId)
157 _NetworkInfoImpl::SetLac(int lac)
163 _NetworkInfoImpl::SetMcc(int mcc)
169 _NetworkInfoImpl::SetMnc(int mnc)
175 _NetworkInfoImpl::SetPlmn(const String& plmn)
181 _NetworkInfoImpl::SetOperatorName(const String& operatorName)
183 __operatorName = operatorName;
187 _NetworkInfoImpl::SetNetworkType(_NetworkType networkType)
189 __networkType = networkType;
194 _NetworkInfoImpl::operator=(const _NetworkInfoImpl& rhs)
198 __cellId = rhs.__cellId;
203 __operatorName = rhs.__operatorName;
204 __networkType = rhs.__networkType;
211 _NetworkInfoImpl::GetInstance(NetworkInfo& networkInfo)
213 return networkInfo.__pNetworkInfoImpl;
216 const _NetworkInfoImpl*
217 _NetworkInfoImpl::GetInstance(const NetworkInfo& networkInfo)
219 return networkInfo.__pNetworkInfoImpl;
222 }} // Tizen::Telephony