2 // Open Service Platform
3 // Copyright (c) 2012 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 FScl_EmailImpl.cpp
19 * @brief This is the implementation for _EmailImpl class.
21 * This file contains definitions of @e _EmailImpl class.
24 #include <unique_ptr.h>
25 #include <FApp_AppInfo.h>
26 #include <FBaseSysLog.h>
27 #include <FSclEmail.h>
28 #include <FBase_StringConverter.h>
29 #include "FScl_EmailImpl.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
34 namespace Tizen { namespace Social
37 _EmailImpl::_EmailImpl(void)
39 , __type(EMAIL_TYPE_PERSONAL)
44 _EmailImpl::_EmailImpl(EmailType type, const String& email)
48 String stringValue = email;
49 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
51 if (stringValue.GetLength() > MAX_EMAIL_LENGTH)
53 stringValue.SetLength(MAX_EMAIL_LENGTH);
57 __email = stringValue;
61 _EmailImpl::_EmailImpl(const _EmailImpl& rhs)
63 __recordId = rhs.__recordId;
65 __label = rhs.__label;
66 __email = rhs.__email;
69 _EmailImpl::~_EmailImpl(void)
76 _EmailImpl::operator =(const _EmailImpl& rhs)
83 __recordId = rhs.__recordId;
85 __label = rhs.__label;
86 __email = rhs.__email;
92 _EmailImpl::operator ==(const _EmailImpl& rhs) const
94 if(__type != rhs.__type || __label != rhs.__label || __email != rhs.__email)
103 _EmailImpl::operator !=(const _EmailImpl& rhs) const
105 return !(*this == rhs);
109 _EmailImpl::Equals(const Object& rhs) const
111 const _EmailImpl* pEmailImpl = dynamic_cast<const _EmailImpl*>(&rhs);
113 if (pEmailImpl == null)
118 return (*this == *pEmailImpl);
122 _EmailImpl::GetHashCode(void) const
124 int hashCode = __recordId;
126 hashCode += __label.GetHashCode();
127 hashCode += __email.GetHashCode();
133 _EmailImpl::GetType(void) const
141 _EmailImpl::GetEmail(void) const
147 _EmailImpl::GetLabel(void) const
153 _EmailImpl::SetType(EmailType type)
159 _EmailImpl::SetEmail(const String& email)
161 SysTryReturnResult(NID_SCL, !email.IsEmpty(), E_INVALID_ARG, "The email is an empty string.");
170 _EmailImpl::SetLabel(const String& label)
176 _EmailImpl::SetRecordId(int recordId)
178 __recordId = recordId;
182 _EmailImpl::GetRecordId(void) const
188 _EmailImpl::IsEmpty(void) const
190 return __email.IsEmpty();
194 _EmailImpl::GetInstance(const Email& email)
196 return email.__pEmailImpl;
200 _EmailImpl::GetInstance(Email& email)
202 return email.__pEmailImpl;