Handling null value in chat-message get APIs 97/217497/5
authorhyunho <hhstark.kang@samsung.com>
Tue, 12 Nov 2019 06:26:27 +0000 (15:26 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Thu, 28 Nov 2019 10:24:14 +0000 (10:24 +0000)
chat-message can have null attributes

Change-Id: I82bd848dec95508f3973d4e6e1d5d4fb6ed3fd59
Signed-off-by: hyunho <hhstark.kang@samsung.com>
notification-ex/chat_message_item.cc
notification-ex/stub.cc

index be4e80b..6bc1934 100644 (file)
@@ -171,18 +171,26 @@ std::list<std::string> ChatMessageItem::GetSharedPath() const {
 }
 
 TextItem& ChatMessageItem::GetNameItem() const {
+  if (impl_->name_ == nullptr)
+    return static_cast<TextItem&>(FactoryManager::GetInst().GetNullItem());
   return *(impl_->name_);
 }
 
 TextItem& ChatMessageItem::GetTextItem() const {
+  if (impl_->text_ == nullptr)
+    return static_cast<TextItem&>(FactoryManager::GetInst().GetNullItem());
   return *(impl_->text_);
 }
 
 ImageItem& ChatMessageItem::GetImageItem() const {
+  if (impl_->image_ == nullptr)
+    return static_cast<ImageItem&>(FactoryManager::GetInst().GetNullItem());
   return *(impl_->image_);
 }
 
 TimeItem& ChatMessageItem::GetTimeItem() const {
+  if (impl_->time_ == nullptr)
+    return static_cast<TimeItem&>(FactoryManager::GetInst().GetNullItem());
   return *(impl_->time_);
 }
 
index 1c700b9..f8b50a7 100644 (file)
@@ -480,7 +480,10 @@ extern "C" EXPORT_API int noti_ex_item_chat_message_get_name(
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
-  *name = new Handle(&(p->GetNameItem()));
+  if (p->GetNameItem().GetType() == AbstractItem::NullObject)
+    *name = nullptr;
+  else
+    *name = new Handle(&(p->GetNameItem()));
 
   return NOTI_EX_ERROR_NONE;
 }
@@ -498,7 +501,10 @@ extern "C" EXPORT_API int noti_ex_item_chat_message_get_text(
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
-  *text = new Handle(&(p->GetTextItem()));
+  if (p->GetTextItem().GetType() == AbstractItem::NullObject)
+    *text = nullptr;
+  else
+    *text = new Handle(&(p->GetTextItem()));
 
   return NOTI_EX_ERROR_NONE;
 }
@@ -516,7 +522,10 @@ extern "C" EXPORT_API int noti_ex_item_chat_message_get_image(
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
-  *image =  new Handle(&(p->GetImageItem()));
+  if (p->GetImageItem().GetType() == AbstractItem::NullObject)
+    *image = nullptr;
+  else
+    *image =  new Handle(&(p->GetImageItem()));
 
   return NOTI_EX_ERROR_NONE;
 }
@@ -534,7 +543,10 @@ extern "C" EXPORT_API int noti_ex_item_chat_message_get_time(
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
   ChatMessageItem* p = static_cast<ChatMessageItem*>(h->Get());
-  *time = new Handle(&(p->GetTimeItem()));
+  if (p->GetTimeItem().GetType() == AbstractItem::NullObject)
+    *time = nullptr;
+  else
+    *time = new Handle(&(p->GetTimeItem()));
 
   return NOTI_EX_ERROR_NONE;
 }