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.
18 * @brief This is the implementation for Email class.
20 * This file contains definitions of @e Email class.
23 #include <FSclEmail.h>
24 #include <FApp_AppInfo.h>
25 #include <FBaseSysLog.h>
26 #include "FScl_EmailImpl.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
31 namespace Tizen { namespace Social
36 __pEmailImpl = new (std::nothrow) _EmailImpl();
37 SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
40 Email::Email(EmailType type, const String& email)
42 __pEmailImpl = new (std::nothrow) _EmailImpl(type, email);
43 SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
46 Email::Email(const Email& rhs)
48 __pEmailImpl = new (std::nothrow) _EmailImpl(*rhs.__pEmailImpl);
49 SysTryReturnVoidResult(NID_SCL, __pEmailImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
58 Email::operator =(const Email& rhs)
65 *__pEmailImpl = *rhs.__pEmailImpl;
71 Email::operator ==(const Email& rhs) const
73 return *__pEmailImpl == *rhs.__pEmailImpl;
77 Email::operator !=(const Email& rhs) const
79 return !(*this == rhs);
83 Email::Equals(const Object& rhs) const
85 const Email* pEmail = dynamic_cast<const Email*>(&rhs);
92 return __pEmailImpl->Equals(*pEmail->__pEmailImpl);
96 Email::GetHashCode(void) const
98 return __pEmailImpl->GetHashCode();
102 Email::GetType(void) const
104 EmailType type = __pEmailImpl->GetType();
106 if (type == EMAIL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
108 type = EMAIL_TYPE_OTHER;
115 Email::GetLabel(void) const
117 return __pEmailImpl->GetLabel();
121 Email::GetEmail(void) const
123 String email = __pEmailImpl->GetEmail();
125 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
127 if (email.GetLength() > MAX_EMAIL_LENGTH)
129 email.SetLength(MAX_EMAIL_LENGTH);
137 Email::SetType(EmailType type)
139 return __pEmailImpl->SetType(type);
143 Email::SetLabel(const String& label)
145 return __pEmailImpl->SetLabel(label);
149 Email::SetEmail(const String& email)
151 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
153 SysTryReturnResult(NID_SCL, email.GetLength() <= MAX_EMAIL_LENGTH, E_INVALID_ARG, "The length of the email exceeds the max length.");
156 return __pEmailImpl->SetEmail(email);