// // Open Service Platform // 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 FSclAttendee.cpp * @brief This is the implementation for Attendee class. * * This file contains definitions of @e Attendee class. */ #include #include #include #include using namespace Tizen::Base; using namespace Tizen::App; namespace Tizen { namespace Social { Attendee::Attendee(const String& email) : __email(email) , __attendeeRole(ATTENDEE_ROLE_ATTENDEE) , __attendeeStatus(ATTENDEE_STATUS_NONE) , __pAttendeeImpl(null) , __personId(INVALID_RECORD_ID) { // empty body. } Attendee::Attendee(const Attendee& rhs) : __name(rhs.__name) , __email(rhs.__email) , __phoneNumber(rhs.__phoneNumber) , __attendeeRole(rhs.__attendeeRole) , __attendeeStatus(rhs.__attendeeStatus) , __pAttendeeImpl(null) , __personId(rhs.__personId) { // empty body. } Attendee::~Attendee(void) { // empty body. } Attendee& Attendee::operator =(const Attendee& rhs) { if (this == &rhs) { return *this; } __name = rhs.__name; __email = rhs.__email; __phoneNumber = rhs.__phoneNumber; __attendeeRole = rhs.__attendeeRole; __attendeeStatus = rhs.__attendeeStatus; __personId = rhs.__personId; return *this; } bool Attendee::operator ==(const Attendee& rhs) const { if ((__name == rhs.__name) && (__email == rhs.__email) && (__phoneNumber == rhs.__phoneNumber) && (__attendeeRole == rhs.__attendeeRole) && (__attendeeStatus == rhs.__attendeeStatus) && (__personId == rhs.__personId)) { return true; } return false; } bool Attendee::operator !=(const Attendee& rhs) const { return !(*this == rhs); } bool Attendee::Equals(const Object& rhs) const { const Attendee* pAttendee = dynamic_cast(&rhs); if (pAttendee == null) { return false; } return (*this == *pAttendee); } int Attendee::GetHashCode(void) const { int hashCode = 17; hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __name.GetHashCode(); hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __email.GetHashCode(); hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __phoneNumber.GetHashCode(); hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __attendeeRole; hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __attendeeStatus; hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __personId; return hashCode; } String Attendee::GetName(void) const { return __name; } String Attendee::GetEmail(void) const { return __email; } AttendeeRole Attendee::GetRole(void) const { return __attendeeRole; } AttendeeStatus Attendee::GetStatus(void) const { return __attendeeStatus; } result Attendee::SetName(const String& name) { SysTryReturnResult(NID_SCL, !name.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. The name is empty."); if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) { SysTryReturnResult(NID_SCL, name.GetLength() <= MAX_ATTENDEE_NAME_LENGTH, E_INVALID_ARG, "Invalid argument is used. The length of the name exceeds MAX_ATTENDEE_NAME_LENGTH."); } __name = name; return E_SUCCESS; } result Attendee::SetEmail(const String& email) { SysTryReturnResult(NID_SCL, !email.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. The email is empty."); if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) { SysTryReturnResult(NID_SCL, email.GetLength() <= MAX_ATTENDEE_EMAIL_LENGTH, E_INVALID_ARG, "Invalid argument is used. The length of the email exceeds MAX_ATTENDEE_EMAIL_LENGTH."); } __email = email; return E_SUCCESS; } void Attendee::SetRole(AttendeeRole role) { switch (role) { case ATTENDEE_ROLE_ATTENDEE: //fall through case ATTENDEE_ROLE_REQUIRED_ATTENDEE: //fall through case ATTENDEE_ROLE_ORGANIZER: __attendeeRole = role; break; default: __attendeeRole = ATTENDEE_ROLE_ATTENDEE; break; } } void Attendee::SetStatus(AttendeeStatus status) { switch (status) { case ATTENDEE_STATUS_NONE: //fall through case ATTENDEE_STATUS_NOT_RESPONDED: //fall through case ATTENDEE_STATUS_ACCEPTED: //fall through case ATTENDEE_STATUS_DECLINED: //fall through case ATTENDEE_STATUS_TENTATIVE: __attendeeStatus = status; break; default: __attendeeStatus = ATTENDEE_STATUS_NONE; break; } } void Attendee::SetPhoneNumber(const String& phoneNumber) { __phoneNumber = phoneNumber; } String Attendee::GetPhoneNumber(void) const { return __phoneNumber; } void Attendee::SetPersonId(PersonId personId) { __personId = personId; } PersonId Attendee::GetPersonId(void) const { return __personId; } }} // Tizen::Social