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 FSclImAddress.cpp
18 * @brief This is the implementation for ImAddress class.
20 * This file contains definitions of @e ImAddress class.
23 #include <FSclImAddress.h>
24 #include <FApp_AppInfo.h>
25 #include <FBaseSysLog.h>
26 #include "FScl_ImAddressImpl.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
31 namespace Tizen { namespace Social
34 ImAddress::ImAddress(void)
36 __pImAddressImpl = new (std::nothrow) _ImAddressImpl();
37 SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
40 ImAddress::ImAddress(const String& serviceProviderName, const String& imAddress)
42 __pImAddressImpl = new (std::nothrow) _ImAddressImpl(serviceProviderName, imAddress);
43 SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
46 ImAddress::ImAddress(const ImAddress& rhs)
48 __pImAddressImpl = new (std::nothrow) _ImAddressImpl(*rhs.__pImAddressImpl);
49 SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
52 ImAddress::~ImAddress(void)
54 delete __pImAddressImpl;
58 ImAddress::operator =(const ImAddress& rhs)
65 *__pImAddressImpl = *rhs.__pImAddressImpl;
71 ImAddress::operator ==(const ImAddress& rhs) const
73 return *__pImAddressImpl == *rhs.__pImAddressImpl;
77 ImAddress::operator !=(const ImAddress& rhs) const
79 return !(*this == rhs);
83 ImAddress::Equals(const Object& rhs) const
85 const ImAddress* pImAddress = dynamic_cast<const ImAddress*>(&rhs);
86 if (pImAddress == null)
91 return __pImAddressImpl->Equals(*pImAddress->__pImAddressImpl);
95 ImAddress::GetHashCode(void) const
97 return __pImAddressImpl->GetHashCode();
101 ImAddress::GetServiceProviderName(void) const
103 return __pImAddressImpl->GetServiceProviderName();
107 ImAddress::GetImAddress(void) const
109 String imAddress = __pImAddressImpl->GetImAddress();
111 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
113 if (imAddress.GetLength() > MAX_IM_ADDRESS_LENGTH)
115 imAddress.SetLength(MAX_IM_ADDRESS_LENGTH);
123 ImAddress::SetServiceProviderName(const String& serviceProviderName)
125 __pImAddressImpl->SetServiceProviderName(serviceProviderName);
129 ImAddress::SetImAddress(const String& imAddress)
131 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
133 SysTryReturn(NID_SCL, imAddress.GetLength() <= MAX_IM_ADDRESS_LENGTH,
134 E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the imAddress exceeds MAX_IM_ADDRESS_LENGTH.", GetErrorMessage(E_INVALID_ARG));
137 return __pImAddressImpl->SetImAddress(imAddress);