2 // Copyright (c) 2013 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 * @file FScl_ContactAppLaunchDataImpl.cpp
19 * @brief This is the header file for the %_ContactAppLaunchData class.
21 * This header file contains the declarations of the %_ContactAppLaunchData class.
24 #include <FBaseSysLog.h>
25 #include "FScl_ContactAppLaunchDataImpl.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
30 namespace Tizen { namespace Social
33 _ContactAppLaunchDataImpl::_ContactAppLaunchDataImpl(void)
35 std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
36 SysTryReturnVoidResult(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
38 result r = pExtraData->Construct();
39 SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
41 __pExtraData = std::move(pExtraData);
44 _ContactAppLaunchDataImpl::_ContactAppLaunchDataImpl(const _ContactAppLaunchDataImpl& rhs)
46 std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
47 SysTryReturnVoidResult(NID_SCL, pExtraData != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
49 result r = pExtraData->Construct();
50 SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
52 std::unique_ptr<IMapEnumerator> pMapEnum((rhs.__pExtraData)->GetMapEnumeratorN());
53 SysTryReturnVoidResult(NID_SCL, pMapEnum != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
55 std::unique_ptr<String> pKey(null);
56 std::unique_ptr<String> pVal(null);
59 while (pMapEnum->MoveNext() == E_SUCCESS)
61 pStr = static_cast<String*> (pMapEnum->GetKey());
62 pKey.reset(new (std::nothrow) String(*pStr));
63 SysTryReturnVoidResult(NID_SCL, pKey != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
65 pStr = static_cast<String*> (pMapEnum->GetValue());
66 pVal.reset(new (std::nothrow) String(*pStr));
67 SysTryReturnVoidResult(NID_SCL, pVal != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
69 r = pExtraData->Add(pKey.get(), pVal.get());
70 SysTryReturnVoidResult(NID_SCL, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
76 __pExtraData = std::move(pExtraData);
78 __displayText = rhs.__displayText;
80 __appId = rhs.__appId;
81 __operationId = rhs.__operationId;
83 __category = rhs.__category;
87 _ContactAppLaunchDataImpl::~_ContactAppLaunchDataImpl(void)
91 _ContactAppLaunchDataImpl&
92 _ContactAppLaunchDataImpl::operator =(const _ContactAppLaunchDataImpl& rhs)
99 std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
100 SysTryReturn(NID_SCL, pExtraData != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
102 result r = pExtraData->Construct();
103 SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
105 std::unique_ptr<IMapEnumerator> pMapEnum((rhs.__pExtraData)->GetMapEnumeratorN());
106 SysTryReturn(NID_SCL, pMapEnum != null, *this, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
108 std::unique_ptr<String> pKey(null);
109 std::unique_ptr<String> pVal(null);
112 while (pMapEnum->MoveNext() == E_SUCCESS)
114 pStr = static_cast<String*> (pMapEnum->GetKey());
115 pKey.reset(new (std::nothrow) String(*pStr));
116 SysTryReturn(NID_SCL, pKey != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
118 pStr = static_cast<String*> (pMapEnum->GetValue());
119 pVal.reset(new (std::nothrow) String(*pStr));
120 SysTryReturn(NID_SCL, pVal != null, *this, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
122 r = pExtraData->Add(pKey.get(), pVal.get());
123 SysTryReturn(NID_SCL, !IsFailed(r), *this, r, "[%s] Propagating.", GetErrorMessage(r));
129 __pExtraData = std::move(pExtraData);
131 __displayText = rhs.__displayText;
133 __appId = rhs.__appId;
134 __operationId = rhs.__operationId;
136 __category = rhs.__category;
142 bool operator ==(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs)
144 if (lhs.__displayText != rhs.__displayText)
149 if (lhs.__uid != rhs.__uid)
154 if (lhs.__appId != rhs.__appId)
159 if (lhs.__operationId != rhs.__operationId)
164 if (lhs.__uri != rhs.__uri)
169 if (lhs.__category != rhs.__category)
174 if (lhs.__mime != rhs.__mime)
179 if (!lhs.__pExtraData->Equals(*rhs.__pExtraData))
187 bool operator !=(const _ContactAppLaunchDataImpl& lhs, const _ContactAppLaunchDataImpl& rhs)
189 return !(lhs == rhs);
193 _ContactAppLaunchDataImpl::Equals(const Object& rhs) const
195 const _ContactAppLaunchDataImpl* pContactAppLaunchData = dynamic_cast<const _ContactAppLaunchDataImpl*>(&rhs);
196 if (pContactAppLaunchData == null)
201 return *this == *pContactAppLaunchData;
205 _ContactAppLaunchDataImpl::GetHashCode(void) const
207 int hash = __displayText.GetHashCode();
208 hash += __uid.GetHashCode();
209 hash += __appId.GetHashCode();
210 hash += __operationId.GetHashCode();
211 hash += __uri.GetHashCode();
212 hash += __category.GetHashCode();
213 hash += __mime.GetHashCode();
219 _ContactAppLaunchDataImpl::GetDisplayText(void) const
221 return __displayText;
225 _ContactAppLaunchDataImpl::GetUid(void) const
231 _ContactAppLaunchDataImpl::GetAppId(void) const
237 _ContactAppLaunchDataImpl::GetOperationId(void) const
239 return __operationId;
243 _ContactAppLaunchDataImpl::GetUri(void) const
249 _ContactAppLaunchDataImpl::GetCategory(void) const
255 _ContactAppLaunchDataImpl::GetMime(void) const
261 _ContactAppLaunchDataImpl::GetExtraDataN(void) const
265 std::unique_ptr<HashMap, AllElementsDeleter> pExtraData(new (std::nothrow) HashMap());
266 SysTryReturn(NID_SCL, pExtraData != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
268 result r = pExtraData->Construct();
269 SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
271 std::unique_ptr<IMapEnumerator> pMapEnum(__pExtraData->GetMapEnumeratorN());
272 SysTryReturn(NID_SCL, pMapEnum != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
274 std::unique_ptr<String> pKey(null);
275 std::unique_ptr<String> pVal(null);
278 while (pMapEnum->MoveNext() == E_SUCCESS)
280 pStr = static_cast<String*> (pMapEnum->GetKey());
281 pKey.reset(new (std::nothrow) String(*pStr));
282 SysTryReturn(NID_SCL, pKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
284 pStr = static_cast<String*> (pMapEnum->GetValue());
285 pVal.reset(new (std::nothrow) String(*pStr));
286 SysTryReturn(NID_SCL, pVal != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
288 r = pExtraData->Add(pKey.get(), pVal.get());
289 SysTryReturn(NID_SCL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
295 return pExtraData.release();
299 _ContactAppLaunchDataImpl::SetDisplayText(const String& displayText)
301 __displayText = displayText;
305 _ContactAppLaunchDataImpl::SetUid(const String& uid)
311 _ContactAppLaunchDataImpl::SetAppId(const String& appId)
317 _ContactAppLaunchDataImpl::SetOperationId(const String& operationId)
319 __operationId = operationId;
323 _ContactAppLaunchDataImpl::SetUri(const String& uri)
329 _ContactAppLaunchDataImpl::SetCategory(const String& category)
331 __category = category;
335 _ContactAppLaunchDataImpl::SetMime(const String& mime)
341 _ContactAppLaunchDataImpl::SetExtraData(const IMap* pExtraData)
343 std::unique_ptr<HashMap, AllElementsDeleter> pNewExtraData(new (std::nothrow) HashMap());
344 SysTryReturn(NID_SCL, pNewExtraData != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
346 result r = pNewExtraData->Construct();
347 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Failed to construct pExtraData.", GetErrorMessage(r));
349 if (pExtraData != null)
351 std::unique_ptr<IMapEnumerator> pMapEnum(pExtraData->GetMapEnumeratorN());
352 SysTryReturn(NID_SCL, pMapEnum != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
354 std::unique_ptr<String> pKey(null);
355 std::unique_ptr<String> pVal(null);
358 while (pMapEnum->MoveNext() == E_SUCCESS)
360 pStr = static_cast<String*> (pMapEnum->GetKey());
361 pKey.reset(new (std::nothrow) String(*pStr));
362 SysTryReturn(NID_SCL, pKey != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
364 pStr = static_cast<String*> (pMapEnum->GetValue());
365 pVal.reset(new (std::nothrow) String(*pStr));
366 SysTryReturn(NID_SCL, pVal != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
368 r = pNewExtraData->Add(pKey.get(), pVal.get());
369 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
376 __pExtraData = std::move(pNewExtraData);
382 _ContactAppLaunchDataImpl::IsEmpty(void) const
384 if (!__displayText.IsEmpty())
389 if (!__uid.IsEmpty())
394 if (!__appId.IsEmpty())
399 if (!__operationId.IsEmpty())
404 if (!__uri.IsEmpty())
409 if (!__category.IsEmpty())
414 if (!__mime.IsEmpty())
419 if (__pExtraData->GetCount() != 0)
427 const _ContactAppLaunchDataImpl*
428 _ContactAppLaunchDataImpl::GetInstance(const ContactAppLaunchData& appLaunchData)
430 return appLaunchData.__pContactAppLaunchDataImpl;
433 _ContactAppLaunchDataImpl*
434 _ContactAppLaunchDataImpl::GetInstance(ContactAppLaunchData& appLaunchData)
436 return appLaunchData.__pContactAppLaunchDataImpl;