Fix wrong log value
[platform/core/api/notification.git] / notification-ex / group_item.cc
index a1bda0e..75a55c7 100644 (file)
@@ -23,6 +23,7 @@
 #include "notification-ex/group_item.h"
 #include "notification-ex/group_item_implementation.h"
 #include "notification-ex/factory_manager.h"
+#include "notification-ex/ex_util.h"
 #include "notification-ex/exception.h"
 
 #ifdef LOG_TAG
@@ -53,6 +54,14 @@ GroupItem::GroupItem(shared_ptr<AbstractAction> action)
 GroupItem::Impl::Impl(GroupItem* parent)
     : parent_(parent) {
   LOGI("GroupItem created");
+  char* name;
+  int ret = app_get_name(&name);
+  if (ret != APP_ERROR_NONE) {
+    app_label_ = util::GetAppId();
+  } else {
+    app_label_ = string(name);
+    free(name);
+  }
 }
 
 GroupItem::~GroupItem() {
@@ -67,9 +76,8 @@ Bundle GroupItem::Serialize() const {
   b = AbstractItem::Serialize();
   b.Add(GROUP_DIRECTION_KEY, impl_->is_vertical_ ?
       GROUP_DIRECTION_VERTICAL : GROUP_DIRECTION_HORIZONTAL);
-  if (!impl_->app_label_.empty())
-    b.Add(GROUP_APP_LABEL_KEY, impl_->app_label_);
 
+  b.Add(GROUP_APP_LABEL_KEY, impl_->app_label_);
   if (impl_->children_list_.size() == 0)
     return b;
 
@@ -145,16 +153,40 @@ bool GroupItem::IsItemTypeExist(int type) {
 list<string> GroupItem::GetSharedPath() const {
   list<string> ret;
 
+  auto r = AbstractItem::GetSharedPath();
+  for (auto& shared_path_r : r)
+    ret.push_back(move(shared_path_r));
+
   for (auto& i : impl_->children_list_) {
-    auto s = i->GetSharedPath();
-    for (auto& j : s) {
-      ret.push_back(move(j));
-    }
+    auto c = i->GetSharedPath();
+    for (auto& shared_path_c : c)
+      ret.push_back(move(shared_path_c));
   }
 
   return ret;
 }
 
+void GroupItem::SetSharedPath() {
+  for (auto& i : impl_->children_list_)
+    i->SetSharedPath();
+}
+
+list<map<string, string>> GroupItem::GetPathMapList() const {
+  list<map<string, string>> path_map_list;
+
+  auto r = AbstractItem::GetPathMapList();
+  for (auto& path_map_r : r)
+    path_map_list.push_back(move(path_map_r));
+
+  for (auto& i : impl_->children_list_) {
+    auto c = i->GetPathMapList();
+    for (auto& path_map_c : c)
+      path_map_list.push_back(move(path_map_c));
+  }
+
+  return path_map_list;
+}
+
 void GroupItem::AddChild(shared_ptr<AbstractItem> child) {
   impl_->children_list_.emplace_back(child);
 }
@@ -168,6 +200,10 @@ void GroupItem::RemoveChild(string itemId) {
   }
 }
 
+void GroupItem::RemoveChildren() {
+  impl_->children_list_.clear();
+}
+
 list<shared_ptr<AbstractItem>> GroupItem::GetChildren() {
   return impl_->children_list_;
 }
@@ -181,13 +217,6 @@ bool GroupItem::IsVertical() {
 }
 
 string GroupItem::GetAppLabel() {
-  if (impl_->app_label_.empty()) {
-    char* name;
-    int ret = app_get_name(&name);
-    if (ret != APP_ERROR_NONE)
-      THROW(ERROR_IO_ERROR);
-    impl_->app_label_ = string(name);
-  }
   return impl_->app_label_;
 }