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 FSclImAddress.cpp
19 * @brief This is the implementation for ImAddress class.
21 * This file contains definitions of @e ImAddress class.
24 #include <FSclImAddress.h>
25 #include <FApp_AppInfo.h>
26 #include <FBaseSysLog.h>
27 #include "FScl_ImAddressImpl.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
32 namespace Tizen { namespace Social
35 ImAddress::ImAddress(void)
37 __pImAddressImpl = new (std::nothrow) _ImAddressImpl();
38 SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
41 ImAddress::ImAddress(const String& serviceProviderName, const String& imAddress)
43 __pImAddressImpl = new (std::nothrow) _ImAddressImpl(serviceProviderName, imAddress);
44 SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
47 ImAddress::ImAddress(const ImAddress& rhs)
49 __pImAddressImpl = new (std::nothrow) _ImAddressImpl(*rhs.__pImAddressImpl);
50 SysTryReturnVoidResult(NID_SCL, __pImAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
53 ImAddress::~ImAddress(void)
55 delete __pImAddressImpl;
59 ImAddress::operator =(const ImAddress& rhs)
66 *__pImAddressImpl = *rhs.__pImAddressImpl;
72 ImAddress::operator ==(const ImAddress& rhs) const
74 return *__pImAddressImpl == *rhs.__pImAddressImpl;
78 ImAddress::operator !=(const ImAddress& rhs) const
80 return !(*this == rhs);
84 ImAddress::Equals(const Object& rhs) const
86 const ImAddress* pImAddress = dynamic_cast<const ImAddress*>(&rhs);
87 if (pImAddress == null)
92 return __pImAddressImpl->Equals(*pImAddress->__pImAddressImpl);
96 ImAddress::GetHashCode(void) const
98 return __pImAddressImpl->GetHashCode();
102 ImAddress::GetServiceProviderName(void) const
104 return __pImAddressImpl->GetServiceProviderName();
108 ImAddress::GetImAddress(void) const
110 String imAddress = __pImAddressImpl->GetImAddress();
112 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
114 if (imAddress.GetLength() > MAX_IM_ADDRESS_LENGTH)
116 imAddress.SetLength(MAX_IM_ADDRESS_LENGTH);
124 ImAddress::SetServiceProviderName(const String& serviceProviderName)
126 __pImAddressImpl->SetServiceProviderName(serviceProviderName);
130 ImAddress::SetImAddress(const String& imAddress)
132 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
134 SysTryReturn(NID_SCL, imAddress.GetLength() <= MAX_IM_ADDRESS_LENGTH,
135 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));
138 return __pImAddressImpl->SetImAddress(imAddress);