// // Copyright (c) 2012 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // /** * @file FScl_PhoneNumberImpl.cpp * @brief This is the implementation for _PhoneNumberImpl class. * * This file contains definitions of @e _PhoneNumberImpl class. */ #include #include #include #include #include "FScl_PhoneNumberImpl.h" using namespace Tizen::Base; namespace Tizen { namespace Social { _PhoneNumberImpl::_PhoneNumberImpl(void) : __recordId(-1) , __type(PHONENUMBER_TYPE_HOME) , __isPhoneTypeChanged(false) { } _PhoneNumberImpl::_PhoneNumberImpl(PhoneNumberType type, const String& number) : __recordId(-1) , __type(type) , __number(number) , __isPhoneTypeChanged(false) { } _PhoneNumberImpl::_PhoneNumberImpl(const _PhoneNumberImpl& rhs) { __recordId = rhs.__recordId; __type = rhs.__type; __label = rhs.__label; __number = rhs.__number; __isPhoneTypeChanged = rhs.__isPhoneTypeChanged; } _PhoneNumberImpl::~_PhoneNumberImpl(void) { } _PhoneNumberImpl& _PhoneNumberImpl::operator =(const _PhoneNumberImpl& rhs) { if (this == &rhs) { return *this; } __recordId = rhs.__recordId; __type = rhs.__type; __label = rhs.__label; __number = rhs.__number; __isPhoneTypeChanged = rhs.__isPhoneTypeChanged; return *this; } bool _PhoneNumberImpl::operator ==(const _PhoneNumberImpl& rhs) const { if (__type != rhs.__type || __label != rhs.__label || __number != rhs.__number) { return false; } return true; } bool _PhoneNumberImpl::Equals(const Object& rhs) const { const _PhoneNumberImpl* pPhoneNumberImpl = dynamic_cast(&rhs); if (pPhoneNumberImpl == null) { return false; } return (*this == *pPhoneNumberImpl); } int _PhoneNumberImpl::GetHashCode(void) const { int hashCode = __recordId; hashCode += __type; hashCode += __number.GetHashCode(); hashCode += __label.GetHashCode(); return hashCode; } bool _PhoneNumberImpl::operator !=(const _PhoneNumberImpl& rhs) const { return !(*this == rhs); } PhoneNumberType _PhoneNumberImpl::GetType(void) const { return __type; } String _PhoneNumberImpl::GetPhoneNumber(void) const { return __number; } void _PhoneNumberImpl::SetType(PhoneNumberType type) { __type = type; __isPhoneTypeChanged = true; } result _PhoneNumberImpl::SetPhoneNumber(const String& number) { SysTryReturn(NID_SCL, !number.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phone number is empty.", GetErrorMessage(E_INVALID_ARG)); __number = number; return E_SUCCESS; } void _PhoneNumberImpl::SetLabel(const String& label) { __label = label; } String _PhoneNumberImpl::GetLabel(void) const { return __label; } void _PhoneNumberImpl::SetRecordId(int recordId) { __recordId = recordId; } int _PhoneNumberImpl::GetRecordId(void) const { return __recordId; } bool _PhoneNumberImpl::IsEmpty(void) const { return __number.IsEmpty(); } bool _PhoneNumberImpl::IsPhoneNumberTypeChanged(void) const { return __isPhoneTypeChanged; } _PhoneNumberImpl* _PhoneNumberImpl::GetInstance(PhoneNumber& phoneNumber) { return phoneNumber.__pPhoneNumberImpl; } const _PhoneNumberImpl* _PhoneNumberImpl::GetInstance(const PhoneNumber& phoneNumber) { return phoneNumber.__pPhoneNumberImpl; } }} // Tizen::Social