// // Copyright (c) 2013 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // /** * @file FScl_ContactAppLaunchDataImpl.cpp * @brief This is the header file for the %_ContactAppLaunchData class. * * This header file contains the declarations of the %_ContactAppLaunchData class. */ #include #include "FScl_ContactAppLaunchDataImpl.h" using namespace Tizen::Base; using namespace Tizen::Base::Collection; namespace Tizen { namespace Social { _ContactAppLaunchDataImpl::_ContactAppLaunchDataImpl(void) { std::unique_ptr pExtraData(new (std::nothrow) HashMap()); SysTryReturnVoidResult(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); result r = pExtraData->Construct(); SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r)); __pExtraData = std::move(pExtraData); } _ContactAppLaunchDataImpl::_ContactAppLaunchDataImpl(const _ContactAppLaunchDataImpl& rhs) { std::unique_ptr pExtraData(new (std::nothrow) HashMap()); SysTryReturnVoidResult(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); result r = pExtraData->Construct(); SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r)); std::unique_ptr pMapEnum((rhs.__pExtraData)->GetMapEnumeratorN()); SysTryReturnVoidResult(NID_SCL, pMapEnum != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); std::unique_ptr pKey(null); std::unique_ptr pVal(null); String* pStr = null; while (pMapEnum->MoveNext() == E_SUCCESS) { pStr = static_cast (pMapEnum->GetKey()); pKey.reset(new (std::nothrow) String(*pStr)); SysTryReturnVoidResult(NID_SCL, pKey != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); pStr = static_cast (pMapEnum->GetValue()); pVal.reset(new (std::nothrow) String(*pStr)); SysTryReturnVoidResult(NID_SCL, pVal != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pExtraData->Add(pKey.get(), pVal.get()); SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r)); pKey.release(); pVal.release(); } __pExtraData = std::move(pExtraData); __displayText = rhs.__displayText; __uid = rhs.__uid; __appId = rhs.__appId; __operationId = rhs.__operationId; __uri = rhs.__uri; __category = rhs.__category; __mime = rhs.__mime; } _ContactAppLaunchDataImpl::~_ContactAppLaunchDataImpl(void) { } _ContactAppLaunchDataImpl& _ContactAppLaunchDataImpl::operator =(const _ContactAppLaunchDataImpl& rhs) { if (this == &rhs) { return *this; } std::unique_ptr pExtraData(new (std::nothrow) HashMap()); SysTryReturn(NID_SCL, pExtraData != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); result r = pExtraData->Construct(); SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r)); std::unique_ptr pMapEnum((rhs.__pExtraData)->GetMapEnumeratorN()); SysTryReturn(NID_SCL, pMapEnum != null, *this, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); std::unique_ptr pKey(null); std::unique_ptr pVal(null); String* pStr = null; while (pMapEnum->MoveNext() == E_SUCCESS) { pStr = static_cast (pMapEnum->GetKey()); pKey.reset(new (std::nothrow) String(*pStr)); SysTryReturn(NID_SCL, pKey != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); pStr = static_cast (pMapEnum->GetValue()); pVal.reset(new (std::nothrow) String(*pStr)); SysTryReturn(NID_SCL, pVal != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pExtraData->Add(pKey.get(), pVal.get()); SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Propagating.", GetErrorMessage(r)); pKey.release(); pVal.release(); } __pExtraData = std::move(pExtraData); __displayText = rhs.__displayText; __uid = rhs.__uid; __appId = rhs.__appId; __operationId = rhs.__operationId; __uri = rhs.__uri; __category = rhs.__category; __mime = rhs.__mime; return *this; } bool operator ==(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs) { if (lhs.__displayText != rhs.__displayText) { return false; } if (lhs.__uid != rhs.__uid) { return false; } if (lhs.__appId != rhs.__appId) { return false; } if (lhs.__operationId != rhs.__operationId) { return false; } if (lhs.__uri != rhs.__uri) { return false; } if (lhs.__category != rhs.__category) { return false; } if (lhs.__mime != rhs.__mime) { return false; } if (!lhs.__pExtraData->Equals(*rhs.__pExtraData)) { return false; } return true; } bool operator !=(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs) { return !(lhs == rhs); } bool _ContactAppLaunchDataImpl::Equals(const Object& rhs) const { const _ContactAppLaunchDataImpl* pContactAppLaunchData = dynamic_cast(&rhs); if (pContactAppLaunchData == null) { return false; } return *this == *pContactAppLaunchData; } int _ContactAppLaunchDataImpl::GetHashCode(void) const { int hash = __displayText.GetHashCode(); hash += __uid.GetHashCode(); hash += __appId.GetHashCode(); hash += __operationId.GetHashCode(); hash += __uri.GetHashCode(); hash += __category.GetHashCode(); hash += __mime.GetHashCode(); return hash; } String _ContactAppLaunchDataImpl::GetDisplayText(void) const { return __displayText; } String _ContactAppLaunchDataImpl::GetUid(void) const { return __uid; } String _ContactAppLaunchDataImpl::GetAppId(void) const { return __appId; } String _ContactAppLaunchDataImpl::GetOperationId(void) const { return __operationId; } String _ContactAppLaunchDataImpl::GetUri(void) const { return __uri; } String _ContactAppLaunchDataImpl::GetCategory(void) const { return __category; } String _ContactAppLaunchDataImpl::GetMime(void) const { return __mime; } IMap* _ContactAppLaunchDataImpl::GetExtraDataN(void) const { ClearLastResult(); std::unique_ptr pExtraData(new (std::nothrow) HashMap()); SysTryReturn(NID_SCL, pExtraData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); result r = pExtraData->Construct(); SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r)); std::unique_ptr pMapEnum(__pExtraData->GetMapEnumeratorN()); SysTryReturn(NID_SCL, pMapEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); std::unique_ptr pKey(null); std::unique_ptr pVal(null); String* pStr = null; while (pMapEnum->MoveNext() == E_SUCCESS) { pStr = static_cast (pMapEnum->GetKey()); pKey.reset(new (std::nothrow) String(*pStr)); SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); pStr = static_cast (pMapEnum->GetValue()); pVal.reset(new (std::nothrow) String(*pStr)); SysTryReturn(NID_SCL, pVal != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pExtraData->Add(pKey.get(), pVal.get()); SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); pKey.release(); pVal.release(); } return pExtraData.release(); } void _ContactAppLaunchDataImpl::SetDisplayText(const String& displayText) { __displayText = displayText; } void _ContactAppLaunchDataImpl::SetUid(const String& uid) { __uid = uid; } void _ContactAppLaunchDataImpl::SetAppId(const String& appId) { __appId = appId; } void _ContactAppLaunchDataImpl::SetOperationId(const String& operationId) { __operationId = operationId; } void _ContactAppLaunchDataImpl::SetUri(const String& uri) { __uri = uri; } void _ContactAppLaunchDataImpl::SetCategory(const String& category) { __category = category; } void _ContactAppLaunchDataImpl::SetMime(const String& mime) { __mime = mime; } result _ContactAppLaunchDataImpl::SetExtraData(const IMap* pExtraData) { std::unique_ptr pNewExtraData(new (std::nothrow) HashMap()); SysTryReturn(NID_SCL, pNewExtraData != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); result r = pNewExtraData->Construct(); SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r)); if (pExtraData != null) { std::unique_ptr pMapEnum(pExtraData->GetMapEnumeratorN()); SysTryReturn(NID_SCL, pMapEnum != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); std::unique_ptr pKey(null); std::unique_ptr pVal(null); String* pStr = null; while (pMapEnum->MoveNext() == E_SUCCESS) { pStr = static_cast (pMapEnum->GetKey()); pKey.reset(new (std::nothrow) String(*pStr)); SysTryReturn(NID_SCL, pKey != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); pStr = static_cast (pMapEnum->GetValue()); pVal.reset(new (std::nothrow) String(*pStr)); SysTryReturn(NID_SCL, pVal != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pNewExtraData->Add(pKey.get(), pVal.get()); SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); pKey.release(); pVal.release(); } } __pExtraData = std::move(pNewExtraData); return E_SUCCESS; } bool _ContactAppLaunchDataImpl::IsEmpty(void) const { if (!__displayText.IsEmpty()) { return false; } if (!__uid.IsEmpty()) { return false; } if (!__appId.IsEmpty()) { return false; } if (!__operationId.IsEmpty()) { return false; } if (!__uri.IsEmpty()) { return false; } if (!__category.IsEmpty()) { return false; } if (!__mime.IsEmpty()) { return false; } if (__pExtraData->GetCount() != 0) { return false; } return true; } const _ContactAppLaunchDataImpl* _ContactAppLaunchDataImpl::GetInstance(const ContactAppLaunchData& appLaunchData) { return appLaunchData.__pContactAppLaunchDataImpl; } _ContactAppLaunchDataImpl* _ContactAppLaunchDataImpl::GetInstance(ContactAppLaunchData& appLaunchData) { return appLaunchData.__pContactAppLaunchDataImpl; } }} // Tizen::Social