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.
19 * @brief This is the implementation for Email class.
21 * This file contains definitions of @e Email class.
24 #include <FSclEmail.h>
25 #include <FApp_AppInfo.h>
26 #include <FBaseSysLog.h>
27 #include "FScl_EmailImpl.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
32 namespace Tizen { namespace Social
37 __pEmailImpl = new (std::nothrow) _EmailImpl();
38 SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
41 Email::Email(EmailType type, const String& email)
43 __pEmailImpl = new (std::nothrow) _EmailImpl(type, email);
44 SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
47 Email::Email(const Email& rhs)
49 __pEmailImpl = new (std::nothrow) _EmailImpl(*rhs.__pEmailImpl);
50 SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
59 Email::operator =(const Email& rhs)
66 *__pEmailImpl = *rhs.__pEmailImpl;
72 Email::operator ==(const Email& rhs) const
74 return *__pEmailImpl == *rhs.__pEmailImpl;
78 Email::operator !=(const Email& rhs) const
80 return !(*this == rhs);
84 Email::Equals(const Object& rhs) const
86 const Email* pEmail = dynamic_cast<const Email*>(&rhs);
93 return __pEmailImpl->Equals(*pEmail->__pEmailImpl);
97 Email::GetHashCode(void) const
99 return __pEmailImpl->GetHashCode();
103 Email::GetType(void) const
105 EmailType type = __pEmailImpl->GetType();
107 if (type == EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
109 type = EMAIL_TYPE_OTHER;
116 Email::GetLabel(void) const
118 return __pEmailImpl->GetLabel();
122 Email::GetEmail(void) const
124 String email = __pEmailImpl->GetEmail();
126 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
128 if (email.GetLength() > MAX_EMAIL_LENGTH)
130 email.SetLength(MAX_EMAIL_LENGTH);
138 Email::SetType(EmailType type)
140 return __pEmailImpl->SetType(type);
144 Email::SetLabel(const String& label)
146 return __pEmailImpl->SetLabel(label);
150 Email::SetEmail(const String& email)
152 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
154 SysTryReturnResult(NID_SCL, email.GetLength() <= MAX_EMAIL_LENGTH, E_INVALID_ARG, "The length of the email exceeds the max length.");
157 return __pEmailImpl->SetEmail(email);