2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FScl_EmailImpl.cpp
18 * @brief This is the implementation for _EmailImpl class.
20 * This file contains definitions of @e _EmailImpl class.
23 #include <unique_ptr.h>
24 #include <FApp_AppInfo.h>
25 #include <FBaseSysLog.h>
26 #include <FSclEmail.h>
27 #include <FBase_StringConverter.h>
28 #include "FScl_EmailImpl.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
33 namespace Tizen { namespace Social
36 _EmailImpl::_EmailImpl(void)
38 , __type(EMAIL_TYPE_PERSONAL)
43 _EmailImpl::_EmailImpl(EmailType type, const String& email)
47 String stringValue = email;
48 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
50 if (stringValue.GetLength() > MAX_EMAIL_LENGTH)
52 stringValue.SetLength(MAX_EMAIL_LENGTH);
56 __email = stringValue;
60 _EmailImpl::_EmailImpl(const _EmailImpl& rhs)
62 __recordId = rhs.__recordId;
64 __label = rhs.__label;
65 __email = rhs.__email;
68 _EmailImpl::~_EmailImpl(void)
75 _EmailImpl::operator =(const _EmailImpl& rhs)
82 __recordId = rhs.__recordId;
84 __label = rhs.__label;
85 __email = rhs.__email;
91 _EmailImpl::operator ==(const _EmailImpl& rhs) const
93 if(__type != rhs.__type || __label != rhs.__label || __email != rhs.__email)
102 _EmailImpl::operator !=(const _EmailImpl& rhs) const
104 return !(*this == rhs);
108 _EmailImpl::Equals(const Object& rhs) const
110 const _EmailImpl* pEmailImpl = dynamic_cast<const _EmailImpl*>(&rhs);
112 if (pEmailImpl == null)
117 return (*this == *pEmailImpl);
121 _EmailImpl::GetHashCode(void) const
123 int hashCode = __recordId;
125 hashCode += __label.GetHashCode();
126 hashCode += __email.GetHashCode();
132 _EmailImpl::GetType(void) const
140 _EmailImpl::GetEmail(void) const
146 _EmailImpl::GetLabel(void) const
152 _EmailImpl::SetType(EmailType type)
158 _EmailImpl::SetEmail(const String& email)
160 SysTryReturnResult(NID_SCL, !email.IsEmpty(), E_INVALID_ARG, "The email is an empty string.");
169 _EmailImpl::SetLabel(const String& label)
175 _EmailImpl::SetRecordId(int recordId)
177 __recordId = recordId;
181 _EmailImpl::GetRecordId(void) const
187 _EmailImpl::IsEmpty(void) const
189 return __email.IsEmpty();
193 _EmailImpl::GetInstance(const Email& email)
195 return email.__pEmailImpl;
199 _EmailImpl::GetInstance(Email& email)
201 return email.__pEmailImpl;